一直没怎么做过javase,功能性的马马虎虎也就算了,
可对UI要求也比较高,所以请教一下
1)
如何自定义JOptionPane.showMessageDialog的样式,
包括按钮背景,文字,整个弹出窗体的背景,message文字样式等等(如上图)2)
如何自定义JTabbedPane的tab背景色以及文字样式等等(如上图)JOptionPaneJTabbedPane自定义样式

解决方案 »

  1.   

    建议你用NetBeans做javase的程序。直观,理解
      

  2.   


    我用了,可JOptionPane.showMessageDialog的窗口又不能所见即所得吧
      

  3.   

    可以用UIManager改变背景颜色,字体等UIManager UI=new UIManager();
     UI.put("OptionPane.background", Color.white);
     UI.put("Panel.background", Color.white);
     UI.put("OptionPane.font", new FontUIResource(new Font(...))); JOptionPane.showMessageDialog(null,"Text","SetColor",JOptionPane.INFORMATION_MESSAGE);
      

  4.   

    private void initTabComponent(int i) {
        pane.setTabComponentAt(i, new ButtonTabComponent(pane));
        pane.setBackgroundAt(i, Color.getHSBColor((float)i/tabNumber, 1, 1));
    }
      

  5.   

    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTabbedPane;public class TabColors extends JPanel {    private static final int MAX = 5;
        private final JTabbedPane pane = new JTabbedPane();    public TabColors() {
            for (int i = 0; i < MAX; i++) {
                Color color = Color.getHSBColor((float) i / MAX, 1, 1);
                pane.add("Tab " + String.valueOf(i), new TabContent(i, color));
                pane.setBackgroundAt(i, color);
            }
            this.add(pane);
        }    private static class TabContent extends JPanel {        private TabContent(int i, Color color) {
                setOpaque(true);
                setBackground(color);
                add(new JLabel("Tab content " + String.valueOf(i)));
            }        @Override
            public Dimension getPreferredSize() {
                return new Dimension(320, 240);
            }
        }    private void display() {
            JFrame f = new JFrame("TabColors");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(this);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }    public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {            @Override
                public void run() {
                    new TabColors().display();
                }
            });
        }
    }