private void setPointButtonAction() {
    JButton button = calculator.getButtonPoint();
    Action action =
        new AbstractAction("colonAction") {
          @Override
          public void actionPerformed(ActionEvent e) {
            appendTextInCalculatorDisplay(".");
          }
        };

    // Shortcut al punto normal
    action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, 0));
    button.getActionMap().put("colonAction", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "colonAction");

    // Shortcut al punto del numpad
    action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DECIMAL, 0));
    button.getActionMap().put("colonAction", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "colonAction");

    button.addActionListener(action);
  }
  private void setMinusButtonAction() {
    JButton button = calculator.getButtonMinus();
    Action action =
        new AbstractAction("buttonMinusAction") {
          @Override
          public void actionPerformed(ActionEvent e) {
            appendTextInCalculatorDisplay("-");
          }
        };

    // Shortcut al menos del numpad
    action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0));
    button.getActionMap().put("buttonMinusAction", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "buttonMinusAction");

    // Shortcut al guion alto
    action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0));
    button.getActionMap().put("buttonMinusAction", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "buttonMinusAction");
    button.addActionListener(action);
  }
  private void setButtonAction(JButton button, final String key) {

    Action action =
        new AbstractAction("button" + key + "Action") {
          @Override
          public void actionPerformed(ActionEvent e) {
            appendTextInCalculatorDisplay(key.toLowerCase());
          }
        };

    // Shortcuts a los numeros comunes
    action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(key));
    button.getActionMap().put("button" + key + "Action", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "button" + key + "Action");

    // Shortcuts a los del numpad
    if (getNumpadVk(key) != null) {
      action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(getNumpadVk(key), 0));
      button.getActionMap().put("button" + key + "Action", action);
      button
          .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
          .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "button" + key + "Action");
    }

    button.addActionListener(action);
  }
Ejemplo n.º 4
0
  /**
   * A very basic dialogue creator. This allows for greater customization like setting modality.
   *
   * @param owner The owner
   * @param minSize The minimum size
   * @param title The title
   * @param message The message to display
   * @param option The options - i.e. the buttons added defined by {@link JDialog} option types.
   *     Currently only {@link JOptionPane#OK_OPTION} is supported.
   * @param icon The icon to display
   * @param modalityType The modality type @see ModalityType
   */
  private void showDialouge(
      Window owner,
      Dimension minSize,
      String title,
      String message,
      int option,
      Icon icon,
      ModalityType modalityType) {
    final JDialog d = new JDialog(owner, title, modalityType);
    d.setLayout(new BorderLayout());
    d.setSize(minSize);
    d.setMinimumSize(minSize);
    // set the dialouge's location to be centred at the centre of it's owner
    d.setLocation(
        ((owner.getX() + owner.getWidth()) / 2) - d.getWidth() / 2,
        ((owner.getY() + owner.getHeight()) / 2) - d.getHeight() / 2);
    JLabel l = new JLabel(message, icon, SwingConstants.CENTER);
    // Add dialogue's text containing children for text recolouring
    l.setForeground(survivor.getCurrentColourScheme().getReadableText());
    complementaryAmenableForegroundColourableComponents.add(l);
    d.add(l, BorderLayout.CENTER);

    if (option == JOptionPane.OK_OPTION) {
      JButton ok = new JButton("OK");
      // make the button respond when ENTER is pressed
      ok.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "pressed");
      ok.getInputMap().put(KeyStroke.getKeyStroke("released ENTER"), "released");
      // Add dialogue's text containing children for text recolouring
      complementaryAmenableForegroundColourableComponents.add(ok);
      ok.setForeground(survivor.getCurrentColourScheme().getReadableText());
      ok.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
              d.dispose();
            }
          });

      d.add(ok, BorderLayout.PAGE_END);
    }

    //		d.setBackground(hangman.currentColourScheme.getC3());
    // The dialogue is included in the below sets for proper colouring
    backgroundColourableComponents.add(d);

    d.setVisible(true);
  }
