Example #1
0
  private void listPeople() {

    try {

      jScrollPane1.getViewport().setView(null);

      JFlowPanel jPeople = new JFlowPanel();
      jPeople.applyComponentOrientation(getComponentOrientation());

      java.util.List people = m_dlSystem.listPeopleVisible();

      for (int i = 0; i < people.size(); i++) {

        AppUser user = (AppUser) people.get(i);

        JButton btn = new JButton(new AppUserAction(user));
        btn.applyComponentOrientation(getComponentOrientation());
        btn.setFocusPainted(false);
        btn.setFocusable(false);
        btn.setRequestFocusEnabled(false);
        btn.setHorizontalAlignment(SwingConstants.LEADING);
        btn.setMaximumSize(new Dimension(150, 50));
        btn.setPreferredSize(new Dimension(150, 50));
        btn.setMinimumSize(new Dimension(150, 50));

        jPeople.add(btn);
      }
      jScrollPane1.getViewport().setView(jPeople);

    } catch (BasicException ee) {
      ee.printStackTrace();
    }
  }
Example #2
0
  // constructor of TextFrame
  public TextFrame() {
    // this.message = message;
    message = "Click to Edit Text";
    messageFont = new Font("Arial", Font.PLAIN, 30);
    foreground = Color.black;
    background = Color.white;

    // custom dialog (it's a private class inside TextFrame)
    cd = new CustomDialog(this);

    messageField = new JTextField();
    messageField.setPreferredSize(new Dimension(300, 200));
    messageField.setEditable(false);
    messageField.setHorizontalAlignment(SwingConstants.CENTER);
    messageField.setAlignmentX(Component.CENTER_ALIGNMENT);
    updateMessage();

    customize = new JButton("Customize");
    customize.setMaximumSize(customize.getPreferredSize());
    customize.setAlignmentX(Component.CENTER_ALIGNMENT);

    apply = new JButton("Apply");
    apply.setMaximumSize(customize.getPreferredSize());
    apply.setAlignmentX(Component.CENTER_ALIGNMENT);

    /*add the listeners*/
    customize.addActionListener(this);
    apply.addActionListener(this);
    messageField.addMouseListener(new PopUpClass());

    // customize
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(customize);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(messageField);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(apply);
    p.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));

    // make panel this JFrame's content pane

    this.setContentPane(p);
  }
  /**
   * If the add button is pressed, this function creates a spot for it in the scroll pane, and tells
   * the restaurant panel to add a new person.
   *
   * @param name name of new person
   */
  public void addPerson(String name, boolean isHungry) {
    if (name != null) {
      JButton button = new JButton(name);
      button.setBackground(Color.white);

      Dimension paneSize = scrollPane.getSize();
      Dimension buttonSize =
          new Dimension(
              (paneSize.width / NUM_BUTTONS_COLS) - BUTTON_WIDTH_ADJUST,
              paneSize.height / NUM_BUTTONS_ROWS);
      button.setPreferredSize(buttonSize);
      button.setMinimumSize(buttonSize);
      button.setMaximumSize(buttonSize);
      button.addActionListener(this);
      list.add(button);
      view.add(button);
      if (isHungry)
        restPanel.addPerson(null, "Hungry" + type, name, 50); // puts hungry customer on list
      else restPanel.addPerson(null, type, name, 50); // puts customer on list
      //        restPanel.showInfo(type, name);//puts hungry button on panel
      validate();
    }
  }
  /**
   * Displays a modal dialog with one button for each entry in the {@link GraphicGenerator} clipart
   * library. Clicking on a button sets that entry into the {@link ATTR_CLIPART_NAME} parameter.
   */
  private void displayClipartDialog() {
    Window window = SwingUtilities.getWindowAncestor(myPanel);
    final JDialog dialog = new JDialog(window, Dialog.ModalityType.DOCUMENT_MODAL);
    FlowLayout layout = new FlowLayout();
    dialog.getRootPane().setLayout(layout);
    int count = 0;
    for (Iterator<String> iter = GraphicGenerator.getClipartNames(); iter.hasNext(); ) {
      final String name = iter.next();
      try {
        JButton btn = new JButton();

        btn.setIcon(new ImageIcon(GraphicGenerator.getClipartIcon(name)));
        Dimension d = new Dimension(CLIPART_ICON_SIZE, CLIPART_ICON_SIZE);
        btn.setMaximumSize(d);
        btn.setPreferredSize(d);
        btn.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                myTemplateState.put(ATTR_CLIPART_NAME, name);
                dialog.setVisible(false);
                update();
              }
            });
        dialog.getRootPane().add(btn);
        count++;
      } catch (IOException e) {
        LOG.error(e);
      }
    }
    int size =
        (int) (Math.sqrt(count) + 1) * (CLIPART_ICON_SIZE + layout.getHgap())
            + CLIPART_DIALOG_BORDER * 2;
    dialog.setSize(size, size + DIALOG_HEADER);
    dialog.setLocationRelativeTo(window);
    dialog.setVisible(true);
  }
