java为按钮添加的鼠标监听
importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener...
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
class myjdialog extends JDialog
{
public myjdialog(myframe frame)
{
super(frame,"dasd",true);
Container container=getContentPane();
container.add(new JLabel("das"));
setBounds(120, 120, 100, 100);
}
}
public class myframe extends JFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
new myframe();
}
public myframe(){
Container container=getContentPane();
container.setLayout(null);
JLabel jl=new JLabel("das");
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
JButton jb=new JButton();
jb.setBounds(10, 10, 100, 21);
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new myjdialog(myframe.this).setVisible(true);
// TODO Auto-generated method stub
}
});
container.add(jb);
}
/**
* @param args
*/
}
帮我找找问题好不好! 展开
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
class myjdialog extends JDialog
{
public myjdialog(myframe frame)
{
super(frame,"dasd",true);
Container container=getContentPane();
container.add(new JLabel("das"));
setBounds(120, 120, 100, 100);
}
}
public class myframe extends JFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
new myframe();
}
public myframe(){
Container container=getContentPane();
container.setLayout(null);
JLabel jl=new JLabel("das");
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
JButton jb=new JButton();
jb.setBounds(10, 10, 100, 21);
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new myjdialog(myframe.this).setVisible(true);
// TODO Auto-generated method stub
}
});
container.add(jb);
}
/**
* @param args
*/
}
帮我找找问题好不好! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询