Ejemplo n.º 5
0
  public void showLoginDialog() throws UnknownHostException {
    JOptionPane pane = new JOptionPane();
    LoginDialog dialog = new LoginDialog();
    pane.setMessage(dialog);

    JButton ok = new JButton("Ok");
    ok.addActionListener(new OkAction(pane, dialog));

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new OkAction(pane, dialog));

    pane.setOptions(new JButton[] {ok});

    JDialog dlg = pane.createDialog(parent, "Connect");
    dlg.setVisible(true);
  }
  private void setButtonCopyAction() {
    JButton button = calculator.getButtonCopy();
    Action action =
        new AbstractAction("buttonCopyAction") {
          @Override
          public void actionPerformed(ActionEvent e) {
            calculator.getDisplay().selectAll();
            calculator.getDisplay().copy();
          }
        };
    // Shortcut a control+c
    action.putValue(
        Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
    button.getActionMap().put("buttonCopyAction", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "buttonCopyAction");

    button.addActionListener(action);
  }
  private void setButtonClearAction() {

    JButton button = calculator.getButtonClear();
    Action action =
        new AbstractAction("buttonClearAction") {
          @Override
          public void actionPerformed(ActionEvent e) {
            calculator.setDisplayText("");
            if (calculator.getActualMode() == CalculatorModes.ERROR_MODE) {
              calculator.reset();
              calculator.setDecMode();
            }
          }
        };

    // Shorcut al space
    action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0));
    button.getActionMap().put("buttonClearAction", action);
    button
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "buttonClearAction");

    button.addActionListener(action);
  }
Ejemplo n.º 8
0
  /** creating GUI, partially using parameters from the shape passed in the constructor */
  private void createGUI() {
    // initializing
    JPanel main = new JPanel(new BorderLayout());
    JPanel middle = new JPanel(new GridLayout(6, 1, 10, 10));
    JPanel bottom = new JPanel();
    JLabel manual = new JLabel("Edit the information of your shape:");
    JLabel hrefDesc = new JLabel("Enter the link it should lead to:");
    hrefDesc.setLabelFor(href);
    JLabel titleDesc = new JLabel("Enter the tootlip which should be shown:");
    titleDesc.setLabelFor(title);
    JLabel altDesc = new JLabel("Enter alternative text:");
    altDesc.setLabelFor(alt);
    JButton ok = new JButton("Save");
    JButton cancel = new JButton("Cancel");

    // assembling
    middle.add(hrefDesc, BorderLayout.NORTH);
    middle.add(href, BorderLayout.SOUTH);
    middle.add(altDesc, BorderLayout.NORTH);
    middle.add(alt, BorderLayout.SOUTH);
    middle.add(titleDesc, BorderLayout.NORTH);
    middle.add(title, BorderLayout.SOUTH);
    middle.setBorder(new EmptyBorder(10, 10, 10, 10));
    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            doSave();
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    KeyStroke keySave = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    Action performSave =
        new AbstractAction("Save") {
          private static final long serialVersionUID = 1L;

          public void actionPerformed(ActionEvent e) {
            doSave();
          }
        };
    ok.getActionMap().put("performSave", performSave);
    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keySave, "performSave");

    KeyStroke keyExit = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    Action performExit =
        new AbstractAction("Exit") {
          private static final long serialVersionUID = 1L;

          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        };
    cancel.getActionMap().put("performExit", performExit);
    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyExit, "performExit");
    bottom.add(ok);
    bottom.add(cancel);
    main.add(manual, BorderLayout.NORTH);
    main.add(middle, BorderLayout.CENTER);
    main.add(bottom, BorderLayout.SOUTH);
    main.setBorder(new EmptyBorder(10, 10, 10, 10));

    // finalizing
    href.setText(shape.getHref());
    alt.setText(shape.getAlt());
    title.setText(shape.getTooltip());
    this.setSize(300, 400);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
    this.add(main);
  }
  /**
   * ************************************************************ The above feature improvement was
   * made by Gang Shu on February 7, 2014
   * ************************************************************
   */
  private void initUI() {
    this.setSize(new Dimension(dialogWidth, dialogHeight));

    srcFilesDirField = createTextField();
    srcFilesDirField.setEditable(false);
    srcFilesDirField.addMouseListener(new BrowseSourceFilesBtnListener());

    workingDirField = createTextField();
    workingDirField.setEditable(true);
    workingDirField.addMouseListener(new BrowseWorkingDirButtonListener());

    buildSelectedFileCountLabel();

    srcFilesBrowseBtn = new JButton("Browse...");
    srcFilesBrowseBtn.addActionListener(new BrowseSourceFilesBtnListener());

    outputDirBrowseBtn = new JButton("Browse...");
    outputDirBrowseBtn.addActionListener(new BrowseWorkingDirButtonListener());

    finishButton = new JButton("Finish");
    vfbListener = new ValidateFinishButtonListener();
    finishButton.addActionListener(vfbListener);
    //        finishButton.addActionListener(new ValidateFinishButtonListener());

    cancelButton = new JButton("Cancel");
    InputMap im = cancelButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap am = cancelButton.getActionMap();
    im.put(KeyStroke.getKeyStroke("ESCAPE"), "Cancel");
    am.put("Cancel", new CancelAction());

    cancelButton.addActionListener(new CancelButtonListener());

    fileRadio = new JRadioButton("File Selections");
    fileRadio.setSelected(false);
    fileRadio.setToolTipText("select one or multiple EDF source files");
    fileRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (dirMode == true) {
              enableOutputDirPanel(false);
              resetActiveAreas();
              dirMode = false;
            }
          }
        });

    dirRadio = new JRadioButton("Directory");
    dirRadio.setSelected(true);
    dirRadio.setToolTipText("select a source directory of EDF files");
    dirRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (dirMode == false) enableOutputDirPanel(false);
            resetActiveAreas();
            dirMode = true;
          }
        });

    yesOverwriteRadio = new JRadioButton("Yes");
    yesOverwriteRadio.setToolTipText("overwrite source files");
    yesOverwriteRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputDirBrowseBtn.setEnabled(false);
            workingDirField.setEnabled(false);
            overwriteMode = true;
            MainWindow.setWriteMode(MainWindow.overwrite_mode);
            repaint();
          }
        });

    // noOverrideRadio = new JRadioButton("Save Changes to New Directory");
    noOverwriteRadio = new JRadioButton("No");
    noOverwriteRadio.setToolTipText("duplicate source files to new directory");
    noOverwriteRadio.setSelected(true);
    /** Bugfix to default write mode. (Mar. 5, 2014) */
    MainWindow.setWriteMode(MainWindow.duplicate_mode);
    /** Bugfix to default write mode. (Mar. 5, 2014) */
    noOverwriteRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputDirBrowseBtn.setEnabled(true);
            workingDirField.setEnabled(true);
            if (workingDirectory != null) workingDirField.setText(workingDirectory.toString());
            overwriteMode = false;
            MainWindow.setWriteMode(MainWindow.duplicate_mode);

            repaint();
          }
        });
    enableOutputDirPanel(false);
    finishButton.setEnabled(false);
    // disable finish button until source and output have been chosen. -- Fangping, 08/03/2010
  }
