예제 #1
0
  private void packDevices() {
    int i, j;
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);

    for (i = 0, j = 0; i < cnt; i++) {
      if (devArray[i].isSpecial) continue;

      gbc.weightx = 0.8;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.gridx = 0;
      gbc.gridy = j;
      gbc.ipadx = 5;
      gbc.ipady = 5;
      gbl.setConstraints(devArray[i].widgetset.l1, gbc);
      getContentPane().add(devArray[i].widgetset.l1);

      gbc.weightx = 1.0;
      gbc.gridx = 1;
      gbc.gridy = j;
      gbc.ipadx = 0;
      gbc.ipady = 0;
      gbl.setConstraints(devArray[i].widgetset.wc, gbc);
      getContentPane().add(devArray[i].widgetset.wc);

      gbc.weightx = 0.8;
      gbc.gridx = 2;
      gbc.gridy = j;
      gbc.ipadx = 5;
      gbc.ipady = 5;
      gbl.setConstraints(devArray[i].widgetset.l2, gbc);
      getContentPane().add(devArray[i].widgetset.l2);

      gbc.gridx = 3;
      gbc.gridy = j;
      gbl.setConstraints(devArray[i].widgetset.ln, gbc);
      getContentPane().add(devArray[i].widgetset.ln);

      gbc.gridx = 4;
      gbc.gridy = j;
      gbl.setConstraints(devArray[i].widgetset.lval, gbc);
      getContentPane().add(devArray[i].widgetset.lval);

      j++;
    }

    pack();
  }
예제 #2
0
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }
예제 #3
0
파일: Utilities.java 프로젝트: bily/fsxp
 public static void addComponent(
     Container container,
     Component component,
     int gridx,
     int gridy,
     int gridwidth,
     int gridheight,
     int fill,
     int anchor,
     Insets insets,
     int ipadx,
     int ipady,
     double weightx,
     double weighty) {
   java.awt.LayoutManager lm = container.getLayout();
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbc.gridwidth = gridwidth;
   gbc.gridheight = gridheight;
   gbc.fill = fill;
   gbc.anchor = anchor;
   gbc.insets = insets;
   gbc.ipadx = ipadx;
   gbc.ipady = ipady;
   gbc.weightx = weightx;
   gbc.weighty = weighty;
   ((GridBagLayout) lm).setConstraints(component, gbc);
   container.add(component);
 }
예제 #4
0
  public Plot2Da() {
    check_ = new JCheckBox("Hold on");
    plot_ = new Plot2D();

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 0;
    add(check_, c);

    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.REMAINDER;
    c.ipadx = plot_.getSize().width + 100;
    c.ipady = plot_.getSize().height + 100;
    plot_.setBackground(Color.WHITE);

    add(plot_, c);

    setBorder(BorderFactory.createEtchedBorder());
  }
  // Color gre;
  Rules(String se) {
    email = se;
    conti = new Button("Continue");
    rules = new Button("ClicK Here For Rules");
    p1 = new JOptionPane();
    Icon image = new ImageIcon("books.jpg");
    Icon image1 = new ImageIcon("girl.jpg");
    Icon image2 = new ImageIcon("uit.jpg");
    gl = new GridBagLayout();
    gbc = new GridBagConstraints();
    conti.addActionListener(this);
    rules.addActionListener(this);
    // gre=new Color(117,102,185);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();
    p4 = new Panel();
    f = new Frame();
    pic = new JLabel(image);
    pic1 = new JLabel(image1);
    pic2 = new JLabel(image2);
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gl.setConstraints(pic1, gbc);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gl.setConstraints(pic, gbc);
    Insets is = new Insets(30, 30, 30, 30);
    gbc.insets = is;
    gbc.ipadx = 14;
    gbc.ipady = 8;
    gl.setConstraints(rules, gbc);
    gl.setConstraints(conti, gbc);
    p2.setLayout(gl);
    p4.add(pic2);
    p2.add(pic);
    p3.setLayout(gl);
    p3.add(pic1);
    p.add(conti);
    p.add(rules);
    p.setLayout(gl);
    f.add(p4, "North");
    f.add(p3, "East");
    f.add(p2, "West");

    f.add(p, "Center");
    f.setTitle("RULES BOOK");
    // f.setBackground(gre);
    f.setVisible(true);
    f.setSize(900, 600);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
  }
예제 #6
0
  /*
   * helper class to initialize empty spaces
   * @param int x - column of button
   * @param int y - row of button
   * @param Dimension btnSize - sets the size of the button
   */
  public void createBlankButtons(int x, int y, Dimension btnSize) {
    String output = "";
    Font clueFont = new Font("Arial", Font.PLAIN, 8);

    // initialize next myButton
    btn[activeMyButtons] = new myButton();
    String toolTip = ("" + activeMyButtons);
    btn[activeMyButtons].setDefaultToolTipText(toolTip);
    btn[activeMyButtons].setToolTipText(toolTip);

    // get next available myButton and assign current position
    btn[activeMyButtons].positionX = x;
    btn[activeMyButtons].positionY = y;
    btn[activeMyButtons].button = activeMyButtons;
    btn[activeMyButtons].setPreferredSize(btnSize);
    btn[activeMyButtons].setFont(clueFont);

    // assign GridBagConstraints for //position
    cons.gridx = x;
    cons.gridy = y;
    cons.gridwidth = 1;
    cons.gridheight = 1;
    cons.ipadx = 0;
    cons.ipady = 0;

    // determine position and set alternating color
    if (((x % 2 == 0) && (y % 2 == 0)) || ((x % 2 != 0) && (y % 2 != 0))) {
      btn[activeMyButtons].setBackground(new Color(152, 86, 112));
      btn[activeMyButtons].setDefaultColor(new Color(152, 86, 112));
    } else {

      btn[activeMyButtons].setBackground(new Color(128, 48, 82));
      btn[activeMyButtons].setDefaultColor(new Color(128, 48, 82));
    }

    btn[activeMyButtons].setOpaque(true);
    btn[activeMyButtons].setBorderPainted(false);

    // add button to boardPanel
    this.add(btn[activeMyButtons], cons);
    btn[activeMyButtons].addActionListener(new myActionListener());
    validate();

    // pass output to setOutput()
    output = "activeMyButtons: " + activeMyButtons + " " + btn[activeMyButtons].getDefaultColor();
    // setOutput(output);

    activeMyButtons++;
  }
예제 #7
0
 public ProgressDialog(Frame frame, String s, URL url, String s1) {
   super(s);
   bytesTransferred = -1L;
   properties = HJBProperties.getHJBProperties("hjbrowser");
   java.awt.Color color = properties.getColor("hotjava.background", null);
   if (color != null) setBackground(color);
   GridBagLayout gridbaglayout = new GridBagLayout();
   setLayout(gridbaglayout);
   GridBagConstraints gridbagconstraints = new GridBagConstraints();
   gridbagconstraints.gridx = 0;
   gridbagconstraints.anchor = 17;
   gridbagconstraints.weightx = 1.0D;
   String s2 = properties.getProperty("progressDialog.url.label", "Source:");
   addComponent(gridbaglayout, gridbagconstraints, new Label(s2 + " " + url));
   s2 = properties.getProperty("progressDialog.saveInto.label", "Destination:");
   addComponent(gridbaglayout, gridbagconstraints, new Label(s2 + " " + s1));
   gridbagconstraints.ipady = 2;
   bytesTransferredPrefix =
       properties.getProperty("progressDialog.transfer.label", "Bytes transferred:") + " ";
   bytesTransferredInd = new BytesTransferredInd();
   addComponent(gridbaglayout, gridbagconstraints, bytesTransferredInd);
   bpsInd = new BPSIndicator();
   addComponent(gridbaglayout, gridbagconstraints, bpsInd);
   gridbagconstraints.weighty = 1.0D;
   gridbagconstraints.anchor = 15;
   gridbagconstraints.insets = new Insets(0, 0, 5, 0);
   stopButton = new UIHJButton("progressDialog.stop", true, properties);
   stopButton.addActionListener(this);
   addComponent(gridbaglayout, gridbagconstraints, stopButton);
   pack();
   centerOnScreen(frame);
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   try {
     URL url1 = ClassLoader.getSystemResource("lib/images/hotjava.icon.gif");
     java.awt.Image image = toolkit.getImage(url1);
     setIconImage(image);
     return;
   } catch (Exception _ex) {
     return;
   }
 }
