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.
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.
解决方案 »
- 一个自己写的2进制,8进制,16进制和10进制互相转换的代码(没有输入检查)
- 请教各位大哥,帮我参考下形势,走还是留?
- JAVA关于行和列名都固定的表格?
- 大虾指教,如何改变JTable的列宽?
- 请教前辈一IO问题!!!!!!!
- 求教httpclient登录武林三国的问题!!
- 如何设置JVM内存?????在线等待,立即结帐!!!!
- 一个有趣的问题,可以帮助你理解String,大家来讨论啊
- msword文件读写问题
- 请教:在TextArea输入框里,如何按CTRL + Enter触发一个按钮的事件?
- java.net.URL/java.io.InputStream的怪问题(新手)
- 如何使一个线程停了再多次用
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就可以办到。
setFont
setBounds
jbuilder生成.exe
不过还想问各位一句,我怎么样可以设置窗口背景的颜色阿?
我用BorderFactory对JPANEL设置了颜色,方法和 mq612(理想) 提供的设置按钮的一样。不过没有什么变化,希望能给点职教。
谢谢!
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();
}
}