Change frame titlebar

i would like to replace the title bar of a jframei want to draw my own buttons (Close ,Max ,Min)how can i do it?thanks shay
[151 byte] By [shay_tea] at [2007-10-3 2:44:44]
# 1
You can remove the existing toolbar withframe.setUndecorated(true)Then you can add your own title bar at the north position of BorderLayouted PanelICED
icewalker2ga at 2007-7-14 20:33:14 > top of Java-index,Desktop,Core GUI APIs...
# 2
i have been thinking about this solutionbet i think it's not good enoghtwhat append when i what to replace the frams in my application.and i am already using BorderLayout with NORTH attribute
shay_tea at 2007-7-14 20:33:14 > top of Java-index,Desktop,Core GUI APIs...
# 3
> and i am already using BorderLayout with NORTH> attributeYou can always put a second panel inside your first panel (at CENTER), and put a component at the NORTH of that inner panel. Panels can be nested as deep as you like!Regards,Tim
TimRyanNZa at 2007-7-14 20:33:14 > top of Java-index,Desktop,Core GUI APIs...
# 4

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.

shay_tea at 2007-7-14 20:33:14 > top of Java-index,Desktop,Core GUI APIs...
# 5

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/

davedesa at 2007-7-14 20:33:14 > top of Java-index,Desktop,Core GUI APIs...
# 6

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.

mikeyfreakea at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...
# 7
i made it..after looking at the MetalRootPaneUIi see that the is a MetalTitlePane class so i extends the BasicRootPaneUIand use my own title pane component..this why it's a stantard...thanks..
shay_tea at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...
# 8

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

prgsmall2a at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...
# 9
I am looking to do something similar. Any help would be much appreciated.
lost7418880a at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...
# 10

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.

latheefa at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...
# 11

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

AmitavaDeya at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...
# 12
Hi,I am able to place the image on the title bar of JRootPane.FRAME.Is there any way to make it possible on XP look title bar ie JRootPane.NONEThanksLatheef
latheefa at 2007-7-14 20:33:15 > top of Java-index,Desktop,Core GUI APIs...