大小 setSize()
位置 setLocation()
颜色 setBackground()和setForeground()

解决方案 »

  1.   

    import javax.swing.UIManager;
    try{
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }catch(Exception e){
    System.exit(1);
    }这样你的按钮就会凸起来
      

  2.   

    to Philip1314;
    这段代码要放在哪里?
      

  3.   

    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.metal.*;public class TestNetPaint
    {
    public static int count=100;
    public static void main(String[] args)throws Exception
    {
    JFrame myframe=new MyFrame();
    myframe.show();
    }
    }
    class MyFrame extends JFrame
    {
    public MyFrame()
    {
    addWindowListener
    (
    new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    }
    );
    setSize(600,400);

    Container contentPane=getContentPane();
    MyPanel testPanel=new MyPanel();
    JButton myButton=new JButton("test");
    myButton.setFocusPainted(false);//取消聚焦框

    myButton.setForeground(Color.pink);
    myButton.setBackground(Color.blue);

    testPanel.add(myButton);
    contentPane.add(testPanel);

    try{
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    SwingUtilities.updateComponentTreeUI(this);
    }catch(Exception e){
    System.exit(1);
    }
    }
    }
    class MyPanel extends JPanel 
    {  
    TestNetPaint netpaint=new TestNetPaint();
    public MyPanel()
    {
    }
    public void paint(Graphics g)
    {
    super.paint(g);

    System.out.println("MyPanel is running");
    }
    } /*说明:1,在Swing里面我感觉控件的大小,位置无所谓的,只要你布局做的对,原始窗口
    大小合适就好。
    2,myButton.setFocusPainted(false);//取消 按钮上的test外还有个不知所云的框
    3,UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    SwingUtilities.updateComponentTreeUI(this);  这句不能少,否则没用
    4, myButton.setForeground(Color.pink);
    myButton.setBackground(Color.blue); 改变颜色
    */