Example #5
0
 void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5);
   panel1.setLayout(borderLayout1);
   jPanel1.setLayout(borderLayout2);
   jScrollPane1.getViewport().setBackground(Color.white);
   jPanel2.setLayout(gridBagLayout1);
   jLabel1.setText("Profile Name : ");
   nameTextField.setMinimumSize(new Dimension(4, 18));
   nameTextField.setPreferredSize(new Dimension(63, 18));
   jLabel2.setText("Profile Type : ");
   openButton.setMaximumSize(new Dimension(73, 24));
   openButton.setMinimumSize(new Dimension(73, 24));
   openButton.setPreferredSize(new Dimension(73, 24));
   openButton.setText("Open");
   openButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           openButton_actionPerformed(e);
         }
       });
   cancelButton.setMaximumSize(new Dimension(73, 24));
   cancelButton.setMinimumSize(new Dimension(73, 24));
   cancelButton.setPreferredSize(new Dimension(73, 24));
   cancelButton.setMargin(new Insets(0, 5, 0, 5));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           cancelButton_actionPerformed(e);
         }
       });
   profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   profileList.addMouseListener(
       new java.awt.event.MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           profileList_mouseClicked(e);
         }
       });
   jPanel2.setBorder(border1);
   typeComboBox.setMaximumSize(new Dimension(32767, 18));
   typeComboBox.setMinimumSize(new Dimension(122, 18));
   typeComboBox.setPreferredSize(new Dimension(176, 18));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jScrollPane1, BorderLayout.CENTER);
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 7, 0),
           0,
           0));
   jPanel2.add(
       nameTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 7, 0),
           0,
           0));
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 17, 0),
           0,
           0));
   jScrollPane1.getViewport().add(profileList, null);
   jPanel2.add(
       openButton,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 2, 10),
           0,
           0));
   jPanel2.add(
       cancelButton,
       new GridBagConstraints(
           3,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 9, 10),
           0,
           0));
   jPanel2.add(
       typeComboBox,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 17, 0),
           0,
           0));
 }
  public GUI() {

    // Frame
    frame = new JFrame("HardwareSwap Notifier");

    // Panels
    panel = new JPanel();
    group1 = new JPanel();
    group2 = new JPanel();
    group3 = new JPanel();
    group4 = new JPanel();
    group5 = new JPanel();
    group6 = new JPanel();
    group7 = new JPanel();
    group8 = new JPanel();

    // Menu Bar
    menus = new JMenuBar();
    fileMenu = new JMenu("File");
    clearCurrent = new JMenuItem("Clear");
    quitItem = new JMenuItem("Quit");
    load = new JMenuItem("Load");
    saveCurrent = new JMenuItem("Save All");
    clearSaved = new JMenuItem("Clear Saved");
    removeItem = new JMenuItem("Remove Item");
    removePhone = new JMenuItem("Remove Phone");
    saveCurrent = new JMenuItem("Save Current");
    helpMenu = new JMenu("Help");
    help = new JMenuItem("How To Use");
    about = new JMenuItem("About");

    // Buttons
    add1 = new JButton("Add");
    add2 = new JButton("Add");
    start = new JButton("Start");
    stop = new JButton("Stop");
    save1 = new JButton("Add/Save");
    save2 = new JButton("Add/Save");
    show = new JButton("Display Data");

    add1.setFocusPainted(false);
    add2.setFocusPainted(false);
    start.setFocusPainted(false);
    stop.setFocusPainted(false);
    save1.setFocusPainted(false);
    save2.setFocusPainted(false);
    show.setFocusPainted(false);

    stop.setEnabled(false);

    // CheckBox
    remove = new JCheckBox("Remove items when found");
    remove.setFocusable(false);

    // Listener
    ButtonListener listener = new ButtonListener();

    add1.addActionListener(listener);
    add2.addActionListener(listener);
    start.addActionListener(listener);
    stop.addActionListener(listener);
    load.addActionListener(listener);
    save1.addActionListener(listener);
    save2.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    show.addActionListener(listener);
    quitItem.addActionListener(listener);
    clearCurrent.addActionListener(listener);
    clearSaved.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    help.addActionListener(listener);
    about.addActionListener(listener);
    removePhone.addActionListener(listener);
    removeItem.addActionListener(listener);
    remove.addActionListener(listener);

    // Carrier Selection
    options = new String[10];
    options[0] = "AT&T";
    options[1] = "Boost Mobile";
    options[2] = "Cellular One";
    options[3] = "Nextel";
    options[4] = "T-Mobile";
    options[5] = "Tracfone";
    options[6] = "US Cellular";
    options[7] = "Sprint";
    options[8] = "Verizon";
    options[9] = "Virgin Mobile";

    carriers = new JComboBox<String>(options);

    // Text Fields
    searchName = new JTextField(15);
    item = new JTextField(15);
    phone = new JTextField(15);
    interval2 = new JTextField(15);
    results = new JTextArea(10, 20);

    JScrollPane scrollPane = new JScrollPane(results);

    results.setEditable(false);

    // Interval
    intOptions = new SpinnerNumberModel(5, 1, 60, 1);
    interval = new JSpinner(intOptions);
    JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField();
    tf.setHorizontalAlignment(JFormattedTextField.LEFT);

    // Background
    panelBackground = new Color(237, 237, 237);

    panel.setBackground(panelBackground);
    searchName.setBackground(panelBackground);
    item.setBackground(panelBackground);
    phone.setBackground(panelBackground);
    interval.setBackground(panelBackground);

    // Panel Layouts
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS));
    group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS));
    group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS));
    group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS));
    group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS));
    group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS));
    group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS));
    group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS));

    // Borders
    searchName.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Search Name",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    item.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Item",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    phone.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Cell Phone",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    group5.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Check Interval (mins)",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));

    // Sizes
    panel.setPreferredSize(new Dimension(200, 0));
    searchName.setMaximumSize(new Dimension(190, 50));
    item.setMaximumSize(new Dimension(190, 50));
    phone.setMaximumSize(new Dimension(185, 50));
    carriers.setMaximumSize(new Dimension(175, 20));
    group5.setPreferredSize(new Dimension(190, 47));
    group5.setMaximumSize(new Dimension(190, 47));

    add1.setMaximumSize(new Dimension(90, 20));
    save1.setMaximumSize(new Dimension(90, 20));
    add2.setMaximumSize(new Dimension(90, 20));
    save2.setMaximumSize(new Dimension(90, 20));
    start.setMaximumSize(new Dimension(90, 20));
    stop.setMaximumSize(new Dimension(90, 20));
    show.setMaximumSize(new Dimension(120, 20));

    // Add file menu items
    fileMenu.add(clearCurrent);
    fileMenu.add(clearSaved);
    fileMenu.add(load);
    fileMenu.add(removeItem);
    fileMenu.add(removePhone);
    fileMenu.add(saveCurrent);
    fileMenu.add(quitItem);

    // Add help menu items
    helpMenu.add(help);
    helpMenu.add(about);

    // Add to menu bar
    menus.add(fileMenu);
    menus.add(helpMenu);

    // Add items to panel
    group1.add(searchName);
    group1.add(item);

    group2.add(add1);
    group2.add(Box.createHorizontalStrut(10));
    group2.add(save1);

    group6.add(remove);

    group3.add(phone);
    group3.add(Box.createVerticalStrut(10));
    group3.add(carriers);

    group4.add(add2);
    group4.add(Box.createHorizontalStrut(10));
    group4.add(save2);

    group5.add(interval);

    group7.add(show);

    group8.add(start);
    group8.add(Box.createHorizontalStrut(10));
    group8.add(stop);

    panel.add(Box.createVerticalStrut(10));
    panel.add(group1);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group2);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group3);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group4);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group5);
    panel.add(Box.createVerticalStrut(30));
    panel.add(group6);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group7);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group8);
    panel.add(Box.createVerticalStrut(10));

    // Setup frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menus);
    frame.add(scrollPane);
    frame.add(BorderLayout.EAST, panel);
    frame.pack();
    frame.setSize(new Dimension(670, 620));
    frame.setVisible(true);
  }