예제 #8
0
  protected void populateDialog(JDialog dlg) {
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setResizable(false);
    dlg.setSize(new Dimension(350, 135));
    dlg.setTitle("New TurboVNC Connection");

    dlg.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (VncViewer.nViewers == 1) {
              if (cc.viewer instanceof VncViewer) {
                ((VncViewer) cc.viewer).exit(1);
              }
            } else {
              ret = false;
              endDialog();
            }
          }
        });

    dlg.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;

    dlg.getContentPane().add(topPanel, gbc);
    dlg.getContentPane().add(buttonPanel);
    dlg.pack();
  }
  public static void addComponentsToPane(Container pane) {
    if (RIGHT_TO_LEFT) {
      pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    }

    String sample =
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
            + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
            + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi"
            + " ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit"
            + " in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur "
            + "sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit "
            + "anim id est laborum.";

    JButton button;
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    if (shouldFill) {
      // natural height, maximum width
      c.fill = GridBagConstraints.HORIZONTAL;
    }

    button = new JButton("Button 1");
    if (shouldWeightX) {
      c.weightx = 0.5;
    }
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    pane.add(button, c);

    button = new JButton("Button 2");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 1;
    c.gridy = 0;
    pane.add(button, c);

    /*button = new JButton("Button 3");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 2;
    c.gridy = 0;
    pane.add(button, c);*/

    button = new JButton("Long-Named Button 4");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipady = 40; // make this component tall
    c.weightx = 0.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    pane.add(button, c);

    button = new JButton("5");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipady = 0; // reset to default
    c.weighty = 1.0; // request any extra vertical space
    c.anchor = GridBagConstraints.PAGE_END; // bottom of space
    c.insets = new Insets(10, 0, 0, 0); // top padding
    c.gridx = 1; // aligned with button 2
    c.gridwidth = 2; // 2 columns wide
    c.gridy = 2; // third row
    pane.add(button, c);

    JTextArea twitArea = new JTextArea(sample, 6, 20);
    twitArea.setFont(new Font("Roman", Font.BOLD, 20));
    twitArea.setLineWrap(true);
    twitArea.setWrapStyleWord(true);
    twitArea.setOpaque(false);
    twitArea.setEditable(false);
    twitArea.setForeground(Color.white);
    GridBagConstraints twitc = new GridBagConstraints();
    twitc.gridy = 0;
    twitc.gridx = 2;
    twitc.gridheight = 2;
    pane.add(twitArea, twitc);
  }
예제 #10
0
  Client(String[] args) {
    //
    // Initialize an Ice communicator.
    //
    try {
      com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData();
      initData.properties = com.zeroc.Ice.Util.createProperties();
      initData.properties.load("config.client");
      initData.dispatcher =
          (runnable, connection) -> {
            SwingUtilities.invokeLater(runnable);
          };
      _communicator = com.zeroc.Ice.Util.initialize(args, initData).communicator;
    } catch (Throwable ex) {
      handleException(ex);
    }

    Container cp = this;

    JLabel l1 = new JLabel("Hostname");
    _hostname = new JTextField();
    JLabel l2 = new JLabel("Mode");
    _mode = new JComboBox<String>();
    JLabel l3 = new JLabel("Timeout");
    _timeoutSlider = new JSlider(0, MAX_TIME);
    _timeoutLabel = new JLabel("0.0");
    JLabel l4 = new JLabel("Delay");
    _delaySlider = new JSlider(0, MAX_TIME);
    _delayLabel = new JLabel("0.0");
    JPanel buttonPanel = new JPanel();
    _hello = new JButton("Hello World!");
    _shutdown = new JButton("Shutdown");
    _flush = new JButton("Flush");
    _flush.setEnabled(false);
    JSeparator statusPanelSeparator = new JSeparator();
    _status = new JLabel();
    _status.setText("Ready");

    //
    // Default to localhost.
    //
    _hostname.setText("127.0.0.1");
    _hostname
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void changedUpdate(DocumentEvent e) {
                updateProxy();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                if (e.getDocument().getLength() > 0) {
                  _hello.setEnabled(true);
                  _shutdown.setEnabled(true);
                }
                updateProxy();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                if (e.getDocument().getLength() == 0) {
                  _hello.setEnabled(false);
                  _shutdown.setEnabled(false);
                  _flush.setEnabled(false);
                }
                updateProxy();
              }
            });

    _mode.setModel(new DefaultComboBoxModel<String>(DELIVERY_MODE_DESC));

    _hello.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            sayHello();
          }
        });
    _shutdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            shutdown();
          }
        });
    _flush.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            flush();
          }
        });
    _mode.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            changeDeliveryMode(_mode.getSelectedIndex());
          }
        });
    changeDeliveryMode(_mode.getSelectedIndex());

    _timeoutSlider.addChangeListener(new SliderListener(_timeoutSlider, _timeoutLabel));
    _timeoutSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent ce) {
            updateProxy();
          }
        });
    _timeoutSlider.setValue(0);
    _delaySlider.addChangeListener(new SliderListener(_delaySlider, _delayLabel));
    _delaySlider.setValue(0);

    GridBagConstraints gridBagConstraints;

    cp.setMaximumSize(null);
    cp.setPreferredSize(null);
    cp.setLayout(new GridBagLayout());

    l1.setText("Hostname");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    cp.add(l1, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(5, 0, 5, 5);
    cp.add(_hostname, gridBagConstraints);

    l2.setText("Mode");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l2, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 0, 5, 5);
    cp.add(_mode, gridBagConstraints);

    l3.setText("Timeout");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l3, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    cp.add(_timeoutSlider, gridBagConstraints);

    _timeoutLabel.setMinimumSize(new Dimension(20, 17));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_timeoutLabel, gridBagConstraints);

    l4.setText("Delay");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l4, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    cp.add(_delaySlider, gridBagConstraints);

    _delayLabel.setMinimumSize(new Dimension(20, 17));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_delayLabel, gridBagConstraints);

    _hello.setText("Hello World!");
    buttonPanel.add(_hello);

    _shutdown.setText("Shutdown");
    buttonPanel.add(_shutdown);

    _flush.setText("Flush");
    buttonPanel.add(_flush);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.ipady = 5;
    cp.add(buttonPanel, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(statusPanelSeparator, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_status, gridBagConstraints);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    _shutdownHook =
        new Thread("Shutdown hook") {
          @Override
          public void run() {
            destroyCommunicator();
          }
        };

    try {
      Runtime.getRuntime().addShutdownHook(_shutdownHook);
    } catch (IllegalStateException e) {
      //
      // Shutdown in progress, ignored
      //
    }

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            destroyCommunicator();
            Runtime.getRuntime().removeShutdownHook(_shutdownHook);
            dispose();
            Runtime.getRuntime().exit(0);
          }
        });

    setTitle("Ice - Hello World!");
    pack();
    locateOnScreen(this);
    setVisible(true);
  }