Ejemplo n.º 10
0
  public ReverseFlashCard() {
    // basic init
    setTitle("WayMemo -Reverse Flash Card Mode");
    this.setSize(800, 600);
    paneCenter = new JPanel(new GridLayout(7, 1));

    add(ln, "North");
    add(paneCenter, "Center");
    add(b2, "West");
    add(bReset, "South");
    add(b1, "East");
    paneCenter.add(l1);
    paneCenter.add(l2);
    paneCenter.add(l3);
    paneCenter.add(l4);
    paneCenter.add(l5);
    paneCenter.add(b3);
    paneCenter.add(pMark);
    pMark.add(bMark);
    pMark.add(bUnMark);
    pMark.add(lt);

    // text area init

    Utility.initTextAreaView(l1);
    Utility.initTextAreaView(l2);
    Utility.initTextAreaView(l3);
    Utility.initTextAreaView(l4);
    Utility.initTextAreaView(l5);

    // action

    //
    Action actionNext =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            num++;
            wordDisplay();
          }
        };
    b1.getInputMap().put(KeyStroke.getKeyStroke("C"), "pressed");
    b1.getActionMap().put("released", actionNext);
    //
    Action actionBack =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            num--;
            wordDisplay();
          }
        };
    b2.getInputMap().put(KeyStroke.getKeyStroke("Z"), "pressed");
    b2.getActionMap().put("released", actionBack);
    //
    Action actionShow =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            l1.setText(dtr[num]);
            l3.setText(d2[num]);
            l4.setText(d3[num]);
            l5.setText(d4[num]);
          }
        };
    b3.getInputMap().put(KeyStroke.getKeyStroke("X"), "pressed");
    b3.getActionMap().put("released", actionShow);
    //
    //
    Action actionMark =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            d1[num] = "[MARKED*]" + d1[num];
            l2.setText(d1[num]);
          }
        };
    bMark.getInputMap().put(KeyStroke.getKeyStroke("S"), "pressed");
    bMark.getActionMap().put("released", actionMark);
    //
    //
    //
    Action actionUnmark =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            d1[num] = od1[num];
            l2.setText(d1[num]);
          }
        };
    bUnMark.getInputMap().put(KeyStroke.getKeyStroke("F2"), "pressed");
    bUnMark.getActionMap().put("released", actionUnmark);
    //
    //
    Action actionReset =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            num = 0;
            wordDisplay();
          }
        };
    bReset.getInputMap().put(KeyStroke.getKeyStroke("r"), "pressed");
    bReset.getActionMap().put("released", actionReset);
    //
    //
    b1.setMnemonic(KeyEvent.VK_C);
    b2.setMnemonic(KeyEvent.VK_Z);
    b3.setMnemonic(KeyEvent.VK_X);
    bMark.setMnemonic(KeyEvent.VK_S);
    bUnMark.setMnemonic(KeyEvent.VK_D);
    bReset.setMnemonic(KeyEvent.VK_R);

    b1.addActionListener(actionNext);
    b2.addActionListener(actionBack);
    b3.addActionListener(actionShow);
    bReset.addActionListener(actionReset);
    bMark.addActionListener(actionMark);
    bUnMark.addActionListener(actionUnmark);
    //
    //
    try {
      this.fileScan(new OpenFileDTR().getPathDTR());
    } catch (IOException e) {
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 11
0
  private void initComponents() {
    getContentPane().setLayout(new BorderLayout());

    jlFirst = new JLabel(res.getString("DGetNewPassword.jlFirst.text"));
    GridBagConstraints gbc_jlFirst = new GridBagConstraints();
    gbc_jlFirst.gridx = 0;
    gbc_jlFirst.gridy = 0;
    gbc_jlFirst.anchor = GridBagConstraints.EAST;
    gbc_jlFirst.insets = new Insets(5, 5, 5, 5);

    jlConfirm = new JLabel(res.getString("DGetNewPassword.jlConfirm.text"));
    GridBagConstraints gbc_jpfFirst = new GridBagConstraints();
    gbc_jpfFirst.gridx = 1;
    gbc_jpfFirst.gridy = 0;
    gbc_jpfFirst.anchor = GridBagConstraints.WEST;
    gbc_jpfFirst.insets = new Insets(5, 5, 5, 5);

    if (passwordQualityConfig.getEnabled()) {
      if (passwordQualityConfig.getEnforced()) {
        jpfFirst = new JPasswordQualityField(15, passwordQualityConfig.getMinimumQuality());
      } else {
        jpfFirst = new JPasswordQualityField(15);
      }
    } else {
      jpfFirst = new JPasswordField(15);
    }

    GridBagConstraints gbc_jlConfirm = new GridBagConstraints();
    gbc_jlConfirm.gridx = 0;
    gbc_jlConfirm.gridy = 1;
    gbc_jlConfirm.anchor = GridBagConstraints.EAST;
    gbc_jlConfirm.insets = new Insets(5, 5, 5, 5);

    jpfConfirm = new JPasswordField(15);
    GridBagConstraints gbc_jpfConfirm = new GridBagConstraints();
    gbc_jpfConfirm.gridx = 1;
    gbc_jpfConfirm.gridy = 1;
    gbc_jpfConfirm.anchor = GridBagConstraints.WEST;
    gbc_jpfConfirm.insets = new Insets(5, 5, 5, 5);

    jpPassword = new JPanel(new GridBagLayout());
    jpPassword.add(jlFirst, gbc_jlFirst);
    jpPassword.add(jpfFirst, gbc_jpfFirst);

    jpPassword.add(jlConfirm, gbc_jlConfirm);
    jpPassword.add(jpfConfirm, gbc_jpfConfirm);
    jpPassword.setBorder(
        new CompoundBorder(
            new EmptyBorder(5, 5, 5, 5),
            new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));

    jbOK = new JButton(res.getString("DGetNewPassword.jbOK.text"));
    jbOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            okPressed();
          }
        });

    jbCancel = new JButton(res.getString("DGetNewPassword.jbCancel.text"));
    jbCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            cancelPressed();
          }
        });
    jbCancel
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel
        .getActionMap()
        .put(
            CANCEL_KEY,
            new AbstractAction() {
              public void actionPerformed(ActionEvent evt) {
                cancelPressed();
              }
            });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);

    getContentPane().add(jpPassword, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            closeDialog();
          }
        });

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();

    // fix for focus issues: request focus after dialog was made visible
    jpfFirst.addAncestorListener(
        new AncestorListener() {
          @Override
          public void ancestorRemoved(AncestorEvent event) {}

          @Override
          public void ancestorMoved(AncestorEvent event) {}

          @Override
          public void ancestorAdded(AncestorEvent event) {
            JComponent component = event.getComponent();
            component.requestFocusInWindow();
          }
        });
  }
