JAVA 为什么我运行的结果是一个什么都没有的窗口?
我的程序,这是一个复选框的程序packagecom.lzw;importjava.awt.*;importjava.awt.event.ActionEvent;impor...
我的程序,这是一个复选框的程序
package com.lzw;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
public class SS extends JFrame{
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JTextArea k = new JTextArea(3,10);
JCheckBox s1 = new JCheckBox("1");
JCheckBox s2 = new JCheckBox("2");
JCheckBox s3 = new JCheckBox("3");
public SS () {
Container s = new Container();
setTitle("王尼玛");
setVisible(true);
setSize(400,400);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
s.setLayout(new BorderLayout());
final JScrollPane jt = new JScrollPane(k);
jp1.add(jt);
s.add(jp1,BorderLayout.NORTH);
jp2.add(s1);
s1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(s1.isSelected())
k.append("王尼玛");
}
});
jp2.add(s2);
s2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(s2.isSelected())
k.append("你妹哟");
}
});
jp2.add(s3);
s3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(s3.isSelected())
k.append("你妹");
}
});
s.add(jp2,BorderLayout.SOUTH);
}
public static void main(String[] args) {
new SS();
}
}
程序运行结果 展开
package com.lzw;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
public class SS extends JFrame{
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JTextArea k = new JTextArea(3,10);
JCheckBox s1 = new JCheckBox("1");
JCheckBox s2 = new JCheckBox("2");
JCheckBox s3 = new JCheckBox("3");
public SS () {
Container s = new Container();
setTitle("王尼玛");
setVisible(true);
setSize(400,400);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
s.setLayout(new BorderLayout());
final JScrollPane jt = new JScrollPane(k);
jp1.add(jt);
s.add(jp1,BorderLayout.NORTH);
jp2.add(s1);
s1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(s1.isSelected())
k.append("王尼玛");
}
});
jp2.add(s2);
s2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(s2.isSelected())
k.append("你妹哟");
}
});
jp2.add(s3);
s3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(s3.isSelected())
k.append("你妹");
}
});
s.add(jp2,BorderLayout.SOUTH);
}
public static void main(String[] args) {
new SS();
}
}
程序运行结果 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |