public static void main(String[] args) { frame.setLayout(new FlowLayout()); final JPanel sceneHolder = new JPanel(); initialize(sceneHolder); frame.add(sceneHolder); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(700, 700); frame.setVisible(true); }
public LJ3MDApp() { tNum.setHorizontalAlignment(JTextField.CENTER); tTemp.setHorizontalAlignment(JTextField.CENTER); tRho.setHorizontalAlignment(JTextField.CENTER); tSpeed.setHorizontalAlignment(JTextField.CENTER); tAvK.setHorizontalAlignment(JTextField.RIGHT); tAvU.setHorizontalAlignment(JTextField.RIGHT); tAvp.setHorizontalAlignment(JTextField.RIGHT); float[] aveKing = new float[501]; float[] avePot = new float[501]; float[] aveEn = new float[501]; JFrame box = new JFrame(); box.setLayout(new BorderLayout()); box.setSize(1000, 1000); box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cpnl = new JPanel(); // create a panel for controls cpnl.setLayout(new GridLayout(18, 2)); box.add(cpnl, BorderLayout.EAST); // add controls cpnl.add(bStart); bStart.addActionListener(this); cpnl.add(bReset); bReset.addActionListener(this); cpnl.add(new JLabel(" N:")); tNum.addActionListener(this); cpnl.add(tNum); cpnl.add(new JLabel(" Density (\u03c1):")); tRho.addActionListener(this); cpnl.add(tRho); cpnl.add(new JLabel(" Steps/frame:")); tSpeed.addActionListener(this); cpnl.add(tSpeed); cpnl.add(bTstat); bTstat.addActionListener(this); cpnl.add(bPot); bPot.addActionListener(this); cpnl.add(new JLabel(" < K/N > :")); tAvK.setEditable(false); cpnl.add(tAvK); cpnl.add(new JLabel(" Temperature:")); tTemp.setEditable(false); cpnl.add(tTemp); cpnl.add(new JLabel(" < U/N > :")); tAvU.setEditable(false); cpnl.add(tAvU); cpnl.add(new JLabel(" < pressure > :")); tAvp.setEditable(false); cpnl.add(tAvp); cpnl.add(bRetime); bRetime.addActionListener(this); spnl = new JPanel(); // create a panel for status box.add(spnl, BorderLayout.SOUTH); lStatus.setFont(new Font("Courier", 0, 12)); spnl.add(lStatus); canvas = new XYZCanvas(); box.add(canvas, BorderLayout.CENTER); timer = new Timer(delay, this); timer.start(); // timer.stop(); box.setVisible(true); }