当前位置: 技术问答>java相关
简单问题,正确有分!!!!
来源: 互联网 发布时间:2015-02-14
本文导语: 我想做一个多项选择的applet: import java.awt.*; import javax.swing.JApplet; public class downdraw extends JApplet { public void init() { Checkbox JonBox=new Checkbox("Jon"); Checkbox IanBox=new Checkbox("Ian"); Checkbox NateBox=new Checkbox("Nate"); ...
我想做一个多项选择的applet:
import java.awt.*;
import javax.swing.JApplet;
public class downdraw extends JApplet
{
public void init()
{
Checkbox JonBox=new Checkbox("Jon");
Checkbox IanBox=new Checkbox("Ian");
Checkbox NateBox=new Checkbox("Nate");
Checkbox MichaelBox=new Checkbox("Michael");
getContentPane().add(JonBox);
getContentPane().add(IanBox);
getContentPane().add(NateBox);
getContentPane().add(MichaelBox);
}
}
但是为何只出现第四项?请纠正!
import java.awt.*;
import javax.swing.JApplet;
public class downdraw extends JApplet
{
public void init()
{
Checkbox JonBox=new Checkbox("Jon");
Checkbox IanBox=new Checkbox("Ian");
Checkbox NateBox=new Checkbox("Nate");
Checkbox MichaelBox=new Checkbox("Michael");
getContentPane().add(JonBox);
getContentPane().add(IanBox);
getContentPane().add(NateBox);
getContentPane().add(MichaelBox);
}
}
但是为何只出现第四项?请纠正!
|
import java.awt.*;
import javax.swing.JApplet;
public class downdraw extends JApplet
{
public void init()
{
Checkbox JonBox=new Checkbox("Jon");
Checkbox IanBox=new Checkbox("Ian");
Checkbox NateBox=new Checkbox("Nate");
Checkbox MichaelBox=new Checkbox("Michael");
getContentPane().setLayout(new FlowLayout());
getContentPane().add(JonBox);
getContentPane().add(IanBox);
getContentPane().add(NateBox);
getContentPane().add(MichaelBox);
}
}
import javax.swing.JApplet;
public class downdraw extends JApplet
{
public void init()
{
Checkbox JonBox=new Checkbox("Jon");
Checkbox IanBox=new Checkbox("Ian");
Checkbox NateBox=new Checkbox("Nate");
Checkbox MichaelBox=new Checkbox("Michael");
getContentPane().setLayout(new FlowLayout());
getContentPane().add(JonBox);
getContentPane().add(IanBox);
getContentPane().add(NateBox);
getContentPane().add(MichaelBox);
}
}
|
public void init()
{
getContentPane().setLayout(new FlowLayout());
Checkbox JonBox=new Checkbox("Jon");
Checkbox IanBox=new Checkbox("Ian");
Checkbox NateBox=new Checkbox("Nate");
Checkbox MichaelBox=new Checkbox("Michael");
getContentPane().add(JonBox);
getContentPane().add(IanBox);
getContentPane().add(NateBox);
getContentPane().add(MichaelBox);
}
{
getContentPane().setLayout(new FlowLayout());
Checkbox JonBox=new Checkbox("Jon");
Checkbox IanBox=new Checkbox("Ian");
Checkbox NateBox=new Checkbox("Nate");
Checkbox MichaelBox=new Checkbox("Michael");
getContentPane().add(JonBox);
getContentPane().add(IanBox);
getContentPane().add(NateBox);
getContentPane().add(MichaelBox);
}
|
getContentPane().add(JonBox,BorderLayout.NORTH);
getContentPane().add(IanBox,BorderLayout.EAST);
getContentPane().add(NateBox,BorderLayout.WEST);
getContentPane().add(MichaelBox,BorderLayout.SOUTH);
getContentPane().add(IanBox,BorderLayout.EAST);
getContentPane().add(NateBox,BorderLayout.WEST);
getContentPane().add(MichaelBox,BorderLayout.SOUTH);