Ejemplo n.º 12
0
 private void setKeyAcceleratorButton(
     JButton b, AbstractAction act, String actionName, int keyCode, int mask) {
   KeyStroke ks = KeyStroke.getKeyStroke(keyCode, mask);
   b.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ks, actionName);
   b.getActionMap().put(actionName, act);
 }
  private void initComponents(GeneralSubtree generalSubtree) {
    jlBase = new JLabel(res.getString("DGeneralSubtreeChooser.jlBase.text"));

    GridBagConstraints gbc_jlBase = new GridBagConstraints();
    gbc_jlBase.gridx = 0;
    gbc_jlBase.gridy = 0;
    gbc_jlBase.gridwidth = 1;
    gbc_jlBase.gridheight = 1;
    gbc_jlBase.insets = new Insets(5, 5, 0, 5);
    gbc_jlBase.anchor = GridBagConstraints.EAST;

    jgnBase = new JGeneralName(res.getString("DGeneralSubtreeChooser.Base.Title"));
    jgnBase.setToolTipText(res.getString("DGeneralSubtreeChooser.jgnBase.tooltip"));

    GridBagConstraints gbc_jgnBase = new GridBagConstraints();
    gbc_jgnBase.gridx = 1;
    gbc_jgnBase.gridy = 0;
    gbc_jgnBase.gridwidth = 1;
    gbc_jgnBase.gridheight = 1;
    gbc_jgnBase.insets = new Insets(5, 5, 0, 5);
    gbc_jgnBase.anchor = GridBagConstraints.WEST;

    jlMinimum = new JLabel(res.getString("DGeneralSubtreeChooser.jlMinimum.text"));

    GridBagConstraints gbc_jlMinimum = new GridBagConstraints();
    gbc_jlMinimum.gridx = 0;
    gbc_jlMinimum.gridy = 1;
    gbc_jlMinimum.gridwidth = 1;
    gbc_jlMinimum.gridheight = 1;
    gbc_jlMinimum.insets = new Insets(5, 5, 5, 5);
    gbc_jlMinimum.anchor = GridBagConstraints.EAST;

    jtfMinimum = new JTextField(3);
    jtfMinimum.setToolTipText(res.getString("DGeneralSubtreeChooser.jtfMinimum.tooltip"));

    GridBagConstraints gbc_jtfMinimum = new GridBagConstraints();
    gbc_jtfMinimum.gridx = 1;
    gbc_jtfMinimum.gridy = 1;
    gbc_jtfMinimum.gridwidth = 1;
    gbc_jtfMinimum.gridheight = 1;
    gbc_jtfMinimum.insets = new Insets(5, 5, 5, 5);
    gbc_jtfMinimum.anchor = GridBagConstraints.WEST;

    jlMaximum = new JLabel(res.getString("DGeneralSubtreeChooser.jlMaximum.text"));

    GridBagConstraints gbc_jlMaximum = new GridBagConstraints();
    gbc_jlMaximum.gridx = 0;
    gbc_jlMaximum.gridy = 2;
    gbc_jlMaximum.gridwidth = 1;
    gbc_jlMaximum.gridheight = 1;
    gbc_jlMaximum.insets = new Insets(5, 5, 5, 5);
    gbc_jlMaximum.anchor = GridBagConstraints.EAST;

    jtfMaximum = new JTextField(3);
    jtfMaximum.setToolTipText(res.getString("DGeneralSubtreeChooser.jtfMaximum.tooltip"));

    GridBagConstraints gbc_jtfMaximum = new GridBagConstraints();
    gbc_jtfMaximum.gridx = 1;
    gbc_jtfMaximum.gridy = 2;
    gbc_jtfMaximum.gridwidth = 1;
    gbc_jtfMaximum.gridheight = 1;
    gbc_jtfMaximum.insets = new Insets(5, 5, 5, 5);
    gbc_jtfMaximum.anchor = GridBagConstraints.WEST;

    jpGeneralSubtree = new JPanel(new GridBagLayout());

    jpGeneralSubtree.setBorder(
        new CompoundBorder(
            new EmptyBorder(5, 5, 5, 5),
            new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));

    jpGeneralSubtree.add(jlBase, gbc_jlBase);
    jpGeneralSubtree.add(jgnBase, gbc_jgnBase);
    jpGeneralSubtree.add(jlMinimum, gbc_jlMinimum);
    jpGeneralSubtree.add(jtfMinimum, gbc_jtfMinimum);
    jpGeneralSubtree.add(jlMaximum, gbc_jlMaximum);
    jpGeneralSubtree.add(jtfMaximum, gbc_jtfMaximum);

    jbOK = new JButton(res.getString("DGeneralSubtreeChooser.jbOK.text"));
    jbOK.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            okPressed();
          }
        });

    jbCancel = new JButton(res.getString("DGeneralSubtreeChooser.jbCancel.text"));
    jbCancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            cancelPressed();
          }
        });
    jbCancel
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel
        .getActionMap()
        .put(
            CANCEL_KEY,
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent evt) {
                cancelPressed();
              }
            });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(BorderLayout.CENTER, jpGeneralSubtree);
    getContentPane().add(BorderLayout.SOUTH, jpButtons);

    populate(generalSubtree);

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();
  }
