Archived

This topic is now archived and is closed to further replies.

pim

[java] Extending swing...

Recommended Posts

Hi! I'm currently programming a logic gate simulator in java, but have encountered a few problems customizing swing components. I'm trying to combine the JDesktopPane with a JTabbedPane so that I get a tab for all the windows in the desktop (Just like many text editors have!) The problems that I have encountered are the following: 1 - I can't seem to catch the JInternalFrame's Maximize message in any other way than overriding setMaximum method. 2 - I'm having trouble setting the active window! I've tried setSelected, but it only helps 50% of the time?!? 3 - I'm trying to create a copy of the maximize/minimize buttons to put in the menu bar - any solutions on how to do that? [edited by - pim on October 16, 2003 12:53:54 PM]

Share this post


Link to post
Share on other sites
Why bother with JDesktopPane if you are using JTabbedPane? With JTabbedPane, the use of minimize is redundant. When the user loads a document, just create another tab.



First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
I want a JTabbePane to contain a JDesktopPane. The desktop will be the same for every tab, but when you select a tab the window in the desktop associated with that tab will be selected. This will help selecting windows when they are maximized for instance...

Share this post


Link to post
Share on other sites
I understand what you are trying to do, it just seems redundant. You can just as easily put the contents of each JInternalFrame inside a JPanel instead and put each JPanel in a tab of the JTabbedpane. Are you just trying to go for a cool factor or something?

Did you look at the method addInternalFrameListener()? An InternalFrameListener produces events similar to WindowListener.



First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
I could do that, but I want to have the ability to look at different documents at the same time! I have taken a look at InternalFrameListener, but it didn''t help my problem... it doesn''t give you the ability to catch maximize messages. I could check the size of the window against the maximum size, but it wouldn''t be the same, would it?

Share this post


Link to post
Share on other sites
So you are just using tabs for a coolness factor or an alternate interface.

1. Since InternalFrameListener does not catch maximize events, you may have to go with your first option. Subclass JInternalFrame and override setMaximize to catch that event. Another option to look at is making a DesktopManager interface by subclassing DefaultDestopManager and calling setDesktopManager on the JDesktopPane. There is a method call for maximizeFrame which takes a JInternalFrame as its parameter.

2. Are you calling setSelected on the JInternalFrame or the JDesktopPane? If you haven''t already, try it on the JDesktopPane.

3. One way is to use an image. JMenuItem can hold an image.



First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
Thanks for the help! I'll look into 1 and 2 (I'm not at my own computer now).
In 3, I was looking for the functionality. It seems like the buttons are instances of private classes, so I can't instanciate them...

[edited by - pim on October 20, 2003 8:38:26 AM]

Share this post


Link to post
Share on other sites