大家帮忙看下,下面这个简单程序,问题是show()用不了怎么办.
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
class ShowJButton extends JFrame{
JButton jbutton1=new JButton("上一笔");//文字按钮
ImageIcon imageIcon1=new ImageIcon("f:\\code\\image\\ace.jpg");
JButton jbutton2=new JButton("下一笔",imageIcon1);//文字图形按钮
ImageIcon imageIcon2=new ImageIcon("f:\\code\\image\\ace.jpg");
JButton jbutton3=new JButton(imageIcon2); //图形按钮
FlowLayout flowLayout1=new FlowLayout();
ShowJButton(){
setTitle("按钮演示窗口");
setSize(200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jbutton3.setToolTipText("退出程序"); //设置按钮3的提示文字
this.getContentPane().setLayout(flowLayout1);
this.getContentPane().add(jbutton1);
this.getContentPane().add(jbutton2);
this.getContentPane().add(jbutton3);
show();
}
public static void main(String[] args){
ShowJButton sjb=new ShowJButton();
}}
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
class ShowJButton extends JFrame{
JButton jbutton1=new JButton("上一笔");//文字按钮
ImageIcon imageIcon1=new ImageIcon("f:\\code\\image\\ace.jpg");
JButton jbutton2=new JButton("下一笔",imageIcon1);//文字图形按钮
ImageIcon imageIcon2=new ImageIcon("f:\\code\\image\\ace.jpg");
JButton jbutton3=new JButton(imageIcon2); //图形按钮
FlowLayout flowLayout1=new FlowLayout();
ShowJButton(){
setTitle("按钮演示窗口");
setSize(200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jbutton3.setToolTipText("退出程序"); //设置按钮3的提示文字
this.getContentPane().setLayout(flowLayout1);
this.getContentPane().add(jbutton1);
this.getContentPane().add(jbutton2);
this.getContentPane().add(jbutton3);
show();
}
public static void main(String[] args){
ShowJButton sjb=new ShowJButton();
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货