예제 #11
0
  /**
   * @return A JPanel the side panel used to store all the options available during the game
   *     Includes: - the timer - the difficulty of the game - The number of hints available - New
   *     Button: Creates a new board with the same difficulty - Reset: Clear board and start again -
   *     Get Hint: Get a hint from the board. the hint cannot be changed - Delete: delete a cell
   *     that can be deleted - Check: check if the board is solved - Solution: view the solution of
   *     the board - Save: Save the current state of the board - Back go back to the main menu
   */
  public JPanel setButtons(int time) {
    JPanel buttons = new JPanel();
    buttons.setLayout(new GridBagLayout());
    buttons.setBackground(new Color(255, 231, 186));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);

    // Display the current time
    clock = new ClockLabel(time);
    gbc.weightx = 0.5;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    buttons.add(clock, gbc);

    // Display the difficulty
    diffLabel = new JLabel("Difficulty: " + Integer.toString(difficulty));
    diffLabel.setFont(new Font("Arial", Font.BOLD, 17));
    gbc.weightx = 0.5;
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    buttons.add(diffLabel, gbc);

    // Display the number of hints available
    // Hints are two times the difficulty
    hintLabel = new JLabel("Hints: " + Integer.toString(hints));
    hintLabel.setFont(new Font("Arial", Font.BOLD, 17));
    gbc.weightx = 0.5;
    gbc.gridx = 2;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    buttons.add(hintLabel, gbc);

    // Create a new game
    JButton New = new JButton("New");
    New.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    New.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new SudokuGUI(difficulty, menu);
            dispose();
          }
        });
    buttons.add(New, gbc);

    // Resets the board to the beginning
    JButton Reset = new JButton("Reset");
    Reset.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 2;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    Reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            sudokuBoard.reset();
          }
        });
    buttons.add(Reset, gbc);

    // Display a hint of the board
    JButton GetHint = new JButton("Get Hint");
    GetHint.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    GetHint.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (hints != 0) {
              sudokuBoard.displayHint();
              hints--;
              hintLabel.setText("Hints: " + Integer.toString(hints));
            }
          }
        });
    buttons.add(GetHint, gbc);

    // Delete a cell
    JButton Delete = new JButton("Delete");
    Delete.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 2;
    gbc.gridy = 6;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    Delete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // add something
            sudokuBoard.deleteCell();
          }
        });
    buttons.add(Delete, gbc);

    JButton Check = new JButton("Check");
    Check.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    Check.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            final JFrame answer = new JFrame();
            answer.setLayout(new FlowLayout(FlowLayout.CENTER));
            answer.pack();

            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            answer.setLocation((d.width - 800), (d.height / 2 - 100));
            answer.setResizable(true);
            answer.setVisible(true);
            JPanel panel = new JPanel();
            // If successful, open a window for them to enter their name
            // If unsuccessful, open a window with a message
            if (sudokuBoard.checkSolution()) {
              answer.setTitle("SUCCESS :)");

              panel.setLayout(new GridBagLayout());
              GridBagConstraints gbc = new GridBagConstraints();
              gbc.insets = new Insets(5, 5, 5, 5);

              JLabel success = new JLabel("Board is Solved. Congratulations!!");
              success.setFont(new Font("Arial", Font.BOLD, 17));
              gbc.gridx = 0;
              gbc.gridy = 0;
              gbc.gridwidth = 2;
              panel.add(success, gbc);

              JLabel enter = new JLabel("Enter Name:");
              gbc.gridx = 0;
              gbc.gridy = 2;
              gbc.gridwidth = 2;
              panel.add(enter, gbc);

              JTextField name = new JTextField();
              name.addKeyListener(
                  new KeyListener() {

                    @Override
                    public void keyPressed(KeyEvent arg0) {
                      // Prevents from entering a name that is just spaces of empty
                      // If the user enters more than one word. It just combines the first two words
                      // and stores that as the name
                      if (!((JTextField) arg0.getSource()).getText().isEmpty()
                          && !((JTextField) arg0.getSource()).getText().trim().isEmpty()) {
                        if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
                          String name = (String) ((JTextField) arg0.getSource()).getText();
                          String[] combine = name.split(" ");
                          name = combine[0] + combine[1];
                          HighList hiscores = new HighList();
                          hiscores.addToList(name, clock.getTime(), difficulty);
                          hiscores.saveRecord();
                          answer.dispose();
                        }
                      }
                    }

                    @Override
                    public void keyReleased(KeyEvent arg0) {}

                    @Override
                    public void keyTyped(KeyEvent arg0) {}
                  });
              gbc.gridx = 0;
              gbc.gridy = 4;
              gbc.gridwidth = 2;
              gbc.ipady = 10;
              gbc.fill = GridBagConstraints.HORIZONTAL;
              panel.add(name, gbc);

              answer.setSize(350, 150);
            } else {
              answer.setTitle("Fail :(");
              JLabel fail = new JLabel("Board is not solved. Try again!");
              fail.setFont(new Font("Arial", Font.BOLD, 17));
              answer.setSize(300, 80);
              panel.add(fail);
            }
            answer.add(panel);
          }
        });
    buttons.add(Check, gbc);

    JButton Solution = new JButton("Solution");
    Solution.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 2;
    gbc.gridy = 8;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    Solution.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (currentSolution != null) {
              currentSolution.dispose();
            }
            currentSolution = new SolutionGUI(sudokuBoard.getSolution());
          }
        });
    buttons.add(Solution, gbc);

    JButton Save = new JButton("Save");
    Save.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 0;
    gbc.gridy = 10;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    Save.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            try {
              sudokuBoard.save(clock.getTime(), hints);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });
    buttons.add(Save, gbc);

    JButton Back = new JButton("Back");
    Back.setFont(new Font("Arial", Font.BOLD, 15));
    gbc.weightx = 0.5;
    gbc.gridx = 2;
    gbc.gridy = 10;
    gbc.gridwidth = 2;
    gbc.ipady = 15;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    Back.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            try {
              sudokuBoard.save(clock.getTime(), hints);
            } catch (IOException e) {
              e.printStackTrace();
            }

            dispose();
            menu.setVisible(true);
          }
        });
    buttons.add(Back, gbc);

    return buttons;
  }
예제 #12
0
  public Lab5() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("Mah Jong Tiles Demo");

    constraints.ipadx = 5;
    constraints.ipady = 5;
    constraints.insets = new Insets(5, 5, 5, 5);
    add(new JScrollPane(tilePanel));

    addComponent(new CharacterTile('1'), 0, 0);
    addComponent(new CharacterTile('2'), 0, 1);
    addComponent(new CharacterTile('3'), 0, 2);
    addComponent(new CharacterTile('4'), 0, 3);
    addComponent(new CharacterTile('5'), 0, 4);
    addComponent(new CharacterTile('6'), 0, 5);
    addComponent(new CharacterTile('7'), 0, 6);
    addComponent(new CharacterTile('8'), 0, 7);
    addComponent(new CharacterTile('9'), 0, 8);

    addComponent(new CircleTile(1), 1, 0);
    addComponent(new CircleTile(2), 1, 1);
    addComponent(new CircleTile(3), 1, 2);
    addComponent(new CircleTile(4), 1, 3);
    addComponent(new CircleTile(5), 1, 4);
    addComponent(new CircleTile(6), 1, 5);
    addComponent(new CircleTile(7), 1, 6);
    addComponent(new CircleTile(8), 1, 7);
    addComponent(new CircleTile(9), 1, 8);

    addComponent(new Bamboo1Tile(), 2, 0);
    addComponent(new BambooTile(2), 2, 1);
    addComponent(new BambooTile(3), 2, 2);
    addComponent(new BambooTile(4), 2, 3);
    addComponent(new BambooTile(5), 2, 4);
    addComponent(new BambooTile(6), 2, 5);
    addComponent(new BambooTile(7), 2, 6);
    addComponent(new BambooTile(8), 2, 7);
    addComponent(new BambooTile(9), 2, 8);

    addComponent(new CharacterTile('N'), 3, 0);
    addComponent(new CharacterTile('E'), 3, 1);
    addComponent(new CharacterTile('W'), 3, 2);
    addComponent(new CharacterTile('S'), 3, 3);

    addComponent(new CharacterTile('C'), 4, 0);
    addComponent(new CharacterTile('F'), 4, 1);
    addComponent(new WhiteDragonTile(), 4, 2);

    addComponent(new FlowerTile("Chrysanthemum"), 5, 0);
    addComponent(new FlowerTile("Orchid"), 5, 1);
    addComponent(new FlowerTile("Plum"), 5, 2);
    addComponent(new FlowerTile("Bamboo"), 5, 3);

    addComponent(new SeasonTile("Spring"), 6, 0);
    addComponent(new SeasonTile("Summer"), 6, 1);
    addComponent(new SeasonTile("Fall"), 6, 2);
    addComponent(new SeasonTile("Winter"), 6, 3);

    pack();
    setVisible(true);
  }