Ejemplo n.º 14
0
    public OptionsDialog(JFrame parent) {
      super(parent, Globals.lang("Writing XMP metadata for selected entries..."), false);
      okButton.setEnabled(false);

      okButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              dispose();
            }
          });

      AbstractAction cancel =
          new AbstractAction() {
            private static final long serialVersionUID = -338601477652815366L;

            public void actionPerformed(ActionEvent e) {
              canceled = true;
            }
          };
      cancelButton.addActionListener(cancel);

      InputMap im = cancelButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
      ActionMap am = cancelButton.getActionMap();
      im.put(Globals.prefs.getKey("Close dialog"), "close");
      am.put("close", cancel);

      progressArea = new JTextArea(15, 60);

      JScrollPane scrollPane =
          new JScrollPane(
              progressArea,
              JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
              JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      Dimension d = progressArea.getPreferredSize();
      d.height += scrollPane.getHorizontalScrollBar().getHeight() + 15;
      d.width += scrollPane.getVerticalScrollBar().getWidth() + 15;

      panel.setSize(d);

      progressArea.setBackground(Color.WHITE);
      progressArea.setEditable(false);
      progressArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
      progressArea.setText("");

      JPanel panel = new JPanel();
      panel.setBorder(BorderFactory.createEmptyBorder(3, 2, 3, 2));
      panel.add(scrollPane);

      // progressArea.setPreferredSize(new Dimension(300, 300));

      ButtonBarBuilder bb = new ButtonBarBuilder();
      bb.addGlue();
      bb.addGridded(okButton);
      bb.addRelatedGap();
      bb.addGridded(cancelButton);
      bb.addGlue();
      JPanel bbPanel = bb.getPanel();
      bbPanel.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 3));
      getContentPane().add(panel, BorderLayout.CENTER);
      getContentPane().add(bbPanel, BorderLayout.SOUTH);

      pack();
      this.setResizable(false);
    }