Example #7
0
  /**
   * Constructor
   *
   * @param game
   */
  public SwingView(Game game) {
    this.game = game;

    // get frame size
    this.size = game.getSize();
    this.side = size * 100;

    UIManager.getDefaults().put("Button.disabledText", Color.BLACK);

    // set size (the game field size + the status line size + the buttons panel)
    this.setSize(side, side + 20 + 30);

    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.setTitle("TicTacToe");

    // Create the main panel which will
    // contain all other panels
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    this.add(mainPanel);

    // The game status string
    JPanel status = new JPanel();
    status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
    status.setMaximumSize(new Dimension(side, 20));
    statusStr = new JLabel(game.getState().toString());

    status.add(statusStr);
    mainPanel.add(status);

    // The game field panel
    gameField = new JPanel();
    gameField.setSize(side, side);
    gameField.setLayout(new GridLayout(size, size));

    // Fill the game field with buttons
    for (int i = 0; i < size * size; i++) {
      gameField.add(createButton());
    }
    mainPanel.add(gameField);

    // The buttons panel
    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.setMaximumSize(new Dimension(side, 50));

    JButton restartBtn = new JButton();
    restartBtn.setMaximumSize(new Dimension(side, 50));
    restartBtn.setText("Restart");

    restartBtn.addActionListener(
        e -> {
          this.dispose();
          this.game = new Game();
          new SwingView(this.game);
        });

    buttons.add(restartBtn);
    mainPanel.add(buttons);

    this.setResizable(false);
    // Game window appears on center
    this.setLocationRelativeTo(null);
    this.setVisible(true);
  }
Example #8
0
  public final void createNotificationUI() {
    JButton createMasks = new JButton("Recreate Bathymetry Masks");
    createMasks.setPreferredSize(createMasks.getPreferredSize());
    createMasks.setMinimumSize(createMasks.getPreferredSize());
    createMasks.setMaximumSize(createMasks.getPreferredSize());

    createMasks.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            bathymetryData.setDeleteMasks(true);
            dispose();
          }
        });

    JButton cancelButton = new JButton("Cancel");
    cancelButton.setPreferredSize(cancelButton.getPreferredSize());
    cancelButton.setMinimumSize(cancelButton.getPreferredSize());
    cancelButton.setMaximumSize(cancelButton.getPreferredSize());

    cancelButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            dispose();
          }
        });

    JLabel filler = new JLabel("                            ");

    JPanel buttonsJPanel = new JPanel(new GridBagLayout());
    buttonsJPanel.add(
        cancelButton,
        new ExGridBagConstraints(0, 0, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));
    buttonsJPanel.add(
        filler,
        new ExGridBagConstraints(
            1, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL));
    buttonsJPanel.add(
        createMasks,
        new ExGridBagConstraints(2, 0, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE));
    buttonsJPanel.add(
        helpButton,
        new ExGridBagConstraints(3, 0, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE));

    JLabel jLabel = new JLabel("Bathymetry has already been created for this product");

    JPanel jPanel = new JPanel(new GridBagLayout());
    jPanel.add(
        jLabel,
        new ExGridBagConstraints(0, 0, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE));
    jPanel.add(
        buttonsJPanel,
        new ExGridBagConstraints(0, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE));

    add(jPanel);

    setModalityType(ModalityType.APPLICATION_MODAL);

    setTitle("Bathymetry");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    pack();

    setPreferredSize(getPreferredSize());
    setMinimumSize(getPreferredSize());
    setMaximumSize(getPreferredSize());
    setSize(getPreferredSize());
  }
Example #9
0
  public final void createBathymetryUI(boolean bandCreated) {

    final int rightInset = 5;

    final MaskEnabledAllBandsCheckbox maskEnabledAllBandsCheckbox =
        new MaskEnabledAllBandsCheckbox(bathymetryData);
    final MaskTransparencySpinner maskTransparencySpinner =
        new MaskTransparencySpinner(bathymetryData);
    final MaskColorComboBox maskColorComboBox = new MaskColorComboBox(bathymetryData);
    final MaskMaxDepthTextfield maskMaxDepthTextfield = new MaskMaxDepthTextfield(bathymetryData);
    final MaskMinDepthTextfield maskMinDepthTextfield = new MaskMinDepthTextfield(bathymetryData);

    final boolean[] fileSelectorEnabled = {true};

    if (bandCreated) {
      fileSelectorEnabled[0] = false;
    } else {
      fileSelectorEnabled[0] = true;
    }

    final ResolutionComboBox resolutionComboBox = new ResolutionComboBox(bathymetryData);

    JPanel resolutionSamplingPanel = new JPanel(new GridBagLayout());
    resolutionSamplingPanel.setBorder(BorderFactory.createTitledBorder(""));

    if (fileSelectorEnabled[0]) {
      resolutionSamplingPanel.add(
          resolutionComboBox.getjLabel(),
          new ExGridBagConstraints(
              0,
              0,
              0,
              0,
              GridBagConstraints.EAST,
              GridBagConstraints.NONE,
              new Insets(0, 0, 0, rightInset)));

      JComboBox jComboBox = resolutionComboBox.getjComboBox();
      jComboBox.setEnabled(fileSelectorEnabled[0]);

      bathymetryData.addPropertyChangeListener(
          BathymetryData.PROMPT_REQUEST_TO_INSTALL_FILE_EVENT,
          new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              SourceFileInfo sourceFileInfo =
                  (SourceFileInfo) resolutionComboBox.getjComboBox().getSelectedItem();

              InstallResolutionFileDialog dialog =
                  new InstallResolutionFileDialog(
                      bathymetryData,
                      sourceFileInfo,
                      InstallResolutionFileDialog.Step.INSTALLATION);
              dialog.setVisible(true);
              dialog.setEnabled(true);
            }
          });

      resolutionSamplingPanel.add(
          jComboBox,
          new ExGridBagConstraints(1, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));
    } else {
      resolutionSamplingPanel.add(
          new JLabel("Note: Cannot recreate a different band, only a different mask"),
          new ExGridBagConstraints(1, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));
    }

    JPanel maskJPanel = new JPanel(new GridBagLayout());
    maskJPanel.setBorder(BorderFactory.createTitledBorder(""));

    JTextField maskNameTextfield = new JTextField(bathymetryData.getMaskName());
    maskNameTextfield.setEditable(false);
    maskNameTextfield.setToolTipText("Name of the mask (this field is not editable)");

    maskJPanel.add(
        new JLabel("Mask Name"),
        new ExGridBagConstraints(
            0,
            0,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, rightInset)));

    maskJPanel.add(
        maskNameTextfield,
        new ExGridBagConstraints(1, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));

    maskJPanel.add(
        maskColorComboBox.getjLabel(),
        new ExGridBagConstraints(
            0,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, rightInset)));

    maskJPanel.add(
        maskColorComboBox.getColorExComboBox(),
        new ExGridBagConstraints(1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));

    maskJPanel.add(
        maskTransparencySpinner.getjLabel(),
        new ExGridBagConstraints(
            0,
            2,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, rightInset)));

    maskJPanel.add(
        maskTransparencySpinner.getjSpinner(),
        new ExGridBagConstraints(1, 2, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));

    maskJPanel.add(
        maskMaxDepthTextfield.getjLabel(),
        new ExGridBagConstraints(
            0,
            3,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, rightInset)));

    maskJPanel.add(
        maskMaxDepthTextfield.getjTextField(),
        new ExGridBagConstraints(1, 3, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));

    maskJPanel.add(
        maskMinDepthTextfield.getjLabel(),
        new ExGridBagConstraints(
            0,
            4,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, rightInset)));

    maskJPanel.add(
        maskMinDepthTextfield.getjTextField(),
        new ExGridBagConstraints(1, 4, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));

    maskJPanel.add(
        maskEnabledAllBandsCheckbox.getjLabel(),
        new ExGridBagConstraints(
            0,
            5,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, rightInset)));

    maskJPanel.add(
        maskEnabledAllBandsCheckbox.getjCheckBox(),
        new ExGridBagConstraints(1, 5, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));

    JPanel mainPanel = new JPanel(new GridBagLayout());

    mainPanel.add(
        resolutionSamplingPanel,
        new ExGridBagConstraints(
            0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 3));

    mainPanel.add(
        maskJPanel,
        new ExGridBagConstraints(
            0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 3));

    String label;
    if (bandCreated) {
      label = "Recreate Bathymetry Mask";
    } else {
      label = "Create Bathymetry Band and Mask";
    }
    JButton createMasks = new JButton(label);
    createMasks.setPreferredSize(createMasks.getPreferredSize());
    createMasks.setMinimumSize(createMasks.getPreferredSize());
    createMasks.setMaximumSize(createMasks.getPreferredSize());

    createMasks.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            bathymetryData.setCreateMasks(true);
            dispose();
          }
        });

    JButton cancelButton = new JButton("Cancel");
    cancelButton.setPreferredSize(cancelButton.getPreferredSize());
    cancelButton.setMinimumSize(cancelButton.getPreferredSize());
    cancelButton.setMaximumSize(cancelButton.getPreferredSize());

    cancelButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            dispose();
          }
        });

    JLabel filler = new JLabel("                            ");

    JPanel buttonsJPanel = new JPanel(new GridBagLayout());
    buttonsJPanel.add(
        cancelButton,
        new ExGridBagConstraints(0, 0, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE));
    buttonsJPanel.add(
        filler,
        new ExGridBagConstraints(
            1, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL));
    buttonsJPanel.add(
        createMasks,
        new ExGridBagConstraints(2, 0, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE));
    buttonsJPanel.add(
        helpButton,
        new ExGridBagConstraints(3, 0, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE));

    createMasks.setAlignmentX(0.5f);

    mainPanel.add(
        buttonsJPanel,
        new ExGridBagConstraints(0, 4, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, 5));

    add(mainPanel);

    setModalityType(ModalityType.APPLICATION_MODAL);

    setTitle("Bathymetry");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    pack();

    setPreferredSize(getPreferredSize());
    setMinimumSize(getPreferredSize());
    setMaximumSize(getPreferredSize());
    setSize(getPreferredSize());
  }