예제 #13
0
  public GUI() {

    // Sets the text and initiates the objects for the buttons
    playButton = new JButton("PLAY");
    exitButton = new JButton("QUIT");
    howToPlay = new JButton("HOW TO PLAY");
    quitEducation = new JButton("Quit education");
    rollDice = new JButton("ROLL THE DICE");
    saveCareerProspects = new JButton("Save career prospects");
    exitApplication = new JButton("Exit application");

    // The main container for the JFrames
    // container for frame

    JPanel welcome = new JPanel();
    spalshScreen.setContentPane(welcome);
    JPanel container = new JPanel();
    frame.setContentPane(container);
    // container for frame 2
    JPanel container2 = new JPanel();
    container2.setBackground(Color.WHITE);

    frame2.setContentPane(container2);
    // container for frame 3
    JPanel container3 = new JPanel();
    container3.setBackground(Color.WHITE);
    frame3.setContentPane(container3);

    loading = new javax.swing.JLabel();
    loading.setIcon(
        new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/hexLoader.gif")));

    // start panel with play button and exit button
    // for frame

    playerName = new javax.swing.JTextField();
    playerName.setText("Player");
    playerName.setLocation(100, 100);
    playerName.setPreferredSize(new Dimension(100, 100));
    playerName.setHorizontalAlignment(JTextField.CENTER);

    JPanel frame = new JPanel();

    frame.add(playerName);

    frame.add(playButton);
    playButton.setPreferredSize(new Dimension(200, 100));
    frame.add(exitButton);
    exitButton.setPreferredSize(new Dimension(200, 100));
    frame.add(howToPlay);
    howToPlay.setPreferredSize(new Dimension(200, 100));

    // board image start screen
    start = new javax.swing.JLabel();
    start.setIcon(
        new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/logo2.png")));

    // for frame 2
    JPanel frame2 = new JPanel();
    frame2.add(quitEducation);

    /* Start of creating the board */

    JButton ordinaryButton;
    int row = 10, column = 10;
    frame2.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(3, 3, 3, 3);

    for (int j = 1; j <= row; j++) {
      for (int i = 0; i < column; i++) {

        ordinaryButton = new JButton();

        if (i == column - 1 && j == row) doActiveTile(ordinaryButton);

        if (j == 1) { // top line
          gbc.ipady = 30;
          gbc.gridx = i;
          gbc.gridy = j;
          gbc.gridwidth = 1;
          addToList(ordinaryButton, TOP);
          frame2.add(ordinaryButton, gbc); // add in the frame
        } else {
          if (j == 10) { // bottom line
            gbc.ipady = 30;
            gbc.gridx = i;
            gbc.gridy = j;
            gbc.gridwidth = 1;
            addToList(ordinaryButton, BOTTOM);
            frame2.add(ordinaryButton, gbc); // add in the frame
          } else {
            if (i == 0) { // left-hand side column
              gbc.ipady = 30;
              gbc.gridx = i;
              gbc.gridy = j;
              gbc.gridwidth = 1;
              addToList(ordinaryButton, LEFT);
              frame2.add(ordinaryButton, gbc); // add in the frame
            } else {
              if (i == 9) { // right-hand side column
                gbc.ipady = 30;
                gbc.gridx = i;
                gbc.gridy = j;
                gbc.gridwidth = 1;
                addToList(ordinaryButton, RIGHT);
                frame2.add(ordinaryButton, gbc); // add in the frame
              }
            }
          }
        }
      }
    }
    /* End of creating the board */

    /* adding constraints for roll dice and Quit education */
    gbc.ipady = 30;
    gbc.gridx = 2;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    frame2.add(rollDice, gbc); // add in the frame

    gbc.ipady = 30;
    gbc.gridx = 6;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    frame2.add(quitEducation, gbc); // add in the frame
    /* END OF adding constraints for roll dice and Quit education */

    // for frame 3
    JPanel frame3 = new JPanel();

    frame3.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(3, 3, 3, 3);
    gbc.ipady = 30;
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = 4;
    frame3.add(saveCareerProspects, gbc);

    frame3.setBackground(Color.WHITE);

    skillsLabel = new javax.swing.JLabel("SKILLS");
    skillsLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.ORANGE));
    Font font = skillsLabel.getFont();
    // same font but bold
    int fontSize = font.getSize();
    fontSize += 5;
    Font boldFont = new Font(font.getFontName(), Font.BOLD, fontSize);
    skillsLabel.setFont(boldFont);

    gbc.ipady = 10;
    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.gridwidth = 1;
    frame3.add(skillsLabel, gbc);
    mathematicsLabel = new javax.swing.JLabel();
    mathematicsLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.PINK));
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.gridwidth = 1;
    frame3.add(mathematicsLabel, gbc);
    scienceLabel = new javax.swing.JLabel();
    scienceLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.CYAN));
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.gridwidth = 1;
    frame3.add(scienceLabel, gbc);
    computerScienceLabel = new javax.swing.JLabel();
    computerScienceLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.green));
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    frame3.add(computerScienceLabel, gbc);
    geographyLabel = new javax.swing.JLabel();
    geographyLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.RED));
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.gridwidth = 1;
    frame3.add(geographyLabel, gbc);
    historyLabel = new javax.swing.JLabel();
    historyLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.BLACK));
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.gridwidth = 1;
    frame3.add(historyLabel, gbc);
    gbc.ipady = 30;
    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.gridwidth = 4;
    frame3.add(exitApplication, gbc);

    gbc.ipady = 10;
    careersLabel = new javax.swing.JLabel("CAREER PROSPECTS", SwingConstants.RIGHT);
    gbc.gridx = 3;
    gbc.gridy = 3;
    gbc.gridwidth = 1;
    careersLabel.setFont(boldFont);

    frame3.add(careersLabel, gbc);
    secondColMaths = new javax.swing.JLabel(mathematicsCareer[0], SwingConstants.RIGHT);
    gbc.gridx = 3;
    gbc.gridy = 4;
    gbc.gridwidth = 1;
    frame3.add(secondColMaths, gbc);
    secondColScience = new javax.swing.JLabel(scienceCareer[0], SwingConstants.RIGHT);
    gbc.gridx = 3;
    gbc.gridy = 5;
    gbc.gridwidth = 1;
    frame3.add(secondColScience, gbc);
    secondColCompScience = new javax.swing.JLabel(computerScienceCareer[0], SwingConstants.RIGHT);
    gbc.gridx = 3;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    frame3.add(secondColCompScience, gbc);
    secondColGeography = new javax.swing.JLabel(geographyCareer[0], SwingConstants.RIGHT);
    gbc.gridx = 3;
    gbc.gridy = 7;
    gbc.gridwidth = 1;
    frame3.add(secondColGeography, gbc);
    secondColHistory = new javax.swing.JLabel(historyCareer[0], SwingConstants.RIGHT);
    gbc.gridx = 3;
    gbc.gridy = 8;
    gbc.gridwidth = 1;
    frame3.add(secondColHistory, gbc);

    JLabel skills = new javax.swing.JLabel();
    skills.setIcon(
        new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/small.jpg")));
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridheight = 9;
    gbc.gridwidth = 3;
    frame3.add(skills, gbc);

    JLabel backgroundImage = new javax.swing.JLabel();
    backgroundImage.setIcon(
        new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/logoSmall.jpg")));
    gbc.gridx = 3;
    gbc.gridy = 2;
    gbc.gridheight = 2;
    gbc.gridwidth = 3;
    frame2.setBackground(Color.WHITE);
    frame2.add(backgroundImage, gbc);

    JLabel rollDiceImage = new javax.swing.JLabel();
    rollDiceImage.setIcon(
        new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/rollDice.jpg")));
    gbc.gridx = 2;
    gbc.gridy = 5;
    gbc.gridheight = 3;
    gbc.gridwidth = 3;
    frame2.add(rollDiceImage, gbc);

    JLabel quitEducationImage = new javax.swing.JLabel();
    quitEducationImage.setIcon(
        new javax.swing.ImageIcon(
            getClass().getClassLoader().getResource("images/quitEducation.jpg")));
    gbc.gridx = 6;
    gbc.gridy = 5;
    gbc.gridheight = 3;
    gbc.gridwidth = 3;
    frame2.add(quitEducationImage, gbc);

    exitApplication.setFont(boldFont);
    saveCareerProspects.setFont(boldFont);
    saveCareerProspects.setForeground(Color.ORANGE);
    exitApplication.setBackground(Color.BLACK);
    exitApplication.setForeground(Color.RED);
    Border border = new LineBorder(Color.LIGHT_GRAY, 5);
    exitApplication.setBorder(border);
    saveCareerProspects.setBorder(border);
    start.setBorder(border);
    howToPlay.setBorder(border);
    playButton.setBorder(border);
    exitButton.setBorder(border);
    howToPlay.setFont(boldFont);
    playButton.setFont(boldFont);
    exitButton.setFont(boldFont);
    border = new LineBorder(Color.ORANGE, 5);
    playerName.setBorder(border);

    // Adds the fields to the panel
    // Adds all the panels to the container
    welcome.add(loading);
    container.add(start);
    container.add(frame);
    container2.add(frame2);
    container3.add(frame3);

    // Action Listeners for the buttons
    howToPlay.addActionListener(this);
    playButton.addActionListener(this);
    exitButton.addActionListener(this);
    quitEducation.addActionListener(this);
    rollDice.addActionListener(this);
    saveCareerProspects.addActionListener(this);
    exitApplication.addActionListener(this);

    // Starts up the UI
    startGui();
    print();
  }
예제 #14
0
  public Summary(int patient_id) {
    this.patient_id = patient_id;
    setTitle("Summary");
    setSize(
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()),
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()) - 40);
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    head = new JLabel("MEDI_SCAN DIAGNOSTIC LAB SERVICES", SwingConstants.CENTER);
    head.setForeground(Color.WHITE);
    Font f2 = new Font("Papyrus", Font.BOLD, 36);
    head.setFont(f2);
    res = new JLabel("RESULT SUMMARY", SwingConstants.CENTER);
    res.setForeground(Color.WHITE);
    Font f3 = new Font("Papyrus", Font.BOLD, 28);
    res.setFont(f3);
    Font f1 = new Font("Goudy Old Style", Font.BOLD, 16);
    hello = new JLabel("Hello Mr./Miss ");
    hello.setForeground(new Color(54, 34, 174));
    hello.setFont(f1);

    fin = new JLabel("Your Medical Test Is Finished");
    fin.setFont(f1);
    fin.setForeground(new Color(54, 34, 174));
    pname = new JLabel("Patient Name");
    pname.setForeground(new Color(54, 34, 174));
    pname.setFont(f1);
    ldate = new JLabel("Test Date");
    ldate.setForeground(new Color(54, 34, 174));
    ldate.setFont(f1);
    age = new JLabel("Age");
    age.setForeground(new Color(54, 34, 174));
    age.setFont(f1);
    sex = new JLabel("Sex");
    sex.setForeground(new Color(54, 34, 174));
    sex.setFont(f1);
    tname = new JLabel("Test Name");
    tname.setForeground(new Color(54, 34, 174));
    tname.setFont(f1);
    nvalue = new JLabel("Normal Value");
    nvalue.setForeground(new Color(54, 34, 174));
    nvalue.setFont(f1);
    trate = new JLabel("Test Rate");
    trate.setForeground(new Color(54, 34, 174));
    trate.setFont(f1);
    tresult = new JLabel("Test Result");
    tresult.setForeground(new Color(54, 34, 174));
    tresult.setFont(f1);
    tamt = new JLabel("Total Amout");
    tamt.setForeground(new Color(54, 34, 174));
    tamt.setFont(f1);

    exit = new JButton("EXIT");
    exit.setFont(f1);

    pHead = new JPanel(new GridLayout(2, 1));
    pHead.setBackground(new Color(134, 134, 234));
    pCenter = new JPanel(new GridBagLayout());
    pCenter.setBackground(new Color(211, 248, 253));
    pCom = new JPanel(new BorderLayout());
    pCom.setBackground(new Color(211, 248, 253));
    pSouth = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pSouth.setBackground(new Color(211, 248, 253));

    // Adding Icon on top-left.
    ImageIcon img = new ImageIcon("pics/logo.jpg");
    this.setIconImage(img.getImage());

    try {
      Connection con = JDBCConnection.getConnection();
      PreparedStatement pstmt =
          con.prepareStatement(
              "Select first_name,last_name,age,sex,test_id,tdate from patientreg where patient_id=?");
      pstmt.setInt(1, this.patient_id);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        first_name = rs.getString("first_name");
        lname = rs.getString("last_name");
        name = new JLabel(first_name + " " + lname);
        name1 = new JLabel(first_name + " " + lname);
        p_age = rs.getInt("age");
        pAge = new JLabel(p_age + "");
        p_sex = rs.getString("sex");
        psex = new JLabel(p_sex);
        t_id = rs.getInt("test_id");
        t_date = rs.getString("tdate");
        date1 = new JLabel(t_date);
      }
    } catch (SQLException s) {
      s.printStackTrace();
    }

    try {
      Connection con = JDBCConnection.getConnection();
      PreparedStatement pstmt =
          con.prepareStatement("Select test_result from reportbydoctor where patient_id=?");
      pstmt.setInt(1, this.patient_id);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {

        te_res = rs.getString("test_result");
        result = new JLabel(te_res);
      }
    } catch (SQLException s) {
      s.printStackTrace();
    }

    try {
      Connection con = JDBCConnection.getConnection();
      PreparedStatement pstmt =
          con.prepareStatement("select normal_val,rate,test_name from addtest where test_id=?");
      pstmt.setInt(1, t_id);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        n_value = rs.getInt("normal_val");
        normal_value1 = new JLabel(n_value + "");
        te_rate = rs.getInt("rate");
        rate1 = new JLabel(te_rate + "");
        rate2 = new JLabel(te_rate + "");
        te_name = rs.getString("test_name");
        testname = new JLabel(te_name);
      }
    } catch (SQLException a) {
      a.printStackTrace();
    }

    content = getContentPane();

    // for label hello
    GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 1;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 50, 20, 0);
    pCenter.add(hello, gc);

    // for label name1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 1;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 0);
    pCenter.add(name1, gc);

    // for label fin
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 2;
    gc.gridy = 1;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(fin, gc);

    // for label pname
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 2;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(pname, gc);

    // for label name
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 2;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(name, gc);

    // for label ldate
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 3;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(ldate, gc);

    // for label date1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 3;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(date1, gc);

    // for label age
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 4;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(age, gc);

    // for label pAge
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 4;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(pAge, gc);

    // for label sex
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 5;
    gc.ipadx = 125;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(sex, gc);

    // for label psex
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 5;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);

    pCenter.add(psex, gc);

    // for label tname
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(tname, gc);

    // for label nvalue
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(nvalue, gc);

    // for label trate
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(trate, gc);

    // for label tresult
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 4;
    gc.gridwidth = 1;
    gc.gridy = 6;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(tresult, gc);

    // for label testname
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(testname, gc);

    // for label normal_value1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 2;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(normal_value1, gc);

    // for label rate1
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(rate1, gc);

    // for label result
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 4;
    gc.gridwidth = 1;
    gc.gridy = 7;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(result, gc);

    // for label tamt
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 3;
    gc.gridwidth = 1;
    gc.gridy = 8;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(tamt, gc);

    // for label rate2
    gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.NONE;
    gc.gridx = 4;
    gc.gridwidth = 1;
    gc.gridy = 8;
    gc.ipadx = 0;
    gc.ipady = 10;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.insets = new Insets(0, 0, 20, 20);
    pCenter.add(rate2, gc);

    exit.addActionListener(this);
    pSouth.add(exit);
    content.add(pSouth, BorderLayout.SOUTH);

    pHead.add(head);
    pHead.add(res);

    content.add(pHead, BorderLayout.NORTH);
    content.add(pCenter, BorderLayout.CENTER);
    setVisible(true);
  }
