package edu.aic.swing.mycomponent;
import java.awt.*;
import javax.swing.*;
public class DragPanelTest extends JFrame {
private static final long serialVersionUID = 1L;
private DragPanel myPanel;
public DragPanelTest() {
// set up a SelfContainedPanel
myPanel = new DragPanel();
myPanel.setBackground(Color.WHITE);
myPanel.setPreferredSize(new Dimension(400, 300));
Container container = getContentPane();
container.setLayout(new FlowLayout());
container.add(myPanel);
setSize(500, 350);
setVisible(true);
}
public static void main(String args[]) {
DragPanelTest application = new DragPanelTest();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
上面这个程序是画圆的,要花长方形应该怎么改,最好还能实现画多个长方形...请高手指教。 |