List of usage examples for javax.swing JFrame setDefaultLookAndFeelDecorated
public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
JFrame
s should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel. From source file:Main.java
/** * Workaround for Bug#5063999.//from www. java2s .com */ public static void installDefaults() { String defaultlaf = System.getProperty("swing.defaultlaf"); if (defaultlaf == null || defaultlaf.length() == 0) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException ex) { // NO-OP } } JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); UIManager.put(FORMATTED_TEXTFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY)); UIManager.put(FORMATTED_TEXTFIELD_INACTIVE_BACKGROUND_KEY, UIManager.get(TEXTFIELD_INACTIVE_BACKGROUND_KEY)); UIManager.put(PASSWORDFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY)); // try { // UIManager.put(LafWidget.TABBED_PANE_PREVIEW_PAINTER, // new DefaultTabPreviewPainter() { // // /** // * {@inheritDoc} // */ // @Override // public TabOverviewKind getOverviewKind(JTabbedPane tabPane) { // return TabOverviewKind.ROUND_CAROUSEL; // // return TabOverviewKind.MENU_CAROUSEL; // } // }); // UIManager.put(LafWidget.COMPONENT_PREVIEW_PAINTER, // new DefaultPreviewPainter()); // UIManager.put(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE); // // UIManager.put(LafWidget.COMBO_BOX_NO_AUTOCOMPLETION, Boolean.TRUE); // } catch (Throwable ignored) { // // substance may not be available. // } }
From source file:ButtonDemo.java
private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("ButtonDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ButtonDemo newContentPane = new ButtonDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); frame.pack();//from w w w.j a v a2 s . c o m frame.setVisible(true); }
From source file:SpringDemo1.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from www .j a v a2 s .c o m*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringDemo1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); contentPane.add(new JLabel("Label: ")); contentPane.add(new JTextField("Text field", 15)); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringDemo2.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w ww .j a v a 2 s. com*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringDemo2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 5, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, 5, SpringLayout.NORTH, contentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringDemo3.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w w w .j a va 2 s . com*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringDemo3"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 5, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, 5, SpringLayout.NORTH, contentPane); //Adjust constraints for the content pane: Its right //edge should be 5 pixels beyond the text field's right //edge, and its bottom edge should be 5 pixels beyond //the bottom edge of the tallest component (which we'll //assume is textField). layout.putConstraint(SpringLayout.EAST, contentPane, 5, SpringLayout.EAST, textField); layout.putConstraint(SpringLayout.SOUTH, contentPane, 5, SpringLayout.SOUTH, textField); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:TopLevelDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. */// w w w . java2 s. co m private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("TopLevelDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create the menu bar. Make it have a cyan background. JMenuBar cyanMenuBar = new JMenuBar(); cyanMenuBar.setOpaque(true); cyanMenuBar.setBackground(Color.cyan); cyanMenuBar.setPreferredSize(new Dimension(200, 20)); //Create a yellow label to put in the content pane. JLabel yellowLabel = new JLabel(); yellowLabel.setOpaque(true); yellowLabel.setBackground(Color.yellow); yellowLabel.setPreferredSize(new Dimension(200, 180)); //Set the menu bar and add the label to the content pane. frame.setJMenuBar(cyanMenuBar); frame.getContentPane().add(yellowLabel, BorderLayout.CENTER); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringDemo4.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *///from ww w. j a v a 2 s .co m private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringDemo4"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); //Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); //Adjust constraints for the label so it's at (5,5). SpringLayout.Constraints labelCons = layout.getConstraints(label); labelCons.setX(Spring.constant(5)); labelCons.setY(Spring.constant(5)); //Adjust constraints for the text field so it's at //(<label's right edge> + 5, 5). SpringLayout.Constraints textFieldCons = layout.getConstraints(textField); textFieldCons.setX(Spring.sum(Spring.constant(5), labelCons.getConstraint(SpringLayout.EAST))); textFieldCons.setY(Spring.constant(5)); //Adjust constraints for the content pane. setContainerSize(contentPane, 5); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:Main.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//* w ww . j ava 2s . c o m*/ private static void createAndShowGUI() { //Suggest that the L&F (rather than the system) //decorate all windows. This must be invoked before //creating the JFrame. Native look and feels will //ignore this hint. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("FrameDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel emptyLabel = new JLabel(""); emptyLabel.setPreferredSize(new Dimension(175, 100)); frame.add(emptyLabel, BorderLayout.CENTER); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:FrameDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. */// w w w.ja v a 2 s. c o m private static void createAndShowGUI() { //Suggest that the L&F (rather than the system) //decorate all windows. This must be invoked before //creating the JFrame. Native look and feels will //ignore this hint. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("FrameDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel emptyLabel = new JLabel(""); emptyLabel.setPreferredSize(new Dimension(175, 100)); frame.getContentPane().add(emptyLabel, BorderLayout.CENTER); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringBox.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w ww . ja va2 s . c o m*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SpringBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. Container contentPane = frame.getContentPane(); contentPane.setLayout(new SpringLayout()); //Add the buttons. contentPane.add(new JButton("Button 1")); contentPane.add(new JButton("Button 2")); contentPane.add(new JButton("Button 3")); contentPane.add(new JButton("Long-Named Button 4")); contentPane.add(new JButton("5")); //Lay out the buttons in one row and as many columns //as necessary, with 6 pixels of padding all around. SpringUtilities.makeCompactGrid(contentPane, 1, contentPane.getComponentCount(), 6, 6, 6, 6); //Display the window. frame.pack(); frame.setVisible(true); }