예제 #15
0
  // initializes the internal component of the translator
  protected void jbInit() {
    this.getContentPane().setLayout(new GridBagLayout());

    loadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadButton_actionPerformed(e);
          }
        });
    loadButton.setMaximumSize(new Dimension(39, 39));
    loadButton.setMinimumSize(new Dimension(39, 39));
    loadButton.setPreferredSize(new Dimension(39, 39));
    loadButton.setSize(new Dimension(39, 39));
    loadButton.setToolTipText("Load Source File");
    loadButton.setIcon(loadIcon);

    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveButton_actionPerformed(e);
          }
        });
    saveButton.setMaximumSize(new Dimension(39, 39));
    saveButton.setMinimumSize(new Dimension(39, 39));
    saveButton.setPreferredSize(new Dimension(39, 39));
    saveButton.setSize(new Dimension(39, 39));
    saveButton.setToolTipText("Save Destination File");
    saveButton.setIcon(saveIcon);

    singleStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepButton_actionPerformed(e);
          }
        });
    singleStepButton.setMaximumSize(new Dimension(39, 39));
    singleStepButton.setMinimumSize(new Dimension(39, 39));
    singleStepButton.setPreferredSize(new Dimension(39, 39));
    singleStepButton.setSize(new Dimension(39, 39));
    singleStepButton.setToolTipText("Single Step");
    singleStepButton.setIcon(singleStepIcon);

    ffwdButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdButton_actionPerformed(e);
          }
        });
    ffwdButton.setMaximumSize(new Dimension(39, 39));
    ffwdButton.setMinimumSize(new Dimension(39, 39));
    ffwdButton.setPreferredSize(new Dimension(39, 39));
    ffwdButton.setSize(new Dimension(39, 39));
    ffwdButton.setToolTipText("Fast Forward");
    ffwdButton.setIcon(ffwdIcon);

    rewindButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindButton_actionPerformed(e);
          }
        });
    rewindButton.setMaximumSize(new Dimension(39, 39));
    rewindButton.setMinimumSize(new Dimension(39, 39));
    rewindButton.setPreferredSize(new Dimension(39, 39));
    rewindButton.setSize(new Dimension(39, 39));
    rewindButton.setToolTipText("Rewind");
    rewindButton.setIcon(rewindIcon);

    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopButton_actionPerformed(e);
          }
        });
    stopButton.setMaximumSize(new Dimension(39, 39));
    stopButton.setMinimumSize(new Dimension(39, 39));
    stopButton.setPreferredSize(new Dimension(39, 39));
    stopButton.setSize(new Dimension(39, 39));
    stopButton.setToolTipText("Stop");
    stopButton.setIcon(stopIcon);

    fullTranslationButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fullTranslationButton_actionPerformed(e);
          }
        });
    fullTranslationButton.setMaximumSize(new Dimension(39, 39));
    fullTranslationButton.setMinimumSize(new Dimension(39, 39));
    fullTranslationButton.setPreferredSize(new Dimension(39, 39));
    fullTranslationButton.setSize(new Dimension(39, 39));
    fullTranslationButton.setToolTipText("Fast Translation");
    fullTranslationButton.setIcon(fullTranslationIcon);

    messageLbl.setFont(Utilities.statusLineFont);
    messageLbl.setLineWrap(true);
    messageLbl.setEditable(false);
    messageLbl.setCursor(null);
    messageLbl.setOpaque(false);
    messageLbl.setFocusable(false);
    messageLblPane.setBorder(BorderFactory.createLoweredBevelBorder());
    // messageLblPane.setBounds(new Rectangle(0, 672, TRANSLATOR_WIDTH - 8, 20));
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 2;
    this.getContentPane().add(messageLblPane, c);

    // arrowLabel.setBounds(new Rectangle(290, 324, 88, 71));
    arrowLabel.setIcon(arrowIcon);

    // source.setVisibleRows(31);
    // destination.setVisibleRows(31);
    // source.setBounds(new Rectangle(35,100,source.getWidth(),source.getHeight()));
    // destination.setBounds(new Rectangle(375,100,destination.getWidth(),destination.getHeight()));

    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 1;
    this.getContentPane().add(source, c);

    c.fill = GridBagConstraints.NONE;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 1;
    c.gridy = 1;
    this.getContentPane().add(arrowLabel, c);

    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 2;
    c.gridy = 1;
    this.getContentPane().add(destination, c);

    // Adding the tool bar to this container.
    toolBar.setFloatable(false);
    toolBar.setLocation(0, 0);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    toolBar.setBorder(BorderFactory.createEtchedBorder());
    arrangeToolBar();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 0;
    this.getContentPane().add(toolBar, c);
    toolBar.revalidate();
    toolBar.repaint();
    repaint();

    // Creating the menu bar
    arrangeMenu();
    setJMenuBar(menuBar);

    // initializing the window size and visibility
    setDefaultCloseOperation(3);
    setSize(new Dimension(TRANSLATOR_WIDTH, TRANSLATOR_HEIGHT));
    setVisible(true);
  }
 /** Fills the panel with simple signal specific fields. */
 protected void fillPanel() {
   if (controller != null) {
     Vector<CycleDataRow> cd = ((ControllerSimpleSignal) controller).getCycleTable();
     for (int i = 0; i < cd.size(); i++) {
       CycleDataRow cdr =
           ((ControllerSimpleSignal) controller)
           .new CycleDataRow(cd.get(i).getTime(), cd.get(i).getGreen(), cd.get(i).getRed());
       cycledata.add(cdr);
     }
   }
   // offset
   JPanel pO = new JPanel(new BorderLayout());
   pO.setBorder(BorderFactory.createTitledBorder("Offset (sec.)"));
   offset =
       new JSpinner(
           new SpinnerNumberModel(
               ((ControllerSimpleSignal) controller).getOffset() * conversion, 0.0, 99999.99, 10));
   offset.setEditor(new JSpinner.NumberEditor(offset, "####0.##"));
   pO.add(offset);
   add(pO);
   // table
   JPanel tabpanel = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   tabpanel.setBorder(BorderFactory.createTitledBorder("Cycle Schedule"));
   cycletable = new JTable(cycletablemodel);
   cycletable.setPreferredScrollableViewportSize(new Dimension(200, 50));
   cycletable.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             int row = cycletable.rowAtPoint(new Point(e.getX(), e.getY()));
             if ((row > cycledata.size() - 1) || (row < 0)) return;
             try {
               WindowEdit winEdit = new WindowEdit(null, cycledata.get(row));
               winEdit.setVisible(true);
               cycletablemodel.deleterow(row);
               cycletablemodel.addrow(winEdit.getMyRow());
             } catch (Exception excp) {
             }
           }
         }
       });
   c.fill = GridBagConstraints.HORIZONTAL;
   c.ipady = 100;
   c.weightx = 0.5;
   c.gridwidth = 3;
   c.gridx = 0;
   c.gridy = 0;
   tabpanel.add(new JScrollPane(cycletable), c);
   c.ipady = 0;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridx = 0;
   tabpanel.add(buttonAdd, c);
   c.gridx = 1;
   tabpanel.add(buttonDelete, c);
   add(tabpanel);
   // configure buttons
   buttonAdd.setEnabled(true);
   buttonAdd.addActionListener(new ButtonAddListener());
   buttonDelete.setEnabled(true);
   buttonDelete.addActionListener(new ButtonDeleteListener());
   return;
 }
