系统可选风格
- windows风格: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
- windows Classic风格: com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel
- Metal风格 ( Swing默认) :avax.swing.plaf.metal.MetalLookAndFeel
- Motif风格 : com.sun.java.swing.plaf.motif.MotifLookAndFeel
- Mac 风格 : com.sun.java.swing.plaf.mac.MacLookAndFeel (需要在苹果电脑上才能实现)
- GTK风格: com.sun.java.swing.plaf.gtk.GTKLookAndFeel ( 需要在相关的操作系统上方可实现 )
- UIManager.getCrossPlatformLookAndFeelClassName() ; ( 可跨平台的Swing默认风格)
try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // 创建窗体对象 JFrame jFrame =new JFrame(); // 设置窗体大小 jFrame.setSize(600, 400); // 设置窗体全屏展示 //jFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); // 设置窗体显示位置 //jFrame.setLocation(100,200); // 设置窗体显示正中间 jFrame.setLocationRelativeTo(null); // 设置窗体标题 jFrame.setTitle("窗体标题"); // 设置窗体不可全屏显示 jFrame.setResizable(false); // 设置窗体关闭后退出程序 jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置此窗口是否应该始终位于其他窗口上方 jFrame.setAlwaysOnTop(true); // 设置窗体图标 jFrame.setIconImage(new ImageIcon(HelloWorld.class.getResource("/images/book.png")).getImage()); // 设置窗体可见 jFrame.setVisible(true); FlowLayout flowLayout=new FlowLayout(FlowLayout.LEFT,20,10); JPanel jPanel =new JPanel(flowLayout); JButton btn01 =new JButton("Button01"); JButton btn02 =new JButton("Button02"); JButton btn03 =new JButton("Button03"); JButton btn04 =new JButton("Button04"); JButton btn05 =new JButton("Button05"); jPanel.add(btn01); jPanel.add(btn02); jPanel.add(btn03); jPanel.add(btn04); jPanel.add(btn05); jFrame.add(jPanel); }catch (Exception e) { // TODO: handle exception }
第三方jar包风格 (beautyeye)
具体可参考文档: BeautyEye简明开发者指南-BeautyEye/Java技术区 - 即时通讯开发者社区!
try { BeautyEyeLNFHelper.translucencyAtFrameInactive=true; UIManager.put("RootPane.setupButtonVisible", false); BeautyEyeLNFHelper.frameBorderStyle=BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow; org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF(); // 创建窗体对象 JFrame jFrame =new JFrame(); // 设置窗体大小 jFrame.setSize(600, 400); // 设置窗体全屏展示 //jFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); // 设置窗体显示位置 //jFrame.setLocation(100,200); // 设置窗体显示正中间 jFrame.setLocationRelativeTo(null); // 设置窗体标题 jFrame.setTitle("窗体标题"); // 设置窗体不可全屏显示 jFrame.setResizable(false); // 设置窗体关闭后退出程序 jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置此窗口是否应该始终位于其他窗口上方 jFrame.setAlwaysOnTop(true); // 设置窗体图标 jFrame.setIconImage(new ImageIcon(HelloWorld.class.getResource("/images/book.png")).getImage()); // 设置窗体可见 jFrame.setVisible(true); FlowLayout flowLayout=new FlowLayout(FlowLayout.LEFT,20,10); JPanel jPanel =new JPanel(flowLayout); JButton btn01 =new JButton("Button01"); JButton btn02 =new JButton("Button02"); JButton btn03 =new JButton("Button03"); JButton btn04 =new JButton("Button04"); JButton btn05 =new JButton("Button05"); jPanel.add(btn01); jPanel.add(btn02); jPanel.add(btn03); jPanel.add(btn04); jPanel.add(btn05); jFrame.add(jPanel); }catch (Exception e) { // TODO: handle exception }
标签:外观,jFrame,add,jPanel,窗体,new,JavaSwing,JButton,美化 From: https://www.cnblogs.com/liangqingyun/p/18570909