1.YourButton extends JButton, and overide the paint() method.
2.need some tools. but you can jar it, then write a shell script to achive the target that double clicking the script file to start it.

解决方案 »

  1.   

    1、用setBorder()方法来设置有图片的按钮边框,可用各种边框的效果import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class Test extends JFrame {
      JPanel pane;  public Test() {
        super("ICON Button");
        this.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent windowEvent) {
            System.exit(0);
          }
        });
        ImageIcon image = new ImageIcon("./classes/test/icon.gif");
        JButton button = new JButton();
        button.setIcon(image);
        button.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, new Color(0, 0, 0)));
        pane = new JPanel();
        pane.add(button);
        this.getContentPane().add(pane);
        this.setSize(200, 150);
        this.setVisible(true);
      }
      public static void main(String[] args) {
        new Test();
      }
    }2、不推荐生成exe文件,如果实在想那样的话JBuilder就可以办到。
      

  2.   

    BorderFactory
    setFont
    setBounds
    jbuilder生成.exe
      

  3.   

    呵呵       在这样的编译器下面生成的是  *.jra文件 要是安装这样的文件需要专门的安装软件:例如: installanywhere  这是一款很不错的安装java程序的软件~~
      

  4.   

    哦,谢谢大家:)现在又有挺大进展了。
    不过还想问各位一句,我怎么样可以设置窗口背景的颜色阿?
    我用BorderFactory对JPANEL设置了颜色,方法和  mq612(理想)  提供的设置按钮的一样。不过没有什么变化,希望能给点职教。
    谢谢!
      

  5.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class Test extends JFrame {
      JPanel pane;  public Test() {
        super("ICON Button");
        this.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent windowEvent) {
            System.exit(0);
          }
        });
        ImageIcon image = new ImageIcon("./classes/test/icon.gif");
        JButton button = new JButton();
        button.setIcon(image);
        button.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, new Color(0, 0, 0)));
        pane = new JPanel();
        pane.setBackground(new Color(255, 255, 255)); //JPanel的背景颜色
        pane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(255, 0, 0))); //再给JPanel加上一像素的红色边框
        pane.add(button);
        this.getContentPane().add(pane);
        this.setSize(200, 150);
        this.setVisible(true);
      }
      public static void main(String[] args) {
        new Test();
      }
    }