예제 #17
0
 /** Fills the panel with SWARM specific fields. */
 public void fillPanel() {
   // Zone initialization
   ControllerSWARM z = (ControllerSWARM) controller;
   Vector<Zone> cz = z.zones;
   for (int i = 0; i < cz.size(); i++) zones.add(cz.get(i).clone());
   // Parameter initialization
   density_sample_size = z.P.SWARM_DENSITY_SAMPLE_SIZE;
   epsilon = z.P.epsilon;
   forecast_lead_time = z.P.SWARM_FORECAST_LEAD_TIME;
   input_var_lane = z.P.input_var_lane;
   meas_var_lane = z.P.meas_var_lane;
   phi = z.P.swarm_phi;
   psi = z.P.swarm_psi;
   sat_den_multiplier = z.P.SWARM_SAT_DEN_NUMBER;
   sat_smoother = z.P.sat_smoother;
   slope_sample_size = z.P.SWARM_SLOPE_SAMPLE_SIZE;
   // Components
   JPanel comp = new JPanel(new FlowLayout());
   comp.setBorder(BorderFactory.createTitledBorder("Components"));
   cbsw1.setSelected(z.P.SWARM1);
   comp.add(cbsw1);
   comp.add(new JLabel("  "));
   cbsw2a.setSelected(z.P.SWARM2A);
   comp.add(cbsw2a);
   comp.add(new JLabel("  "));
   cbsw2b.setSelected(z.P.SWARM2B);
   comp.add(cbsw2b);
   comp.add(new JLabel("  "));
   cbdynbott.setEnabled(false);
   comp.add(cbdynbott);
   add(comp);
   // Zones
   JPanel zone = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   zone.setBorder(BorderFactory.createTitledBorder("Zones"));
   zonetab.setPreferredScrollableViewportSize(new Dimension(400, 30));
   setUpBottleneckColumn();
   setUpFromOnrampColumn();
   setUpToOnrampColumn();
   c.fill = GridBagConstraints.HORIZONTAL;
   c.ipady = 45;
   c.weightx = 0.5;
   c.gridwidth = 3;
   c.gridx = 0;
   c.gridy = 0;
   zone.add(new JScrollPane(zonetab), c);
   c.ipady = 0;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridx = 0;
   zone.add(buttonAdd, c);
   c.gridx = 1;
   zone.add(buttonDelete, c);
   // configure buttons
   buttonAdd.setEnabled(true);
   buttonAdd.setActionCommand(cmdAdd);
   buttonAdd.addActionListener(this);
   buttonDelete.setEnabled(true);
   buttonDelete.setActionCommand(cmdDelete);
   buttonDelete.addActionListener(this);
   add(zone);
   // Parameters
   JPanel param = new JPanel(new GridLayout(1, 0));
   param.setBorder(BorderFactory.createTitledBorder("Parameters"));
   final JTable paramtab = new JTable(paramTM);
   paramtab.setPreferredScrollableViewportSize(new Dimension(500, 160));
   param.add(new JScrollPane(paramtab));
   add(param);
   return;
 }