Example #10
0
  public SmartToolBar(RuntimeConfigFrame fr) {
    frame = fr;
    setFloatable(true);
    treeCombo = new TreeCombo(frame.model);
    treeCombo.addActionListener(new ComboListener());
    treeCombo.setPreferredSize(new Dimension(210, 25));
    treeCombo.setMinimumSize(new Dimension(210, 25));
    treeCombo.setMaximumSize(new Dimension(210, 25));
    add(treeCombo);
    addSeparator();
    addSeparator();
    addSeparator();

    ToolBarAction toolBarAction = new ToolBarAction();
    JButton saveAsButton = add(toolBarAction);
    ImageIcon icon =
        frame
            .getCommonBuilderUIImpl()
            .getScaledImage("file.png", "images/runtimeadmin", 28, 28, Image.SCALE_DEFAULT);
    saveAsButton.setPreferredSize(new Dimension(28, 28));
    saveAsButton.setMinimumSize(new Dimension(28, 28));
    saveAsButton.setMaximumSize(new Dimension(28, 28));
    saveAsButton.setBorderPainted(false);
    saveAsButton.setIcon(icon);
    icon =
        frame
            .getCommonBuilderUIImpl()
            .getScaledImage("file_mo.png", "images/runtimeadmin", 28, 28, Image.SCALE_DEFAULT);
    saveAsButton.setRolloverIcon(icon);
    saveAsButton.setActionCommand("Apply To Server");
    saveAsButton.setToolTipText(RuntimeConfigFrame.getString("Apply To Server"));
    addSeparator();

    JButton close = add(toolBarAction);
    icon =
        frame
            .getCommonBuilderUIImpl()
            .getScaledImage("exit.png", "images/", 28, 28, Image.SCALE_DEFAULT);
    close.setPreferredSize(new Dimension(28, 28));
    close.setMinimumSize(new Dimension(28, 28));
    close.setMaximumSize(new Dimension(28, 28));
    close.setIcon(icon);
    close.setBorderPainted(false);
    icon =
        frame
            .getCommonBuilderUIImpl()
            .getScaledImage("exit_mo.png", "images/", 28, 28, Image.SCALE_DEFAULT);
    close.setRolloverIcon(icon);
    close.setActionCommand("Close");
    close.setToolTipText(RuntimeConfigFrame.getString("Close"));
    addSeparator();

    JButton help = add(toolBarAction);
    icon =
        frame
            .getCommonBuilderUIImpl()
            .getScaledImage("toolhelp.png", "images/", 28, 28, Image.SCALE_DEFAULT);
    help.setPreferredSize(new Dimension(28, 28));
    help.setMinimumSize(new Dimension(28, 28));
    help.setMaximumSize(new Dimension(28, 28));
    help.setBorderPainted(false);
    help.setIcon(icon);

    icon =
        frame
            .getCommonBuilderUIImpl()
            .getScaledImage("toolhelp_mo.png", "images/", 28, 28, Image.SCALE_DEFAULT);
    help.setRolloverIcon(icon);
    help.setActionCommand("Help Contents");
    help.setToolTipText(RuntimeConfigFrame.getString("Help"));
    // addSeparator();

  }
