天天看点

panel在java中什么意思_java中的panel 问题

importjava.awt.*;importjava.awt.event.*;publicclassGraphicsDDAextendsFrameimplementsItemListener,ActionListener{privateintX;privateintY;privateLabellabel1;privateTextFiel...

import java.awt.*;

import java.awt.event.*;

public class GraphicsDDA extends Frame implements ItemListener ,ActionListener{

private int X;

private int Y;

private Label label1;

private TextField startX;

private Label label2;

private TextField startY;

private Label label3;

private TextField endX;

private Label label4;

private TextField endY;

private Choice colorChoice;

private Button start;

private Panel panel;

public GraphicsDDA()

{

super("DDA");

label1=new Label("起点X");

startX=new TextField(5);

label2=new Label("起点Y");

startY=new TextField(5);

label3=new Label("终点X");

endX=new TextField(5);

label4=new Label("终点Y");

endY=new TextField(5);

colorChoice=new Choice();

colorChoice.add("BLACK");

colorChoice.add("BLUE");

colorChoice.add("GREEN");

colorChoice.add("CYAN");

colorChoice.add("RED");

colorChoice.add("MAGENTA");

colorChoice.add("LIGHTGRAY");

colorChoice.add("DARKGRAY");

start=new Button("开始");

panel=new Panel();

this.add(label1);

this.add(startX);

this.add(label2);

this.add(startY);

this.add(label3);

this.add(endX);

this.add(label4);

this.add(endY);

this.add(colorChoice);

this.add(start);

this.add("Center",panel);

panel.setSize(100,100);

panel.setLocation(100,100);

panel.setBackground(Color.white);

// this.setLayout(new BorderLayout());

this.setSize(800,600);

this.setBackground(Color.lightGray);

this.setVisible(true);

this.addWindowListener( new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{

System.exit(0);

}

}

);

}

public void itemStateChanged(ItemEvent e)

{

}

public void actionPerformed(ActionEvent e)

{

}

public static void main(String [] args)

{

GraphicsDDA myDDA=new GraphicsDDA();

}

}

panel 与 其他控件的 叠放次序老 是弄不好,不是太大就是太小

高郁闷了

展开