예제 #18
0
  /** Création de l'intérieur de la fenêtre */
  private void initConteneur() {
    // le fond
    fond = getToolkit().getImage("./images/preference/bomber_fond.gif");
    tracker = new MediaTracker(this);
    tracker.addImage(fond, 0);
    try {
      tracker.waitForID(0);
    } catch (Exception a) {
      System.out.println("Erreur lors chargement de l'image: initConteneur() Preference");
      a.printStackTrace();
    }

    // le layout manager
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 10;
    c.weighty = 10;
    c.ipadx = 10;
    c.ipady = 10;
    c.fill = GridBagConstraints.BOTH;

    // label "Joueurs:"
    Label lbl_joueurs = new Label("Joueurs:");
    lbl_joueurs.setAlignment(Label.CENTER);
    lbl_joueurs.setFont(new Font("SansSerif", Font.BOLD, 16));
    lbl_joueurs.setBackground(Color.black);
    lbl_joueurs.setForeground(Color.red);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 6;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 10, 10);
    c.anchor = GridBagConstraints.SOUTH;
    layout.setConstraints(lbl_joueurs, c);
    add(lbl_joueurs);

    // choix de couleur du joueur ayant l'identifiant 0
    choix_couleur0 = new Choice();
    choix_couleur0.addItem("rouge");
    choix_couleur0.addItem("bleu");
    choix_couleur0.addItemListener(this);
    choix_couleur0.setBackground(Color.red);
    choix_couleur0.setForeground(Color.black);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 5, 20);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(choix_couleur0, c);
    add(choix_couleur0);

    // nom du joueur ayant l'identifiant 0
    txt_joueur0 = new TextField(noms[0]);
    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 4;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 5, 20);
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(txt_joueur0, c);
    add(txt_joueur0);

    // choix de couleur du joueur ayant l'identifiant 1
    choix_couleur1 = new Choice();
    choix_couleur1.addItem("bleu");
    choix_couleur1.addItem("rouge");
    choix_couleur1.addItemListener(this);
    choix_couleur1.setBackground(Color.blue);
    choix_couleur1.setForeground(Color.black);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 20, 20);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(choix_couleur1, c);
    add(choix_couleur1);

    // nom du joueur ayant l'identifiant 1
    txt_joueur1 = new TextField(noms[1]);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 4;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 30, 20);
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(txt_joueur1, c);
    add(txt_joueur1);

    // label "Nombre De Vies:"
    Label lbl_nbvies = new Label("Nombre De Vies:");
    lbl_nbvies.setAlignment(Label.CENTER);
    lbl_nbvies.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_nbvies.setBackground(Color.black);
    lbl_nbvies.setForeground(Color.yellow);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_nbvies, c);
    add(lbl_nbvies);
    // un choix possible
    cbg_vies = new CheckboxGroup();
    Checkbox cb;
    for (int i = 1; i <= 5; i++) {
      if (i == nb_vies) cb = new Checkbox("" + i, cbg_vies, true);
      else cb = new Checkbox("" + i, cbg_vies, false);
      c.gridx = i;
      c.gridy = 4;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.insets = new Insets(20, 10, 5, 10);
      c.anchor = GridBagConstraints.CENTER;
      layout.setConstraints(cb, c);
      add(cb);
    } // for

    // label "Nombre	De Victoires:"
    lbl_victoires = new Label();
    lbl_victoires.setAlignment(Label.CENTER);
    lbl_victoires.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_victoires.setText("Nombre De Victoires: " + nb_victoires);
    lbl_victoires.setBackground(Color.black);
    lbl_victoires.setForeground(Color.green);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_victoires, c);
    add(lbl_victoires);

    // choix du nombre de victoires entre un 1 et 9
    sb_victoires = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 10);
    sb_victoires.setUnitIncrement(1);
    sb_victoires.setBlockIncrement(2);
    sb_victoires.addAdjustmentListener(this);
    sb_victoires.setValue(nb_victoires);
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 5;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(sb_victoires, c);
    add(sb_victoires);

    // tirage aléatoire des niveaux
    cb_aleatoire = new Checkbox("Niveaux Aléatoires", aleatoire);
    cb_aleatoire.setFont(new Font("SansSerif", Font.BOLD, 14));
    cb_aleatoire.setBackground(Color.black);
    cb_aleatoire.setForeground(Color.magenta);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 12, 5, 10);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(cb_aleatoire, c);
    add(cb_aleatoire);

    // label "FPS:" nombre de frames par seconde
    lbl_fps = new Label();
    lbl_fps.setAlignment(Label.CENTER);
    lbl_fps.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_fps.setText("FPS: " + fps);
    lbl_fps.setBackground(Color.black);
    lbl_fps.setForeground(Color.orange);
    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_fps, c);
    add(lbl_fps);

    // choix du nombre de frames par seconde
    sb_fps = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 51);
    sb_fps.setUnitIncrement(1);
    sb_fps.setBlockIncrement(10);
    sb_fps.addAdjustmentListener(this);
    sb_fps.setValue(fps);
    c.gridx = 1;
    c.gridy = 10;
    c.gridwidth = 5;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(sb_fps, c);
    add(sb_fps);

    // bouton de confirmation
    button_ok = new Button("Ok");
    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 6;
    c.gridheight = 1;
    c.insets = new Insets(20, 5, 20, 5);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(button_ok, c);
    add(button_ok);
    button_ok.addActionListener(this);
  } // initConteneur()
  public WizStepManyTextFields(Wizard w, String instr, Vector strings) {
    // store wizard?
    _instructions.setText(instr);
    _instructions.setWrapStyleWord(true);
    _instructions.setEditable(false);
    _instructions.setBorder(null);
    _instructions.setBackground(_mainPanel.getBackground());

    _mainPanel.setBorder(new EtchedBorder());

    GridBagLayout gb = new GridBagLayout();
    _mainPanel.setLayout(gb);

    GridBagConstraints c = new GridBagConstraints();
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.EAST;

    JLabel image = new JLabel("");
    // image.setMargin(new Insets(0, 0, 0, 0));
    image.setIcon(WIZ_ICON);
    image.setBorder(null);
    c.gridx = 0;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridy = 0;
    c.anchor = GridBagConstraints.NORTH;
    gb.setConstraints(image, c);
    _mainPanel.add(image);

    c.weightx = 0.0;
    c.gridx = 2;
    c.gridheight = 1;
    c.gridwidth = 3;
    c.gridy = 0;
    c.fill = GridBagConstraints.NONE;
    gb.setConstraints(_instructions, c);
    _mainPanel.add(_instructions);

    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer = new SpacerPanel();
    gb.setConstraints(spacer, c);
    _mainPanel.add(spacer);

    c.gridx = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    int size = strings.size();
    for (int i = 0; i < size; i++) {
      c.gridy = 2 + i;
      String s = (String) strings.elementAt(i);
      JTextField tf = new JTextField(s, 50);
      tf.setMinimumSize(new Dimension(200, 20));
      tf.getDocument().addDocumentListener(this);
      _fields.addElement(tf);
      gb.setConstraints(tf, c);
      _mainPanel.add(tf);
    }

    c.gridx = 1;
    c.gridy = 3 + strings.size();
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer2 = new SpacerPanel();
    gb.setConstraints(spacer2, c);
    _mainPanel.add(spacer2);
  }
