要做的题目要求在下面的word中:(不知道为什么我剪的图片传不上来,只好用word画了一个!)
下面是我写的代码,但是就是做不到他的要求...求教!!!
package myswing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ZouYei {
JButton jb = null;
public ZouYei() {
JFrame jf = new JFrame("作业练习");
Container cp = jf.getContentPane();
Box baseBox = Box.createHorizontalBox();
cp.add(baseBox);
Box vBox = Box.createVerticalBox();
baseBox.add(vBox);
jb = new JButton("Applet");
jb.setAlignmentX(Component.CENTER_ALIGNMENT);
jb.setMaximumSize(new Dimension(400, 50));
vBox.add(jb);
Box hBox = Box.createHorizontalBox();
vBox.add(hBox);
Box vBox1 = Box.createVerticalBox();
hBox.add(vBox1);
jb = new JButton("1");
jb.setMaximumSize(new Dimension(200, 150));
vBox1.add(jb);
Box vBox2 = Box.createVerticalBox();
vBox1.add(vBox2);
jb = new JButton("2");
jb.setMaximumSize(new Dimension(150, 100));
vBox2.add(Box.createHorizontalStrut(25));
vBox2.add(jb);
jb = new JButton("3");
jb.setMaximumSize(new Dimension(200, 250));
hBox.add(jb);
jf.pack();
jf.setVisible(true);
jf.addWindowListener(new WindowAdapter() {
public void WindowClosing(WindowEvent e) {
System.exit(0);
}
});
}
/**
* @param args
*/
public static void main(String[] args) {
new ZouYei();
// TODO Auto-generated method stub
}
}