[Original] Swing Skills 8: Perfect Lookandfeel Solution Swing Tips 8: Perfect LookandFeel Solutions in Swing Tips 4: Settings System Windows, Borders, Titles, Minimization, Restore, Maximization Buttons and Swing Tips 5: Run LookAndFeel set I used if (currentLookAndFeel.getSupportsWindowDecorations ()) {frame.setUndecorated (true);. frame.getRootPane () setWindowDecorationStyle (JRootPane.FRAME);} and public static void setLookAndFeel (Component target, LookAndFeel lnf) {try {UIManager.SetLookandFeel (LNF); swingutilities.UpdateComponenttreeui (Target);} catch (Exception E) {system.out.println ("Error:" E);}} reach not only set LookandFeel, make system windows, borders, Title, minimize, restore, and maximize the purpose of Lookandfeel. But this method is also very obvious: 1.Matrix users sslazio21 reflect the new pop-up JFilechooser system window side frame as System LookandFeel2. Do not have a system window, border, Lookandfeel, such as Windows, Motif, and their subclasses, root JFrames have no system windows, borders, headings, resulting in minimization, restore, maximum, change size .1 solution is that I am in Swing Skill 4: Set System window, border, title, minimization, restore, maximize button mentioned in the button 1: Global Setup //JFrame, JDialog.SetDefaultLookandfeelDecorated//static global setting // provides newly code as to WHETHER or Not Newly Created JDialogs and Jframes Should Have Their Window Decorations // (Such as Borders, WID gets to close the window, title ...) provided by the current look and feel JFrame.setDefaultLookAndFeelDecorated (true);. initialization is complete try {Class lafClass = Class.forName (currentLookAndFeel); LookAndFeel laf = (LookAndFeel) (lafClass .newinstance ()); jframe.setDefaultLookandFeelDecorated (laf.getsupportswindowdecorations ()); jdialog.setdefaultLookandFeelDecorated (laf.getsupportswindowDecorations ());
} Catch (Exception E) {} must be set to JFrame and JDialog. Note Frame.Setundecoated (True) and JFrame.SetDefault (TRUE) must be before the window is displayed, that is, Frame.Show () or Frame.setVisible (TRUE) before because of java doc says setUndecorated This method can only be called while the frame is not displayable.setDefaultLookAndFeelDecorated of java doc says newly created JDialogs and JFrames, valid for the new window. for 2, I hope the window frame, with the title of LookAndFeel Holding setLookandFeel, if it is for LOOKANDFEEL without windows, borders, headers, using system windows, border, title. In addition to the initialization, I also changed to setLookandfeel: Public Static Void SetLookandFeel (Component Target, Lookandfeel LNF ) {try {JFrame.setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ()); JDialog.setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ()); UIManager.setLookAndFeel (lnf); SwingUtilities.updateComponentTreeUI (target);} catch (Exception e) {System.out .println ("Error:" E);}} is valid for the new window (new pop-up JFilechooser), but for the existing window, border, title will not change. It seems that the existing window must be used Frame.setundecora (true); frame.getrootpane (). setWindowDecoATIO nStyle (JRootPane.FRAME); but there setUndecorated: This method can only be called while the frame is not displayable try frame.hide (); frame.setUndecorated (true); frame.getRootPane () setWindowDecorationStyle (JRootPane.FRAME.. ); Frame.show (); not only no effect, still lost response while SETLOOKANDEEL. Checking Java DOC discovers the status of the frame is not displayable only before Frame's first show () before (). Only Dispose Afterwards: frame.dispose (); frame.setundecoated (true); frame.getrootpane (). SetwindowdecorationStyle (jrootpane.frame); frame.show (); this can be said to be a Swing LookandFeel's perfect solution, the final code is as follows : initialization, before the first window to establish: try {Class lafClass = Class.forName (currentLookAndFeel); LookAndFeel laf = (LookAndFeel) (lafClass.newInstance ()); JFrame.setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ());
JDialog.setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ());} catch (Exception e) {} public static void setLookAndFeel (JFrame frame, LookAndFeel lnf) {try {// global settings JFrame.setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ()); JDialog .setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ()); UIManager.setLookAndFeel (lnf); // change the current frame of the window borders, title frame.dispose (); frame.setUndecorated (lnf.getSupportsWindowDecorations ()); frame.getRootPane () .SETWINDOWDECORATIONSTYLE (JRootpane.Frame); frame.show (); swingutilities.UpdateComponentTreeui (Frame);} catch (Exception E) {system.out.println ("Error:" E);}} is unfortunate, to JDIALOG must there is also a, although only one word changed, or have .public static void setLookAndFeel (JDialog frame, LookAndFeel lnf) {try {// global settings JFrame.setDefaultLookAndFeelDecorated (laf.getSupportsWindowDecorations ()); JDialog.setDefaultLookAndFeelDecorated (laf. GetSupportswind owDecorations ()); UIManager.setLookAndFeel (lnf); // change the current frame of the window borders, title frame.dispose (); frame.setUndecorated (lnf.getSupportsWindowDecorations ());. frame.getRootPane () setWindowDecorationStyle (JRootPane. Frame); frame.show (); swingutilities.UpdateComponenttreeui (Frame);} catch (exception e) {system.out.println ("Error:" E);