import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.*; /** * Description of the Class * *@author Jaroslav Skrabalek *@created 5. duben 2006 */ public class Applet extends JApplet implements ActionListener { private JPanel cent; private JLabel lab; private JComboBox cb; private JButton butRun; /** * Description of the Method * * @param a Description of the Parameter */ public void actionPerformed(ActionEvent a) { if (a.getSource() == butRun) lab.setText("You touched the button, the combobox " + "says '" + cb.getSelectedItem() + "'"); } public String[] loadData() { String[] data = { "a", "b", "c" }; /* call sth. from io class here */ return data; } public void init() { JPanel top = new JPanel(); cent = new JPanel(); JPanel bot = new JPanel(); JLabel nadpis = new JLabel("Chaotické atraktory",JLabel.CENTER); cb = new JComboBox(loadData()); butRun = new JButton("RUN"); top.setLayout(new BorderLayout()); top.add(nadpis, BorderLayout.NORTH); top.add(cb, BorderLayout.CENTER); top.add(butRun, BorderLayout.EAST); cent.setBorder(BorderFactory.createLineBorder( new Color(0, 0, 0))); JLabel flab = new JLabel("F:"); bot.add(flab); bot.add(Box.createRigidArea(new Dimension(10, 0))); flab = new JLabel("L:"); bot.add(flab); JPanel all = new JPanel(); all.setBorder(BorderFactory.createRaisedBevelBorder()); all.setLayout(new BorderLayout()); all.add(top, BorderLayout.NORTH); all.add(cent, BorderLayout.CENTER); all.add(bot, BorderLayout.SOUTH); getContentPane().add(all); butRun.addActionListener(this); //sem dat neco na processing. pokud jiz neco neni v algs.java } /** * Description of the Method * * @param g Description of the Parameter */ public void paint(Graphics g) { getContentPane().print(g); /* Draw controls */ Graphics cg = cent.getGraphics(); cg.setColor(new Color(0, 0, 0)); cg.drawRect(20, 40, 10, 10); cg.fillRect(25, 45, 1, 1); } }