예제 #20
0
  private void initComponents() {
    GridBagConstraints gridBagConstraints;

    aliasLabel = new JLabel();
    aliasTextField = new JTextField();
    hostLabel = new JLabel();
    hostTextField = new JTextField();
    usernameLabel = new JLabel();
    usernameTextField = new JTextField();
    passwordLabel = new JLabel();
    passwordTextField = new JTextField();

    setLayout(new GridBagLayout());

    aliasLabel.setText("Server Alias:");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 3;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.insets = new Insets(2, 2, 2, 2);
    add(aliasLabel, gridBagConstraints);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 3;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = GridBagConstraints.NORTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(2, 2, 2, 2);
    add(aliasTextField, gridBagConstraints);

    hostLabel.setText("Hostname / IP:");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 3;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.insets = new Insets(2, 2, 2, 2);
    add(hostLabel, gridBagConstraints);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 3;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = GridBagConstraints.NORTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(2, 2, 2, 2);
    add(hostTextField, gridBagConstraints);

    usernameLabel.setText("Username:"******"Password:");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.ipadx = 3;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.insets = new Insets(2, 2, 2, 2);
    add(passwordLabel, gridBagConstraints);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 3;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(2, 2, 2, 2);
    add(passwordTextField, gridBagConstraints);
  }
예제 #21
0
  public JunctionLinkDataFrame(final JunctionLink jl) {
    super(
        jl.getCurrName() + " properties",
        false, // resizable
        false, // closable
        false, // maximizable
        true); // iconifiable
    // PSRender.onHold();
    super.setBackground(back_color);
    super.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            reload();
            SelectedObject.setSelectedObject(jl);
          }
        });
    PSRender.moveToTop(jl.getBound(), 0.5);
    ml = jl;
    setLocation(50, 50);
    dataModelMain = new HeadTable(jl);
    tableMain = new JTable(dataModelMain);
    tableMain.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    tableMain.setPreferredScrollableViewportSize(new Dimension(500, 20));
    //        tableMain.setBackground(back_color);

    // code
    TableColumn column_code = tableMain.getColumn("Code");
    DefaultTableCellRenderer rendererCode = new DefaultTableCellRenderer();
    rendererCode.setToolTipText("Enter new code for this path");
    column_code.setCellRenderer(rendererCode);
    column_code.setCellEditor(new TextFieldEditor());
    // name
    TableColumn column_name = tableMain.getColumn("Name");
    LanguageButtonRender render_name = new LanguageButtonRender();
    render_name.setToolTipText("Path name. Press for change name");
    column_name.setCellRenderer(render_name);
    LanguageButtonEditor editor_name = new LanguageButtonEditor(new JCheckBox());
    column_name.setCellEditor(editor_name);
    // junction 1
    TableColumn column_junc_1 = tableMain.getColumn("Junction 1");
    MLButtonRenderer rendererJunc_1 = new MLButtonRenderer();
    rendererJunc_1.setToolTipText("Code of first Junction, click for open properties");
    column_junc_1.setCellRenderer(rendererJunc_1);
    MLButtonEditor editorJunc = new MLButtonEditor(new JCheckBox());
    column_junc_1.setCellEditor(editorJunc);
    // junction 2
    TableColumn column_junc_2 = tableMain.getColumn("Junction 2");
    MLButtonRenderer rendererJunc_2 = new MLButtonRenderer();
    rendererJunc_2.setToolTipText("Code of second Junction, click for open properties");
    column_junc_2.setCellRenderer(rendererJunc_2);
    column_junc_2.setCellEditor(editorJunc);
    // type
    JComboBox comboBoxType = new JComboBox();
    String roadNames[] = jl.getTypeNames();
    for (int i = 0, len = roadNames.length; i < len; i++) {
      comboBoxType.addItem(roadNames[i]);
    }
    TableColumn column_type = tableMain.getColumn("Type");
    DefaultTableCellRenderer rendererType = new DefaultTableCellRenderer();
    rendererType.setToolTipText("To change road type click for combo box");
    column_type.setCellRenderer(rendererType);
    column_type.setCellEditor(new DefaultCellEditor(comboBoxType));
    // legth
    TableColumn column_length = tableMain.getColumn("Length");
    DefaultTableCellRenderer rendererLen = new DefaultTableCellRenderer();
    rendererLen.setToolTipText("The path length in meters");
    column_length.setCellRenderer(rendererLen);

    scrollpaneMain = new JScrollPane(tableMain);
    scrollpaneMain.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollpaneMain.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    scrollpaneMain.setPreferredSize(new Dimension(500, 50));

    Container contentPane = super.getContentPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    contentPane.setLayout(gridbag);

    c.ipady = 0; // make this component tall
    c.weightx = 0.5;
    c.gridwidth = 4;
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(scrollpaneMain, c);
    //        scrollpaneMain.setBackground(back_color);
    //        scrollpaneMain.setForeground(back_color);
    contentPane.add(scrollpaneMain);

    TableModel dataModelPoints = new PointTableModel(jl);
    tablePoints = new JTable(dataModelPoints);
    tablePoints.setPreferredScrollableViewportSize(
        new Dimension(200, dataModelPoints.getRowCount() * tablePoints.getRowHeight()));
    ListModel lm =
        new AbstractListModel() {
          public int getSize() {
            return 1000;
          }

          public Object getElementAt(int index) {
            return "" + index;
          }
        };
    JList rowHeader = new JList(lm);
    rowHeader.setFixedCellWidth(20);

    rowHeader.setFixedCellHeight(tablePoints.getRowHeight());
    // + tablePoints.getRowMargin());

    rowHeader.setCellRenderer(new RowHeaderRenderer(tablePoints));

    scrollPanePoints = new JScrollPane(tablePoints);
    scrollPanePoints.setWheelScrollingEnabled(true);
    scrollPanePoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPanePoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    int mh;
    if (dataModelPoints.getRowCount() * tablePoints.getRowHeight() > 100) {
      mh = 100;
    } else {
      mh = dataModelPoints.getRowCount() * tablePoints.getRowHeight();
    }
    scrollPanePoints.setPreferredSize(new Dimension(200, mh));
    scrollPanePoints.setRowHeaderView(rowHeader);

    c.ipadx = 200;
    c.weightx = 0.5;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(scrollPanePoints, c);
    //        scrollPanePoints.setBackground(back_color);
    contentPane.add(scrollPanePoints);

    button_ok = new JButton("Ok");
    button_ok.addActionListener(this);
    JPanel buttonPane = new JPanel(null);
    buttonPane.setPreferredSize(new Dimension(500, 100));
    button_ok.setBounds(205, 40, 90, 40);
    buttonPane.add(button_ok);
    c.ipady = 10; // make this component tall
    c.ipadx = 10;
    c.weightx = 0.5;
    c.gridwidth = 4;
    c.gridx = 2;
    c.gridy = 2;
    gridbag.setConstraints(buttonPane, c);
    buttonPane.setBackground(back_color);
    contentPane.add(buttonPane);

    super.pack();
    super.setVisible(true);

    // MapApplication.getDesktop().setSelectedFrame(this);

  }