运行成功后
为什么要用鼠标托运一下
才可以显示出效果
不知道为什么会这样
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Sewin extends JFrame implements ActionListener
{
JButton b1,b2,b3;
JLabel label;Container con;int w,h,x,y,width,height;
Sewin()
{super("我的地盘听我的");
setVisible(true);
setBounds(0,0,1024,768);
con=getContentPane();
con.setLayout(null);
b1=new JButton("我的地盘听我的");b2=new JButton("我的同学录");b3=new JButton("休闲娱乐");
Icon icon=new ImageIcon("e:\\zgl\\picture\\qingz.jpg");
label=new JLabel("",icon,JLabel.CENTER);
w=getSize().width;h=getSize().height;
x=w/4;y=h/4;
con.add(b1);con.add(b2);con.add(b3);con.add(label);
label.setBounds(0,0,w,h);
b1.setBounds(x,y,x,y);b2.setBounds(x/2,2*y,x,y);b3.setBounds(x,3*y,x,y);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
addWindowListener(new WindowAdapter ()
{public void windowClosing(WindowEvent e)
{System.exit(0);setVisible(false);
}
});
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==b1)
{this.setVisible(false);System.exit(0);//Sewin_1.setVisible(true);
}
else if(e.getSource()==b2)
{this.setVisible(false);//Sewin_2.setVisible(true);
}
else if(e.getSource()==b3)
{this.setVisible(false);//Sewin_3.setVisible(true);
}
}
}
public class Secondwin
{public static void main(String args[])
{Sewin sewin=new Sewin();
}
}
而且是图片为什么会这么小;
为什么要用鼠标托运一下
才可以显示出效果
不知道为什么会这样
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Sewin extends JFrame implements ActionListener
{
JButton b1,b2,b3;
JLabel label;Container con;int w,h,x,y,width,height;
Sewin()
{super("我的地盘听我的");
setVisible(true);
setBounds(0,0,1024,768);
con=getContentPane();
con.setLayout(null);
b1=new JButton("我的地盘听我的");b2=new JButton("我的同学录");b3=new JButton("休闲娱乐");
Icon icon=new ImageIcon("e:\\zgl\\picture\\qingz.jpg");
label=new JLabel("",icon,JLabel.CENTER);
w=getSize().width;h=getSize().height;
x=w/4;y=h/4;
con.add(b1);con.add(b2);con.add(b3);con.add(label);
label.setBounds(0,0,w,h);
b1.setBounds(x,y,x,y);b2.setBounds(x/2,2*y,x,y);b3.setBounds(x,3*y,x,y);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
addWindowListener(new WindowAdapter ()
{public void windowClosing(WindowEvent e)
{System.exit(0);setVisible(false);
}
});
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==b1)
{this.setVisible(false);System.exit(0);//Sewin_1.setVisible(true);
}
else if(e.getSource()==b2)
{this.setVisible(false);//Sewin_2.setVisible(true);
}
else if(e.getSource()==b3)
{this.setVisible(false);//Sewin_3.setVisible(true);
}
}
}
public class Secondwin
{public static void main(String args[])
{Sewin sewin=new Sewin();
}
}
而且是图片为什么会这么小;
解决方案 »
- java输出4位网站验证码, 在线等
- 在哪一层处理异常最好呢?
- 请问这个这个程序建一个文件,并向文件中写入数据有问题吗?
- 前辈赐教,想转行,但入手难
- 关于JLabel使用settext的时候显示刷新的问题
- 简单程序的疑问
- 简单问题:在javascript或者html中如何调用sessionbean的某个方法?
- 我不想用盗版又买不起正版怎么办?请推荐一个好的免费工具
- 线程问题
- PrintWriter(OutputStream out, boolean autoFlush) 中的out参数为什么可以传入FileWriter对象
- 用java实现ip网关登陆--求助--解决后撒100分!
- 请问设计完报表(iReport)用jsp怎么引用这个报表?
So move the statement setVisible(true); to the end of the sewin constructor.