Example #11
0
  private void jbInit() throws Exception {

    saveButton.setText("Save");
    saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this));
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this));
    this.setTitle(this.getTitle() + " Template Editor");
    printfPanel.setLayout(gridBagLayout1);
    formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    formatLabel.setText("Format String:");
    buttonPanel.setLayout(flowLayout1);
    printfPanel.setBorder(BorderFactory.createEtchedBorder());
    printfPanel.setMinimumSize(new Dimension(100, 160));
    printfPanel.setPreferredSize(new Dimension(380, 160));
    parameterPanel.setLayout(gridBagLayout2);
    parameterLabel.setText("Parameters:");
    parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    parameterTextArea.setMinimumSize(new Dimension(100, 25));
    parameterTextArea.setPreferredSize(new Dimension(200, 25));
    parameterTextArea.setEditable(true);
    parameterTextArea.setText("");
    insertButton.setMaximumSize(new Dimension(136, 20));
    insertButton.setMinimumSize(new Dimension(136, 20));
    insertButton.setPreferredSize(new Dimension(136, 20));
    insertButton.setToolTipText(
        "insert the format in the format string and add parameter to list.");
    insertButton.setText("Insert Parameter");
    insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this));
    formatTextArea.setMinimumSize(new Dimension(100, 25));
    formatTextArea.setPreferredSize(new Dimension(200, 15));
    formatTextArea.setText("");
    parameterPanel.setBorder(null);
    parameterPanel.setMinimumSize(new Dimension(60, 40));
    parameterPanel.setPreferredSize(new Dimension(300, 40));
    insertMatchButton.addActionListener(
        new PrintfTemplateEditor_insertMatchButton_actionAdapter(this));
    insertMatchButton.setText("Insert Match");
    insertMatchButton.setToolTipText(
        "insert the match in the format string and add parameter to list.");
    insertMatchButton.setPreferredSize(new Dimension(136, 20));
    insertMatchButton.setMinimumSize(new Dimension(136, 20));
    insertMatchButton.setMaximumSize(new Dimension(136, 20));
    matchPanel.setPreferredSize(new Dimension(300, 40));
    matchPanel.setBorder(null);
    matchPanel.setMinimumSize(new Dimension(60, 60));
    matchPanel.setLayout(gridBagLayout3);
    InsertPanel.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(0);
    InsertPanel.setBorder(BorderFactory.createEtchedBorder());
    InsertPanel.setMinimumSize(new Dimension(100, 100));
    InsertPanel.setPreferredSize(new Dimension(380, 120));
    editorPane.setText("");
    editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this));
    printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this));
    parameterPanel.add(
        insertButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    parameterPanel.add(
        paramComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    paramComboBox.setRenderer(new MyCellRenderer());
    InsertPanel.add(matchPanel, null);
    InsertPanel.add(parameterPanel, null);
    buttonPanel.add(cancelButton, null);
    buttonPanel.add(saveButton, null);
    this.getContentPane().add(printfTabPane, BorderLayout.NORTH);
    this.getContentPane().add(InsertPanel, BorderLayout.CENTER);
    matchPanel.add(
        insertMatchButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    matchPanel.add(
        matchComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    printfPanel.add(
        parameterLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(7, 5, 0, 5),
            309,
            0));
    printfPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(4, 5, 0, 5),
            288,
            0));
    printfPanel.add(
        formatTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 0, 5),
            300,
            34));
    printfPanel.add(
        parameterTextArea,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 6, 5),
            300,
            34));
    printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor");
    printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf");
    editorPane.setCharacterAttributes(PLAIN_ATTR, true);
    editorPane.addStyle("PLAIN", editorPane.getLogicalStyle());
    editorPanel.getViewport().add(editorPane, null);
    this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    buttonGroup.add(cancelButton);
  }
Example #12
0
  public SketchProperties(Editor e, Sketch s) {
    super();

    editor = e;
    sketch = s;

    fields = new HashMap<String, JComponent>();

    this.setPreferredSize(new Dimension(500, 400));
    this.setMinimumSize(new Dimension(500, 400));
    this.setMaximumSize(new Dimension(500, 400));
    this.setSize(new Dimension(500, 400));
    Point eLoc = editor.getLocation();
    int x = eLoc.x;
    int y = eLoc.y;

    Dimension eSize = editor.getSize();
    int w = eSize.width;
    int h = eSize.height;

    int cx = x + (w / 2);
    int cy = y + (h / 2);

    this.setLocation(new Point(cx - 250, cy - 200));
    this.setModal(true);

    outer = new JPanel(new BorderLayout());
    outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    this.add(outer);

    win = new JPanel();
    win.setLayout(new BorderLayout());
    outer.add(win, BorderLayout.CENTER);

    buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    saveButton = new JButton("OK");
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            save();
            SketchProperties.this.dispose();
          }
        });

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SketchProperties.this.dispose();
          }
        });

    buttonBar.add(saveButton);
    buttonBar.add(cancelButton);

    win.add(buttonBar, BorderLayout.SOUTH);

    tabs = new JTabbedPane();

    overviewPane = new JPanel();
    overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS));
    overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    addTextField(overviewPane, "author", "Sketch author:");
    addTextArea(overviewPane, "summary", "Summary:");
    addTextArea(overviewPane, "license", "Copyright / License:");
    tabs.add("Overview", overviewPane);

    objectsPane = new JPanel();
    objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS));
    objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    addTextField(objectsPane, "board", "Board:");
    addTextField(objectsPane, "core", "Core:");
    addTextField(objectsPane, "compiler", "Compiler:");
    addTextField(objectsPane, "port", "Serial port:");
    addTextField(objectsPane, "programmer", "Programmer:");
    JButton setDef = new JButton("Set to current IDE values");
    setDef.setMaximumSize(setDef.getPreferredSize());
    setDef.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setObjectValues();
          }
        });
    objectsPane.add(Box.createVerticalGlue());
    objectsPane.add(setDef);

    tabs.add("Objects", objectsPane);

    win.add(tabs, BorderLayout.CENTER);

    this.setTitle("Sketch Properties");

    this.pack();
    this.setVisible(true);
  }
