[java] Extending swing...

Started by
5 comments, last by pim 20 years, 6 months ago
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]
Advertisement
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
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...
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
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?
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
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]

This topic is closed to new replies.

Advertisement