Java swing windows style
You will need to first set the look and feel to use the cross platform look and feel As someone commented before it's called metal.
Then before you create the Frame you need to request that the borders are drawn by the look and feel. This will set the look and feel to the one you want. As the cross platform look and feel is metal in Sun's JRE. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to make a window look like this in Java? Ask Question. Asked 10 years, 10 months ago. Active 8 years, 4 months ago.
Viewed 13k times. How do I create a window which looks like this in Java: I want that window layout, instead of the standard Windows-borders, and I don't know how this is called. Edit: look and feel doesn't work for me:. Joachim Sauer k 55 55 gold badges silver badges bronze badges.
If the window system supports minimization, then the icon is used to represent the minimized window. Most window systems or look and feels also display the icon in the window decorations.
A typical icon size is 16x16 pixels, but some window systems use other sizes. The following snapshots show three frames that are identical except for their window decorations. As you can tell by the appearance of the button in each frame, all three use the Java look and feel. The first uses decorations provided by the window system, which happen to be Microsoft Windows, but could as easily be any other system running the Java platform.
The second and third use window decorations provided by the Java look and feel. The third frame uses Java look and feel window decorations, but has a custom icon. Here is an example of creating a frame with a custom icon and with window decorations provided by the look and feel:.
As the preceding code snippet implies, you must invoke the setDefaultLookAndFeelDecorated method before creating the frame whose decorations you wish to affect. You can switch back to using window system decorations by invoking JFrame. Some look and feels might not support window decorations; in this case, the window system decorations are used.
The full source code for the application that creates the frames pictured above is in FrameDemo2. Besides showing how to choose window decorations, FrameDemo2 also shows how to disable all window decorations and gives an example of positioning windows. By default, when the user closes a frame onscreen, the frame is hidden. Although invisible, the frame still exists and the program can make it visible again. If you want different behavior, then you need to either register a window listener that handles window-closing events, or you need to specify default close behavior using the setDefaultCloseOperation method.
You can even do both. More precisely, when the last displayable window within the Java virtual machine VM is disposed of, the VM may terminate. The default close operation is executed after any window listeners handle the window-closing event.
So, for example, assume that you specify that the default close operation is to dispose of a frame. You also implement a window listener that tests whether the frame is the last one visible and, if so, saves some data and exits the application. Under these conditions, when the user closes a frame, the window listener will be called first.
For more information about handling window-closing events, see How to Write Window Listeners. Besides handling window-closing events, window listeners can also react to other window state changes, such as iconification and activation. The following tables list the commonly used JFrame constructors and methods. Other methods you might want to call are defined by the java.
Frame , java. Window , and java. Component classes, from which JFrame descends. Because each JFrame object has a root pane, frames have support for interposing input and painting behavior in front of the frame children, placing children on different "layers", and for Swing menu bars.
All of the standalone applications in this trail use JFrame. The following table lists a few and tells you where each is discussed. All rights reserved. Give each jPanel a unique variable name such as jPanelWindow1 … etc. Select each jPanel one by one and size it to fill the JFrame completely. The custom design of each jPanel can be done later. For now you can insert a Label in the jPanel saying it is Window 1 ,Window 2 etc.
To select a jPanel for inserting a component you have to double click it in the component navigator This is important. You can also use the property sheets on right clicking the Jpanel to set the height and width of the Jpanel. By now you have a jFrame as your main class with multiple jPanels, each sized to fit the jFrame,each Jpanel with a unique variable name. Each Jpanel has a label to identify itself when displayed Label : Window 1 etc. You also have a menu structure to navigate to the Jpanels.
The following is just sample code to be used as a guideline and will be different for your application. Your email address will not be published. This site uses Akismet to reduce spam. Learn how your comment data is processed.
0コメント