コード例 #1
0
  public static void main(String[] args) {
    TestTtsp ttsp = new TestTtsp();

    JFrame jframe = new JFrame("TTSP - Time Precision Error");
    ttsp.setPrecisionErrorChart(new PrecisionErrorChart());
    jframe.getContentPane().add(ttsp.getPrecisionErrorChart(), "Center");
    jframe.setBounds(200, 120, 600, 280);
    jframe.setVisible(true);
    jframe.addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent windowevent) {
            System.exit(0);
          }
        });

    JFrame jframe2 = new JFrame("TTSP - Synchronization Period");
    ttsp.setSyncPeriodChart(new SyncPeriodChart());
    jframe2.getContentPane().add(ttsp.getSyncPeriodChart(), "Center");
    jframe2.setBounds(200, 120, 600, 280);
    jframe2.setVisible(true);
    jframe2.addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent windowevent) {
            System.exit(0);
          }
        });

    try {
      Thread.sleep(10000);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }
  }
コード例 #2
0
  /* Build up the GUI using Swing magic. Nothing very exciting here - the
  BagPanel class makes the code a bit cleaner/easier to read. */
  private void guiInit() throws Exception {
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setMinimumSize(new Dimension(500, 250));
    mainPanel.setPreferredSize(new Dimension(500, 300));

    /* The message area */
    JScrollPane mssgPanel = new JScrollPane();
    mssgPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    mssgPanel.setAutoscrolls(true);
    mssgArea = new JTextArea();
    mssgArea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 20));
    mainPanel.add(mssgPanel, BorderLayout.CENTER);
    mssgPanel.getViewport().add(mssgArea, null);

    /* The button area */
    BagPanel buttonPanel = new BagPanel();
    GridBagConstraints c = buttonPanel.c;

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;

    buttonPanel.makeLabel("Detection", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    detDarkCb = buttonPanel.makeCheckBox("Dark", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    detAccelCb = buttonPanel.makeCheckBox("Movement", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Theft Reports", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repLedCb = buttonPanel.makeCheckBox("LED", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repSirenCb = buttonPanel.makeCheckBox("Siren", false);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repServerCb = buttonPanel.makeCheckBox("Server", false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repNeighboursCb = buttonPanel.makeCheckBox("Neighbours", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Interval", JLabel.CENTER);
    fieldInterval = buttonPanel.makeTextField(10, null);
    fieldInterval.setText(Integer.toString(Constants.DEFAULT_CHECK_INTERVAL));

    ActionListener settingsAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateSettings();
          }
        };
    buttonPanel.makeButton("Update", settingsAction);

    mainPanel.add(buttonPanel, BorderLayout.EAST);

    /* The frame part */
    frame = new JFrame("AntiTheft");
    frame.setSize(mainPanel.getPreferredSize());
    frame.getContentPane().add(mainPanel);
    frame.setVisible(true);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }