[問題] paintpanel 一直無法出現

看板java作者 (小波)時間11年前 (2013/05/14 23:23), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
先說一下我是想要寫一個視覺動態的演算法 然後需要一個paintpanel 來印點,但是paintpanel卻一直沒辦法顯示 我在上方加上其他panel就可以,就只有paintpanel 無法QQ 我是拿以前寫過的拿來改一下就不行了 --------------以下程式碼------------ public class ALGHW extends JFrame{ private JPanel buttonpanel ,jPanel ; //JPanel private JButton buttonsort; private paintPanel paintpanel; public ALGHW(){ super("FastQuick Sort"); jPanel = new JPanel(); jPanel.setBackground(Color.BLACK); add(jPanel,BorderLayout.NORTH); buttonpanel = new JPanel(); add(buttonpanel,BorderLayout.SOUTH); paintpanel = new paintPanel(); add(paintpanel,BorderLayout.CENTER); paintpanel.setBackground(Color.WHITE); buttonsort = new JButton("FastQuick Sort"); buttonpanel.add(buttonsort); }; public class paintPanel extends JPanel{ private static final long serialVersionUID = 1L; private Point points[] = new Point[100000]; private int pointCount = 0; public paintPanel(){ BufferedImage image = new BufferedImage(500,500,BufferedImage.TYPE_INT_ARGB_PRE); } public void paintComponent(Graphics g){ super.paintComponents(g); for(int i = 0 ; i < array.length ; i++){ g.fillOval(i, array[i], 1, 1);//g.fillOval(x, y, width, height) } } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.232.15
文章代碼(AID): #1HabRfIS (java)