Example #13
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
  public void initializeComponents(
      DiscountCardsTableModel tableModel, MessageSource messageSource, LocaleHolder localeHolder) {
    this.tableModel = tableModel;
    this.filters = new ArrayList<>();
    FiltersPurpose filtersPurpose = tableModel.getFiltersPurpose();

    FilterElementsListener filterElementsListener = new FilterElementsListener();

    //      panel for search operations
    filtersPanel = new JPanel();
    filtersPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                messageSource.getMessage(
                    "mainForm.panel.search.title", null, localeHolder.getLocale())),
            BorderFactory.createEmptyBorder()));
    filtersPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(1, 5, 1, 5);

    boolean allCardsPurpose = FiltersPurpose.ALL_DISCOUNT_CARDS == filtersPurpose;
    for (Field field : DiscountCardJdo.class.getDeclaredFields()) {
      FilterColumn filterColumn = field.getAnnotation(FilterColumn.class);
      if (filterColumn != null) {
        if (allCardsPurpose && filterColumn.showForAllDiscountCards()) {
          FilterUnit filterUnit = new FilterUnit();
          if (allCardsPurpose) {
            filterUnit.order = filterColumn.orderForAllDiscountCards();
          }

          filterUnit.order = filterUnit.order == 0 ? Integer.MAX_VALUE : filterUnit.order;
          filterUnit.filterType = filterColumn.type();
          filterUnit.columnTitle = getColumnTitle(field, messageSource, localeHolder);
          filterUnit.columnDatePattern = getColumnDatePattern(field);

          if (!filterColumn.labelKey().isEmpty()) {
            filterUnit.label =
                new JLabel(
                    messageSource.getMessage(
                        filterColumn.labelKey(), null, localeHolder.getLocale()));
            filterUnit.textField = new JTextField(filterColumn.editSize());
            filterUnit.textField.getDocument().addDocumentListener(filterElementsListener);
          }
          if (filterColumn.checkBoxesNumber() > 0) {
            filterUnit.checkBoxes = new JCheckBox[filterColumn.checkBoxesNumber()];
            for (int i = 0; i < filterColumn.checkBoxesNumber(); ++i) {
              String text =
                  messageSource.getMessage(
                      filterColumn.checkBoxesText()[i], null, localeHolder.getLocale());
              String actionCommand =
                  messageSource.getMessage(
                      filterColumn.checkBoxesAction()[i], null, localeHolder.getLocale());
              filterUnit.checkBoxes[i] = new JCheckBox(text);
              filterUnit.checkBoxes[i].setActionCommand(actionCommand);
              if (field.getName().equals("activationDate")) {
                filterUnit.checkBoxes[i].setSelected(true);
              } else {
                filterUnit.checkBoxes[i].setSelected(false);
              }
              filterUnit.checkBoxes[i].addItemListener(
                  new ItemListener() {
                    @Override
                    public void itemStateChanged(ItemEvent e) {
                      int state = e.getStateChange();
                      if (state == ItemEvent.SELECTED) {
                        applyFilters();
                        updateAnalyzeComponent();

                      } else if (state == ItemEvent.DESELECTED) {
                        applyFilters();
                        updateAnalyzeComponent();
                      }
                    }
                  });
            }
          }

          filters.add(filterUnit);
        }
      }
    }
    Collections.sort(
        filters,
        new Comparator<FilterUnit>() {
          @Override
          public int compare(FilterUnit filterUnit1, FilterUnit filterUnit2) {
            return filterUnit1.order - filterUnit2.order;
          }
        });
    for (int i = 0; i < filters.size(); ++i) {
      if (filters.get(i).label != null) {
        filters.get(i).label.setLabelFor(filters.get(i).textField);
        constraints.fill = GridBagConstraints.NONE;
        constraints.gridwidth = GridBagConstraints.RELATIVE;
        constraints.anchor = GridBagConstraints.EAST;
        constraints.weightx = 0.0;
        filtersPanel.add(filters.get(i).label, constraints);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.anchor = GridBagConstraints.EAST;
        constraints.weightx = 1.0;
        filtersPanel.add(filters.get(i).textField, constraints);
      } else if (filters.get(i).checkBoxes != null) {
        JPanel checkBoxPanel = new JPanel();
        checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.LINE_AXIS));
        checkBoxPanel.add(Box.createHorizontalGlue());
        for (int j = 0; j < filters.get(i).checkBoxes.length; ++j) {
          checkBoxPanel.add(filters.get(i).checkBoxes[j]);
          checkBoxPanel.add(Box.createHorizontalGlue());
        }
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.anchor = GridBagConstraints.EAST;
        constraints.weightx = 1.0;
        filtersPanel.add(checkBoxPanel, constraints);
      }
    }

    JButton clearSearchButton =
        new JButton(
            messageSource.getMessage(
                "mainForm.button.clear.title", null, localeHolder.getLocale()));
    clearSearchButton.setPreferredSize(new Dimension(500, 20));
    clearSearchButton.setMaximumSize(new Dimension(500, 20));
    clearSearchButton.setMinimumSize(new Dimension(500, 20));
    constraints.gridx = 1;
    constraints.gridy = filters.size() + 1;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.EAST;
    constraints.weightx = 1.0;
    clearSearchButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (FilterUnit filterUnit : filters) {
              if (filterUnit.label != null) {
                filterUnit.textField.setText("");
              } else if (filterUnit.checkBoxes != null) {
                for (int j = 0; j < filterUnit.checkBoxes.length; ++j) {
                  filterUnit.checkBoxes[j].setSelected(true);
                }
              }
            }
          }
        });
    filtersPanel.add(clearSearchButton, constraints);
    sorter = new TableRowSorter<>(tableModel);

    cardAnalyzeComponent.initializeComponents(tableModel, messageSource, localeHolder);
  }
    private void initComponents() {

      setPreferredSize(new java.awt.Dimension(420, 65));

      this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      JPanel textPanel = new JPanel();
      SpringLayout textLayout = new SpringLayout();
      textPanel.setLayout(textLayout);
      this.add(buttonPanel);
      this.add(textPanel);

      // button area
      abortButton_ = new JButton();
      abortButton_.setBackground(new java.awt.Color(255, 255, 255));
      abortButton_.setIcon(
          new javax.swing.ImageIcon(
              getClass().getResource("/org/micromanager/icons/cancel.png"))); // NOI18N
      abortButton_.setToolTipText("Abort acquisition");
      abortButton_.setFocusable(false);
      abortButton_.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
      abortButton_.setMaximumSize(new java.awt.Dimension(30, 28));
      abortButton_.setMinimumSize(new java.awt.Dimension(30, 28));
      abortButton_.setPreferredSize(new java.awt.Dimension(30, 28));
      abortButton_.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
      abortButton_.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              try {
                JavaUtils.invokeRestrictedMethod(vad_, VirtualAcquisitionDisplay.class, "abort");
              } catch (Exception ex) {
                ReportingUtils.showError(
                    "Couldn't abort. Try pressing stop on Multi-Dimensional acquisition Window");
              }
            }
          });
      buttonPanel.add(abortButton_);

      pauseButton_ = new JButton();
      pauseButton_.setIcon(
          new javax.swing.ImageIcon(
              getClass().getResource("/org/micromanager/icons/control_pause.png"))); // NOI18N
      pauseButton_.setToolTipText("Pause acquisition");
      pauseButton_.setFocusable(false);
      pauseButton_.setMargin(new java.awt.Insets(0, 0, 0, 0));
      pauseButton_.setMaximumSize(new java.awt.Dimension(30, 28));
      pauseButton_.setMinimumSize(new java.awt.Dimension(30, 28));
      pauseButton_.setPreferredSize(new java.awt.Dimension(30, 28));
      pauseButton_.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              try {
                JavaUtils.invokeRestrictedMethod(vad_, VirtualAcquisitionDisplay.class, "pause");
              } catch (Exception ex) {
                ReportingUtils.showError("Couldn't pause");
              }
              if (eng_.isPaused()) {
                pauseButton_.setIcon(
                    new javax.swing.ImageIcon(
                        getClass()
                            .getResource("/org/micromanager/icons/resultset_next.png"))); // NOI18N
              } else {
                pauseButton_.setIcon(
                    new javax.swing.ImageIcon(
                        getClass()
                            .getResource("/org/micromanager/icons/control_pause.png"))); // NOI18N
              }
            }
          });
      buttonPanel.add(pauseButton_);

      gridXSpinner_ = new JSpinner();
      gridXSpinner_.setModel(new SpinnerNumberModel(2, 1, 1000, 1));
      gridXSpinner_.setPreferredSize(new Dimension(35, 24));
      gridYSpinner_ = new JSpinner();
      gridYSpinner_.setModel(new SpinnerNumberModel(2, 1, 1000, 1));
      gridYSpinner_.setPreferredSize(new Dimension(35, 24));
      gridXSpinner_.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              gridSizeChanged();
            }
          });
      gridYSpinner_.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              gridSizeChanged();
            }
          });
      final JLabel gridLabel = new JLabel(" grid");
      final JLabel byLabel = new JLabel("by");
      gridLabel.setEnabled(false);
      byLabel.setEnabled(false);
      gridXSpinner_.setEnabled(false);
      gridYSpinner_.setEnabled(false);

      final JButton createGridButton = new JButton("Create");
      createGridButton.setEnabled(false);
      createGridButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              createGrid();
            }
          });

      newGridButton_ = new JToggleButton("New grid");
      buttonPanel.add(new JLabel("    "));
      buttonPanel.add(newGridButton_);
      newGridButton_.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              if (newGridButton_.isSelected()) {
                makeGridOverlay(
                    vad_.getImagePlus().getWidth() / 2, vad_.getImagePlus().getHeight() / 2);
                newGridButton_.setText("Cancel");
                gridLabel.setEnabled(true);
                byLabel.setEnabled(true);
                gridXSpinner_.setEnabled(true);
                gridYSpinner_.setEnabled(true);
                createGridButton.setEnabled(true);
              } else {
                vad_.getImagePlus().getOverlay().clear();
                vad_.getImagePlus().getCanvas().repaint();
                newGridButton_.setText("New grid");
                gridLabel.setEnabled(false);
                byLabel.setEnabled(false);
                gridXSpinner_.setEnabled(false);
                gridYSpinner_.setEnabled(false);
                createGridButton.setEnabled(false);
              }
            }
          });

      buttonPanel.add(gridXSpinner_);
      buttonPanel.add(byLabel);
      buttonPanel.add(gridYSpinner_);
      buttonPanel.add(gridLabel);
      buttonPanel.add(createGridButton);

      // text area
      zPosLabel_ = new JLabel("Z position:                    ");
      textPanel.add(zPosLabel_);

      timeStampLabel_ = new JLabel("Elapsed time:                               ");
      textPanel.add(timeStampLabel_);

      fpsField_ = new JTextField();
      fpsField_.setText("7");
      fpsField_.setToolTipText("Set the speed at which the acquisition is played back.");
      fpsField_.setPreferredSize(new Dimension(25, 18));
      fpsField_.addFocusListener(
          new java.awt.event.FocusAdapter() {

            public void focusLost(java.awt.event.FocusEvent evt) {
              updateFPS();
            }
          });
      fpsField_.addKeyListener(
          new java.awt.event.KeyAdapter() {

            public void keyReleased(java.awt.event.KeyEvent evt) {
              updateFPS();
            }
          });
      JLabel fpsLabel = new JLabel("Animation playback FPS: ");
      textPanel.add(fpsLabel);
      textPanel.add(fpsField_);

      textLayout.putConstraint(SpringLayout.WEST, textPanel, 0, SpringLayout.WEST, zPosLabel_);
      textLayout.putConstraint(
          SpringLayout.EAST, zPosLabel_, 0, SpringLayout.WEST, timeStampLabel_);
      textLayout.putConstraint(SpringLayout.EAST, timeStampLabel_, 0, SpringLayout.WEST, fpsLabel);
      textLayout.putConstraint(SpringLayout.EAST, fpsLabel, 0, SpringLayout.WEST, fpsField_);
      textLayout.putConstraint(SpringLayout.EAST, fpsField_, 0, SpringLayout.EAST, textPanel);

      textLayout.putConstraint(SpringLayout.NORTH, fpsField_, 0, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, zPosLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(
          SpringLayout.NORTH, timeStampLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, fpsLabel, 3, SpringLayout.NORTH, textPanel);
    }
  /** Create GUI elements */
  private void loadGUI() {
    setTitle("Wifi QRCode Generator");

    mainPanel = new JPanel();
    BoxLayout vBoxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
    mainPanel.setLayout(vBoxLayout);

    int LABEL_WIDTH = 100;
    int LABEL_HEIGHT = 30;

    int EDIT_WIDTH = 200;
    int EDIT_HEIGHT = 30;

    // guide label
    {
      // This layout simply makes label looks left-alignmented
      JPanel barPanel = new JPanel();
      BoxLayout barHLayout = new BoxLayout(barPanel, BoxLayout.X_AXIS);
      barPanel.setLayout(barHLayout);

      JLabel ssoGuideLabel = new JLabel("Enter your SSO and click button below to login");
      ssoGuideLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15));
      barPanel.add(ssoGuideLabel);
      mainPanel.add(barPanel);
    }

    Font gFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13);

    Config config = Config.instance();

    // email password remember password
    {
      JPanel userPanel = new JPanel();
      BoxLayout hBoxLayout = new BoxLayout(userPanel, BoxLayout.X_AXIS);
      userPanel.setLayout(hBoxLayout);
      JLabel emailLabel = new JLabel("Email:");
      Dimension labelDimension = new Dimension(LABEL_WIDTH, LABEL_HEIGHT);
      emailLabel.setMinimumSize(labelDimension);
      emailLabel.setPreferredSize(labelDimension);
      emailLabel.setMaximumSize(labelDimension);
      userPanel.add(emailLabel);
      userPanel.add(Box.createRigidArea(new Dimension(5, 0)));
      emailField = new TextField();
      emailField.setMinimumSize(new Dimension(EDIT_WIDTH, EDIT_HEIGHT));
      emailField.setMaximumSize(new Dimension(EDIT_WIDTH + 300, EDIT_HEIGHT));
      emailField.setFont(gFont);
      emailField.setText(config.getEmail());

      userPanel.add(emailField);

      mainPanel.add(userPanel);

      JPanel passwordPanel = new JPanel();
      BoxLayout hBoxLayout2 = new BoxLayout(passwordPanel, BoxLayout.X_AXIS);
      passwordPanel.setLayout(hBoxLayout2);
      JLabel passwordLabel = new JLabel("SSO Password:"******"Remember password", false);
      rememberPasswordCheckbox.setState(config.getRememberPassword());

      mainPanel.add(rememberPasswordCheckbox);
      mainPanel.add(Box.createHorizontalGlue());
    }

    JPanel centerPanel = new JPanel();
    BorderLayout bLayout = new BorderLayout();
    centerPanel.setLayout(bLayout);

    buttonGetPassword = new JButton(idleButtonText);
    Font font = new Font(Font.SERIF, Font.BOLD, 18);
    buttonGetPassword.setFont(font);
    buttonGetPassword.setMinimumSize(new Dimension(300, 50));
    buttonGetPassword.setPreferredSize(new Dimension(300, 50));
    buttonGetPassword.setMaximumSize(new Dimension(300, 50));

    centerPanel.add(buttonGetPassword, BorderLayout.CENTER);

    hintLabel = new JLabel("Enter your SSO and click button to start");
    hintLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15));

    centerPanel.add(hintLabel, BorderLayout.SOUTH);
    mainPanel.add(centerPanel);

    wifiPasswordField = new TextField("Wifi password has not been generated");
    mainPanel.add(wifiPasswordField);

    JPanel qrCenterPanel = new JPanel();
    BorderLayout bLayout2 = new BorderLayout();
    qrCenterPanel.setLayout(bLayout2);
    qrCodeLabel = new JLabel("");
    qrCodeLabel.setMinimumSize(new Dimension(400, 400));
    qrCodeLabel.setPreferredSize(new Dimension(400, 400));
    qrCodeLabel.setMaximumSize(new Dimension(400, 400));
    qrCodeLabel.setHorizontalAlignment(JLabel.CENTER);
    qrCodeLabel.setVerticalAlignment(JLabel.CENTER);
    qrCodeLabel.setIcon(idleIcon);

    qrCenterPanel.add(qrCodeLabel, BorderLayout.CENTER);
    mainPanel.add(qrCenterPanel);

    // client download section
    {
      Font clientFont = new Font(Font.SANS_SERIF, Font.BOLD, 15);
      Dimension clientDimension = new Dimension(200, 30);
      JPanel clientPanel = new JPanel();
      BorderLayout cp_bLayout = new BorderLayout();
      clientPanel.setLayout(cp_bLayout);
      HyberLinkLabel androidLabel =
          new HyberLinkLabel(
              " [ Android Client ] ",
              "https://github.com/tangyanhan/ClrGstAutoLogin-/blob/master/ClrGstAutoConnect/bin/ClrGstAutoConnect.apk");
      androidLabel.setMinimumSize(clientDimension);
      androidLabel.setFont(clientFont);
      clientPanel.add(androidLabel, BorderLayout.WEST);

      HyberLinkLabel iosLabel = new HyberLinkLabel(" [ iOS Client ] ", "");
      iosLabel.setMinimumSize(clientDimension);
      iosLabel.setFont(clientFont);
      clientPanel.add(iosLabel, BorderLayout.EAST);

      mainPanel.add(clientPanel);
    }

    add(mainPanel);

    this.pack();
    this.setVisible(true);
    this.setLocation(300, 100);
    this.setSize(500, 730);

    buttonGetPassword.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            long elapsed = Calendar.getInstance().getTimeInMillis() - lastClickTime;

            // If we got the successfull password 5 minutes ago
            if (((elapsed / 1000) / 60) < 5) {
              hintLabel.setText("Take a rest! You have got the QR code already!");
              return;
            }

            fetchPassword();

            if (!Config.instance().getWifiPassword().isEmpty())
              lastClickTime = Calendar.getInstance().getTimeInMillis();
          }
        });
  }
