/* * main.java * * Created on 08.02.2011, 20:06:19 */ package js.java.plugins.monitorWand; import java.awt.BorderLayout; import java.io.IOException; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; /** * * @author js */ public class main extends javax.swing.JFrame { private wand w; private connection c; private JSlider sl; /** Creates new form main */ public main() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { ex.printStackTrace(); } initComponents(); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); JLabel l = new JLabel("Aktualisierung nur alle 30 Sekunden!"); l.setHorizontalTextPosition(SwingConstants.RIGHT); p.add(l, BorderLayout.EAST); sl = new JSlider(SwingConstants.HORIZONTAL, 0, 50, 0); sl.setFocusable(false); sl.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { w.setScale(sl.getValue()); } }); p.add(sl, BorderLayout.CENTER); menuBar.add(p); c = new connection(bstMenu); try { c.connect("localhost"); } catch (IOException ex) { System.out.println("Verbindungsfehler"); JOptionPane.showMessageDialog(this, "Keine Verbindung zur Sim möglich.", "Verbindungsfehler", JOptionPane.ERROR_MESSAGE); System.exit(100); } w = new wand(c); this.add(w, BorderLayout.CENTER); } /** 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. */ @SuppressWarnings( "unchecked" ) // private void initComponents() { menuBar = new javax.swing.JMenuBar(); bstMenu = new javax.swing.JMenu(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setLocationByPlatform(true); setMinimumSize(new java.awt.Dimension(400, 300)); bstMenu.setText("Bahnsteige"); menuBar.add(bstMenu); setJMenuBar(menuBar); pack(); }// /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new main().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JMenu bstMenu; private javax.swing.JMenuBar menuBar; // End of variables declaration }