Ejemplo n.º 15
0
    public OptionsDialog(JFrame parent, BibDatabaseContext databaseContext) {
      super(parent, Localization.lang("Synchronize file links"), true);
      this.databaseContext = databaseContext;
      ok.addActionListener(
          e -> {
            canceled = false;
            dispose();
          });

      Action closeAction =
          new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
              dispose();
            }
          };

      cancel.addActionListener(closeAction);

      InputMap im = cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
      ActionMap am = cancel.getActionMap();
      im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
      am.put("close", closeAction);

      ButtonGroup bg = new ButtonGroup();
      bg.add(autoSetUnset);
      bg.add(autoSetNone);
      bg.add(autoSetAll);

      FormLayout layout =
          new FormLayout(
              "fill:pref",
              "pref, 2dlu, pref, 2dlu, pref, pref, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref");
      FormBuilder builder = FormBuilder.create().layout(layout);
      JLabel description =
          new JLabel(
              "<HTML>"
                  + Localization.lang(
                      "Attempt to automatically set file links for your entries. Automatically setting works if "
                          + "a file in your file directory<BR>or a subdirectory is named identically to an entry's BibTeX key, plus extension.")
                  + "</HTML>");

      builder.addSeparator(Localization.lang("Automatically set file links")).xy(1, 1);
      builder.add(description).xy(1, 3);
      builder.add(autoSetUnset).xy(1, 5);
      builder.add(autoSetAll).xy(1, 6);
      builder.add(autoSetNone).xy(1, 7);
      builder.addSeparator(Localization.lang("Check links")).xy(1, 9);

      description =
          new JLabel(
              "<HTML>"
                  + Localization.lang(
                      "This makes JabRef look up each file link and check if the file exists. If not, you will be given options<BR>to resolve the problem.")
                  + "</HTML>");
      builder.add(description).xy(1, 11);
      builder.add(checkLinks).xy(1, 13);
      builder.addSeparator("").xy(1, 15);

      JPanel main = builder.getPanel();
      main.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

      ButtonBarBuilder bb = new ButtonBarBuilder();
      bb.addGlue();
      bb.addButton(ok);
      bb.addButton(cancel);
      bb.addGlue();
      getContentPane().add(main, BorderLayout.CENTER);
      getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);

      pack();
    }