Example #17
0
  /** Initialize the common user interface components. */
  private void initUI() {
    /* initialize fields */
    {
      pFileSeqPanels = new TreeMap<FileSeq, JFileSeqPanel>();
    }

    /* initialize the popup menus */
    {
      initBasicMenus(true, false);
      updateMenuToolTips();
    }

    /* initialize the panel components */
    {
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      /* header */
      {
        pApplyToolTipText = "Replace the working area files with the selected checked-in files.";
        pUnApplyToolTipText = "There are no unsaved changes to Apply at this time.";

        JPanel panel = initHeader(true);
        add(panel);
      }

      add(Box.createRigidArea(new Dimension(0, 4)));

      /* full node name */
      {
        LinkedList<Component> extra = new LinkedList<Component>();
        extra.add(Box.createRigidArea(new Dimension(4, 0)));
        {
          JButton btn = new JButton();
          pSeqLayoutButton = btn;
          btn.setName(pIsListLayout ? "ListLayoutButton" : "TabbedLayoutButton");

          Dimension size = new Dimension(19, 19);
          btn.setMinimumSize(size);
          btn.setMaximumSize(size);
          btn.setPreferredSize(size);

          btn.setActionCommand("seq-layout-changed");
          btn.addActionListener(this);

          extra.add(btn);
        }

        initNameField(this, extra);

        pNodeNameField.setFocusable(true);
        pNodeNameField.addKeyListener(this);
        pNodeNameField.addMouseListener(this);
      }

      add(Box.createRigidArea(new Dimension(0, 4)));

      {
        JTabbedPane tab = new JTabbedPane();
        pFileSeqsTab = tab;
        tab.setVisible(!pIsListLayout);
        add(tab);
      }

      {
        Box vbox = new Box(BoxLayout.Y_AXIS);
        pFileSeqsBox = vbox;

        {
          JScrollPane scroll = UIFactory.createVertScrollPane(vbox);
          pFileSeqsScroll = scroll;
          scroll.setVisible(!pIsListLayout);

          add(scroll);
        }
      }

      Dimension size = new Dimension(sSize + 22, 120);
      setMinimumSize(size);
      setPreferredSize(size);

      setFocusable(true);
      addKeyListener(this);
      addMouseListener(this);
    }

    updateNodeStatus(null, null, null);
  }