我需要做一个小程序在Java 6中,640个* 480像素,与一些按钮,滚动条和标签底部的工具栏。 我能想到的是使用的最佳方法BorderLayout
,使得BorderLayout.SOUTH
区域GridBagLayout
(它将包含的控件),而其余BorderLayout
区域空,作为地方grapics与控制来绘制。 我找不到不使用任何摆动资源网上,我不知道什么摆动来推断他们正在做什么或如何把它翻译成AWT代码。 这是现在的我。 该代码突然结束在init()
因为这是在布局经理开始。 感谢您对你有任何帮助。 让我知道你是否需要那么多的信息是什么在这里。
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Bounce extends Applet implements ActionListener, AdjustmentListener
{
private static final long serialVersionUID = 1L;
private Graphics page;
//buttons
String shapeButtonText = "Square";
Button shape = new Button(shapeButtonText);
Button quit = new Button("Quit");
Button run = new Button("Run");
Button tail = new Button("Tail");
Button clear = new Button("Clear");
//labels
Label speedLabel = new Label("Speed", Label.CENTER);
Label sizeLabel = new Label("Size", Label.CENTER);
//scrollbars
private final int barHeight = 20;
private final int SLIDER_WIDTH = 10;
private final int MAXSPEED = 110;
private final int MINSPEED = 0;
private final int UNIT_INC = 1;
private final int BLOC_INC = 10;
private final int MAX_SIZE = 110;
private final int MIN_SIZE = 10;
Scrollbar speedBar = new Scrollbar(Scrollbar.HORIZONTAL, MINSPEED, SLIDER_WIDTH, 0, MAXSPEED);
Scrollbar sizeBar = new Scrollbar(Scrollbar.HORIZONTAL, MIN_SIZE, SLIDER_WIDTH, 0, MAX_SIZE);
//methods
public void init()
{
//set up objects
//speed scroll bar
speedBar.setUnitIncrement(UNIT_INC);
speedBar.setBlockIncrement(BLOC_INC);
speedBar.setValue(MAXSPEED/2);
//size scrollbar
sizeBar.setUnitIncrement(UNIT_INC);
sizeBar.setBlockIncrement(BLOC_INC);
sizeBar.setValue(MAX_SIZE/2);
//draw the window
BorderLayout window = new BorderLayout();
GridBagLayout toolbar = new GridBagLayout();
//?
}
public void start()
{
}
public void run()
{
}
public void actionPerformed(ActionEvent e)
{
}
public void adjustmentValueChanged(AdjustmentEvent e)
{
}
public void stop()
{
}
public void destory()
{
}
}