graphicspanel.java

来自「利用JAVA实现的利用进化算法对人口增长进行仿真的源码」· Java 代码 · 共 63 行

JAVA
63
字号
/*
 * graphicsPanel.java
 *
 * Created on 12 October 2006, 07:44
 */

package wpc;
import java.awt.Graphics;
/**
 *
 * @author  User
 */
public class GraphicsPanel extends javax.swing.JPanel {
    wpc.data.World world;
    MainFrame mainFrame;
    boolean changed;
    /** Creates new form graphicsPanel */
    public GraphicsPanel(MainFrame mainFrame) {
        this.mainFrame = mainFrame;
        this.world = mainFrame.getWorld();
        initComponents();
        changed = true;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    
      
    public void paintComponent(Graphics g){
       //super.paintComponent(g);
       if(mainFrame.getCreated()){      
          if(mainFrame.getStarted()){
              world.draw(g);               
          }
       }
    }
    
    public void update(){
        repaint();
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?