Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

JFrame Title bar color -- in BasicLookAndFeel

Thread view: 
Louise - 19 Nov 2003 11:31 GMT
Hi does anyone know how to get the color of the title bar in an
internal frame?
When I create my own dialog and then get the color from the UIManager
my dialog
title bar is light blue instead of dark blue like my main JFrame?

any help on this would be much appreaciated!!!

Below is my code...
I have created a my own dialog and set it as undecorated adding a my
own title
bar.  I set the color of this bar using the
UIManager.getColor("InternalFrame.activeTitleBackground");
where "InternalFrame.activeTitleBackground" is defined in
javax.swing.plaf.basic.BasicLookAndFeel
I have also tried several other properties in BasicLookAndFeel:
activeCaption, inactiveCaption, inactiveCaptionBorder,
activeCaptionBorder,
menu
but none of them are correct!!

public class MyDialog extends JDialog
{
   public MyDialog ( Frame owner,String dialogTitle, String
initialText )
   {
       super(owner);
       
       //Removes the default title bar of the dialog, We do not want
a close
       //button.
       setUndecorated( true );
       
       //We still what the dialog to have a title bar so create this.
       JPanel header = new JPanel();
       JLabel title = new JLabel();
       title.setText(dialogTitle);
       title.setOpaque( false );
       header.setLayout( new BorderLayout() );
       
       //get the color of title borders.
       //This is defined in javax.swing.plaf.basic.BasicLookAndFeel

       Color titleBorderColor =
UIManager.getColor("InternalFrame.activeTitleBackground");

       header.setBackground( titleBorderColor );

       header.add( title , BorderLayout.CENTER );
       
       JPanel contents = new JPanel();
       contents.setBorder( BorderFactory.createRaisedBevelBorder());
       contents.setLayout(new BorderLayout());
       contents.add(header,  BorderLayout.NORTH);
       setContentPane( contents );

       //add the progress bar and stop button to this dialog.
       pack();
   }
}
Sandip Chitale - 19 Nov 2003 16:41 GMT
<http://java.sun.com/j2se/1.4.2/docs/api/java/awt/SystemColor.html#activeCaption>

> Hi does anyone know how to get the color of the title bar in an
> internal frame?
[quoted text clipped - 56 lines]
>     }
> }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.