import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Choice extends JFrame implements ItemListener
{
JLabel lb1,lb2;
JCheckBox cb1,cb2;
JTextArea ta;
JPanel pN,pC,pS;
boolean net,j2ee;
public Choice()
{
lb1=new JLabel("Ñ¡Ôñ£º");
lb2=new JLabel("лл²ÎÓ룡");
cb1=new JCheckBox(".NET",false);
cb1.addItemListener(this);
cb2=new JCheckBox("J2EE",false);
cb2.addItemListener(this);
ta=new JTextArea(50,40);
pN=new JPanel();
pC=new JPanel();
pS=new JPanel();
net=false;
j2ee=false;
pN.add(lb1);pN.add(cb1);pN.add(cb2);
pC.setLayout(new BorderLayout());
pC.add(ta,BorderLayout.CENTER);
pS.add(lb2);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(pN,BorderLayout.NORTH);
this.getContentPane().add(pS,BorderLayout.SOUTH);
this.getContentPane().add(pC,BorderLayout.CENTER);
this.setTitle("¿Î³ÌÑ¡Ôñ£¡");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(240,240,400,200);
this.setVisible(true);
}
private void showResult(boolean blnNet,boolean blnJ2ee)
{
if(blnNet==true & blnJ2ee==true)
{
ta.setText("ÄãÑ¡ÔñµÄÊÇ.NetºÍJ2ee¿Î³Ì!");
}
else if(blnNet==true & blnJ2ee==false)
{
ta.setText("ÄãÑ¡ÔñµÄÊÇ.Net¿Î³Ì!");
}
else if(blnNet==false & blnJ2ee==true)
{
ta.setText("ÄãÑ¡ÔñµÄÊÇJ2ee¿Î³Ì£¡");
}
else if(blnNet==false & blnJ2ee==false)
{
ta.setText("");
}
}
public void itemStateChanged(ItemEvent i)
{
if(cb1.isSelected()==true & cb2.isSelected()==true)
{
net=true;
j2ee=true;
showResult(net,j2ee);
}
else if(cb1.isSelected()==true & cb2.isSelected()==false)
{
net=true;
j2ee=false;
showResult(net,j2ee);
}
else if(cb1.isSelected()==false & cb2.isSelected()==true)
{
net=false;
j2ee=true;
showResult(net,j2ee);
}
else if(cb1.isSelected()==false & cb2.isSelected()==false)
{
net=false;
j2ee=false;
showResult(net,j2ee);
}
}
public static void main(String[] args)
{
new Choice();
}
}
中间的文本域始终是充满中间的,怎么设置能让它不要充满!就是左右上下都空出一点空间来!?
我怎么设置都没用....