コード例 #1
0
 private void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
   contentPane.setBorder(border1);
   contentPane.setLayout(borderLayout1);
   controlsPane.setLayout(gridLayout1);
   gridLayout1.setColumns(1);
   gridLayout1.setHgap(10);
   gridLayout1.setRows(0);
   gridLayout1.setVgap(10);
   okButton.setVerifyInputWhenFocusTarget(true);
   okButton.setMnemonic('O');
   okButton.setText("OK");
   buttonsPane.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.CENTER);
   messagePane.setEditable(false);
   messagePane.setText("");
   borderLayout1.setHgap(10);
   borderLayout1.setVgap(10);
   this.setTitle("Subscription Authorization");
   this.getContentPane().add(contentPane, BorderLayout.CENTER);
   contentPane.add(controlsPane, BorderLayout.SOUTH);
   controlsPane.add(responsesComboBox, null);
   controlsPane.add(buttonsPane, null);
   buttonsPane.add(okButton, null);
   contentPane.add(messageScrollPane, BorderLayout.CENTER);
   messageScrollPane.getViewport().add(messagePane, null);
 }
コード例 #2
0
ファイル: Calculator.java プロジェクト: GeorgeZhuo/Gridworld
  public CalculatorPanel() {

    result = 0;
    lastCommand = "+";
    ActionListener command = new CommandAction();

    GridLayout layout = new GridLayout(2, 5);
    layout.setHgap(5);
    layout.setVgap(5);

    panel = new JPanel();
    panel.setLayout(layout);
    panel.setPreferredSize(new Dimension(400, 200));

    // add display
    display = new JTextField();
    Command = new JTextField("+");
    firstNumber = new JTextField();
    secondNumber = new JTextField();
    JTextField equal = new JTextField("=");

    equal.setEnabled(false);
    display.setEnabled(false);
    Command.setEnabled(false);

    panel.add(firstNumber);
    panel.add(Command);
    panel.add(secondNumber);
    panel.add(equal);
    panel.add(display);

    addButton("+", command);
    addButton("-", command);
    addButton("*", command);
    addButton("/", command);
    addButton("OK", command);
    add(panel, BorderLayout.CENTER);
  }
コード例 #3
0
  public ImportDialog(boolean targetIsARow, String fileName) {
    Boolean targetIsARow1 = targetIsARow;
    contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    setContentPane(contentPane);
    JPanel panel3 = new JPanel();
    panel3.setBackground(new Color(-1643275));
    JLabel labelHeadline = new JLabel(Localization.lang("Import_Metadata_from:"));
    labelHeadline.setFont(new Font(labelHeadline.getFont().getName(), Font.BOLD, 14));
    JLabel labelSubHeadline =
        new JLabel(Localization.lang("Choose_the_source_for_the_metadata_import"));
    labelSubHeadline.setFont(
        new Font(labelSubHeadline.getFont().getName(), labelSubHeadline.getFont().getStyle(), 13));
    JLabel labelFileName = new JLabel();
    labelFileName.setFont(new Font(labelHeadline.getFont().getName(), Font.BOLD, 14));
    JPanel headLinePanel = new JPanel();
    headLinePanel.add(labelHeadline);
    headLinePanel.add(labelFileName);
    headLinePanel.setBackground(new Color(-1643275));
    GridLayout gl = new GridLayout(2, 1);
    gl.setVgap(10);
    gl.setHgap(10);
    panel3.setLayout(gl);
    panel3.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    panel3.add(headLinePanel);
    panel3.add(labelSubHeadline);
    radioButtonNoMeta = new JRadioButton(Localization.lang("Create_blank_entry_linking_the_PDF"));
    radioButtonXmp = new JRadioButton(Localization.lang("Create_entry_based_on_XMP_data"));
    radioButtonPDFcontent = new JRadioButton(Localization.lang("Create_entry_based_on_content"));
    radioButtononlyAttachPDF = new JRadioButton(Localization.lang("Only_attach_PDF"));
    JButton buttonOK = new JButton(Localization.lang("Ok"));
    JButton buttonCancel = new JButton(Localization.lang("Cancel"));
    checkBoxDoNotShowAgain =
        new JCheckBox(Localization.lang("Do not show this box again for this import"));
    useDefaultPDFImportStyle =
        new JCheckBox(
            Localization.lang("Always use this PDF import style (and do not ask for each import)"));
    DefaultFormBuilder b =
        new DefaultFormBuilder(new FormLayout("left:pref, 5dlu, left:pref:grow", ""));
    b.appendSeparator(Localization.lang("Create New Entry"));
    b.append(radioButtonNoMeta, 3);
    b.append(radioButtonXmp, 3);
    b.append(radioButtonPDFcontent, 3);
    b.appendSeparator(Localization.lang("Update_Existing_Entry"));
    b.append(radioButtononlyAttachPDF, 3);
    b.nextLine();
    b.append(checkBoxDoNotShowAgain);
    b.append(useDefaultPDFImportStyle);
    b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(buttonOK);
    bb.addButton(buttonCancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    contentPane.add(panel3, BorderLayout.NORTH);
    contentPane.add(b.getPanel(), BorderLayout.CENTER);
    contentPane.add(bb.getPanel(), BorderLayout.SOUTH);

    if (!targetIsARow1) {
      this.radioButtononlyAttachPDF.setEnabled(false);
    }
    String name = new File(fileName).getName();
    if (name.length() < 34) {
      labelFileName.setText(name);
    } else {
      labelFileName.setText(new File(fileName).getName().substring(0, 33) + "...");
    }
    this.setTitle(Localization.lang("Import_Metadata_From_PDF"));

    setModal(true);
    getRootPane().setDefaultButton(buttonOK);

    // only one of the radio buttons may be selected.
    ButtonGroup bg = new ButtonGroup();
    bg.add(radioButtonNoMeta);
    bg.add(radioButtonXmp);
    bg.add(radioButtonPDFcontent);
    bg.add(radioButtononlyAttachPDF);

    buttonOK.addActionListener(
        new ActionListener() {

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

    buttonCancel.addActionListener(
        new ActionListener() {

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

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    contentPane.registerKeyboardAction(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    switch (Globals.prefs.getInt(ImportSettingsTab.PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE)) {
      case NOMETA:
        radioButtonNoMeta.setSelected(true);
        break;
      case XMP:
        radioButtonXmp.setSelected(true);
        break;
      case CONTENT:
        radioButtonPDFcontent.setSelected(true);
        break;
      case ONLYATTACH:
        radioButtononlyAttachPDF.setSelected(true);
        break;
      default:
        // fallback
        radioButtonPDFcontent.setSelected(true);
        break;
    }

    this.setSize(555, 371);
  }
コード例 #4
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);
  }