that's right but .
the pepole how will use my frame
will have to know that there is another panel inside the contentPane panel
and they have to put their components there...
it's not a "standard" why
how can i draw my own...
i thing that i need to replace the RootPaneUI
Dont know how to write a new one.
EDIT:
How about making a method getTheContentPane() / setTheContentPane() or something which returns/changes the content pane you want the users to work with. Just deprecate the original getContentPane() / setContentPane() methods for your class.
Keep in mind that if you're using your own titlebar, you'll have to set it up for dragging, resizing, minimizing, maximizing, etc... It can be quite a task.
IFrame actually does exactly what you're looking at, even using their own setIContentPane() / getIcontentPane() methods. See this article for more info...
http://www-128.ibm.com/developerworks/java/library/j-iframe/
How about adding a JMenu to your Frame? It could be placed at the top of your frame (by default), and would not be included in your NORTH panel. I don't know if that could replace the buttons you wish to create...
OR
You could do something like:
JPanel mainPanel = new JPanel(GridLayout(2,1);
mainPanel.add(topButtonPanel);
mainPanel.add(borderLayoutPanel);
frame.getContentPane().add(mainPanel);
Then you would have the button panel above your border layout panel. Try it out!!
Message was edited by:
mikeyfreake
You could also extend the JFrame class, setting up the frame the way you would like, then override the getContentPane() method to return the borderLayoutPanel from the example given to you above.... but I don't know if this is that good of an idea. It would provide a more 'standard' way of allowing individuals to add components to the content pane, which is what you wanted.
Hi Shay,
I saw your post about changing the title bar. I am in the process of doing that as well. Can you provide me with more details on how you did it? I figure that I have to replace MetalPaneTitle, but to do that it looks like I also have to replace MetalRootPaneUI. Is there an easier way?
Thanks,
Peter
I wanted to add an animated Gif file to the title bar near to the minimize icon.
Can I do it by extending MetelLookandFeel and using my own MyRootPaneUI by renaming the MetalRootPaneUI and then just renaming the MetalTitlePane to MyTitlePane. In MyTitlePane, I plan to add JLabel in addSubComponent() for adding Gif.
So I need to rename MetalRootPaneUI and MetalTitlePane and then use this by extending MetelLookandFeel and overriding initClassDefaults() to point "RootPaneUI", to "MyRootPaneUI".
But I get exception:
UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JRootPane[,0,0,
0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.
0,border=,flags=1,maximumSize=,minimumSize=,preferredSize=]
java.lang.Error
at javax.swing.UIDefaults.getUIError(Unknown Source)...
Please help
Thanks in advance.
A simple solution(might be) is to extend a class from OceanTheme and set that L&F to your program. And create close.gif, close-pressed.gif, maximize.gif, etc.
But where to place those gif files, i dont know, you can try putting those in the .jar file.
Read the bug id 5086089, http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5086089