Ejemplo n.º 16
0
  public JChat() {
    this.setSize(500, 600);
    this.setResizable(false);
    this.setLayout(new BorderLayout());

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridLayout(2, 1));

    // set up buttons
    openChat = new JButton("Open to chat");
    openChat.addActionListener(new OpenChat());
    chatWith = new JButton("Chat with");
    chatWith.addActionListener(new ChatWith());
    send = new JButton("send");
    send.addActionListener(new Send());
    send.setEnabled(false);
    InputMap inputMap = send.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    inputMap.put(enter, "ENTER");
    send.getActionMap().put("ENTER", new ClickAction(send));

    // set up labels
    pickPort = new JLabel();
    pickPort.setText("Pick your port number:");
    desPort = new JLabel();
    desPort.setText("Or enter a destinaltion port number:");

    // set up text fields
    pickText = new JTextField();
    pickText.setPreferredSize(new Dimension(150, 30));
    desText = new JTextField();
    desText.setPreferredSize(new Dimension(150, 30));
    chatText = new JTextField();
    chatText.setPreferredSize(new Dimension(400, 30));
    chatText.setEnabled(false);

    JPanel top1 = new JPanel();
    top1.add(pickPort);
    top1.add(pickText);
    top1.add(openChat);

    JPanel top2 = new JPanel();
    top2.add(desPort);
    top2.add(desText);
    top2.add(chatWith);

    topPanel.add(top1);
    topPanel.add(top2);

    chatField = new JTextArea();
    chatField.setAutoscrolls(true);
    chatField.setDragEnabled(true);
    chatField.setEditable(false);
    chatField.setAlignmentY(TOP_ALIGNMENT);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(chatText);
    bottomPanel.add(send);

    this.add(topPanel, BorderLayout.NORTH);
    this.add(chatField, BorderLayout.CENTER);
    this.add(bottomPanel, BorderLayout.SOUTH);

    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }