矢量画图

package vectordraw; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.JPanel; /** * * @author tangxiaolong */ public class VectorFrame extends javax.swing.JFrame { //选择模式,0代表直线绘制,1代表椭圆绘制,2代表矩形绘制 public static int mode = 0; /** Creates new form VectorFrame */ public VectorFrame() { // this.setLayout(new BorderLayout()); initComponents(); // this.add(new VectorFrame.DrawPanel(), WIDTH); Toolkit tk = getToolkit(); Dimension screenSize = tk.getScreenSize(); int screenWidth = screenSize.width; int screenHeight = screenSize.height; this.setBounds(screenWidth / 4, screenHeight / 4, screenWidth / 2, screenHeight / 2); JPanel jp = new DrawPanel(); jp.addMouseListener(new MouseAdapter() { }); add(jp); }

你可能感兴趣的:(java,swing)