コード例 #1
1
 /** Creates the error area component. */
 private void initErrorArea() {
   SimpleAttributeSet attribs = new SimpleAttributeSet();
   StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT);
   StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily());
   StyleConstants.setForeground(attribs, Color.RED);
   errorPane.setParagraphAttributes(attribs, true);
   errorPane.setPreferredSize(new Dimension(100, 50));
   errorPane.setMinimumSize(new Dimension(100, 50));
   errorPane.setOpaque(false);
 }
コード例 #2
0
  /* (non-Javadoc)
   * @see edu.ku.brc.ui.forms.formatters.DataObjFieldFormatPanelBuilder#buildUI()
   */
  protected void buildUI() {
    CellConstraints cc = new CellConstraints();

    JLabel currentFieldsLbl = createI18NLabel("DOF_DISPLAY_FORMAT");
    formatEditor = new JTextPane();
    // to make sure the component shrinks with the dialog
    formatEditor.setMinimumSize(new Dimension(200, 50));
    formatEditor.setPreferredSize(new Dimension(350, 100));

    formatEditor
        .getDocument()
        .addDocumentListener(
            new DocumentAdaptor() {
              @Override
              public void changed(DocumentEvent e) {
                updateUIEnabled();
              }
            });

    PanelBuilder addFieldPB = new PanelBuilder(new FormLayout("p,2px,p,f:p:g,r:m", "p,2px,p"));
    sepText = createTextField(4);
    addFieldBtn = createButton(getResourceString("DOF_ADD_FIELD"));
    sepLbl = createI18NFormLabel("DOF_SEP_TXT");

    addFieldPB.add(sepLbl, cc.xy(1, 1));
    addFieldPB.add(sepText, cc.xy(3, 1));
    addFieldPB.add(addFieldBtn, cc.xy(5, 1));

    sepText.setDocument(new FilteredDoc());

    addFieldBtn.setEnabled(false);
    sepLbl.setEnabled(false);
    sepText.setEnabled(false);

    // For when it is standalone
    if (AppPreferences.hasRemotePrefs()) {
      sepText.setText(AppPreferences.getRemote().get("DOF_SEP", ", "));

    } else {
      sepText.setText(", ");
    }

    PanelBuilder pb =
        new PanelBuilder(
            new FormLayout(
                "f:d:g",
                "10px,"
                    + // empty space on top of panel
                    "p,f:p:g,"
                    + // Label & format text editor
                    "2px,p,"
                    + // separator & add field
                    "10px,p,"
                    + // separator & label
                    "f:250px:g," // list box for available fields
                ),
            this);

    // layout components on main panel
    int y = 2; // leave first row blank

    pb.add(currentFieldsLbl, cc.xy(1, y));
    y += 1;
    pb.add(UIHelper.createScrollPane(formatEditor), cc.xy(1, y));
    y += 2;

    pb.add(addFieldPB.getPanel(), cc.xy(1, y));
    y += 2;

    JLabel availableFieldsLbl = createI18NFormLabel("DOF_AVAILABLE_FIELDS", SwingConstants.LEFT);
    pb.add(availableFieldsLbl, cc.xy(1, y));
    y += 1;

    // create field tree that will be re-used in all instances of single switch formatter editing
    // panel
    availableFieldsComp =
        new AvailableFieldsComponent(
            tableInfo, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache);

    pb.add(UIHelper.createScrollPane(availableFieldsComp.getTree()), cc.xy(1, y));
    y += 2;

    availableFieldsComp
        .getTree()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              @Override
              public void valueChanged(TreeSelectionEvent e) {
                boolean enable = availableFieldsComp.getTree().getSelectionCount() > 0;
                addFieldBtn.setEnabled(enable);
                sepText.setEnabled(enable);
                sepLbl.setEnabled(enable);
              }
            });

    this.mainPanelBuilder = pb;

    fillWithObjFormatter(formatContainer.getSelectedFormatter());

    addFormatTextListeners();

    // must be called after list of available fields has been created
    addFieldListeners();
  }
コード例 #3
0
  private void addCenterPanel(GridBagConstraints mainPanelConstraints) {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    add(panel, mainPanelConstraints);

    GridBagConstraints panelConstraints = new GridBagConstraints();

    panelConstraints.gridx = 0;
    panelConstraints.gridy = 0;
    panelConstraints.fill = GridBagConstraints.HORIZONTAL;
    panelConstraints.anchor = GridBagConstraints.PAGE_START;
    panelConstraints.weighty = 0;
    panelConstraints.weightx = 0;
    panelConstraints.insets = new Insets(10, 10, 10, 10);

    panelConstraints.gridwidth = 2;

    SimpleAttributeSet plain = new SimpleAttributeSet();
    StyleConstants.setForeground(plain, Color.black);
    StyleConstants.setBold(plain, false);

    SimpleAttributeSet bold = new SimpleAttributeSet();
    StyleConstants.setForeground(bold, Color.black);
    StyleConstants.setBold(bold, true);

    JTextPane header = new JTextPane();
    header.setEditable(false);
    header.setOpaque(false);
    Document doc = header.getDocument();
    try {
      doc.insertString(0, "A new version of JPedal is available.", bold);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(header, panelConstraints);

    panelConstraints.gridwidth = 1;
    panelConstraints.gridy = 1;
    panelConstraints.insets = new Insets(10, 10, 0, 10);
    JTextPane currentVersionLabel = new JTextPane();
    currentVersionLabel.setEditable(false);
    currentVersionLabel.setOpaque(false);
    doc = currentVersionLabel.getDocument();
    try {
      doc.insertString(0, "Your current version:", plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    currentVersionLabel.setMinimumSize(currentVersionLabel.getPreferredSize());
    panel.add(currentVersionLabel, panelConstraints);

    panelConstraints.weightx = 1;
    panelConstraints.gridx = 1;
    JTextPane currentVersionPane = new JTextPane();
    currentVersionPane.setEditable(false);
    currentVersionPane.setOpaque(false);
    doc = currentVersionPane.getDocument();
    try {
      doc.insertString(0, currentVersion, plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(currentVersionPane, panelConstraints);

    panelConstraints.insets = new Insets(0, 10, 10, 10);
    panelConstraints.weightx = 0;
    panelConstraints.gridx = 0;
    panelConstraints.gridy = 2;
    JTextPane availableVersionLabel = new JTextPane();
    availableVersionLabel.setEditable(false);
    availableVersionLabel.setOpaque(false);
    doc = availableVersionLabel.getDocument();
    try {
      doc.insertString(0, "Available Version:", plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(availableVersionLabel, panelConstraints);

    panelConstraints.gridwidth = 2;
    panelConstraints.weightx = 1;
    panelConstraints.gridx = 1;
    JTextPane availableVersionPane = new JTextPane();
    availableVersionPane.setEditable(false);
    availableVersionPane.setOpaque(false);
    doc = availableVersionPane.getDocument();
    try {
      doc.insertString(0, availableVersion, plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(availableVersionPane, panelConstraints);

    panelConstraints.insets = new Insets(10, 10, 10, 10);
    panelConstraints.weightx = 0;
    panelConstraints.gridx = 0;
    panelConstraints.gridy = 3;
    JTextPane moreInfo = new JTextPane();
    moreInfo.setEditable(false);
    moreInfo.setOpaque(false);
    doc = moreInfo.getDocument();
    try {
      doc.insertString(0, "Press ", plain);
      doc.insertString(doc.getLength(), "More info... ", bold);
      doc.insertString(
          doc.getLength(),
          "to open a web page where you can download JPedal or learn more about the new version",
          plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }

    panel.add(moreInfo, panelConstraints);

    panelConstraints.gridy = 4;
    JTextPane configure = new JTextPane();
    doc = configure.getDocument();
    try {
      doc.insertString(0, "To configure automatic updates settings, see ", plain);
      doc.insertString(doc.getLength(), "View | Preferences", bold);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    configure.setEditable(false);
    configure.setOpaque(false);

    panel.add(configure, panelConstraints);

    panelConstraints.weighty = 1;
    panelConstraints.gridy = 5;
    JTextPane manual = new JTextPane();
    doc = manual.getDocument();
    try {
      doc.insertString(0, "To check for new updates manually, use ", plain);
      doc.insertString(doc.getLength(), "Help | Check for Updates", bold);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    manual.setEditable(false);
    manual.setOpaque(false);

    panel.add(manual, panelConstraints);
  }
コード例 #4
0
 private void jbInit() throws Exception {
   this.getContentPane().setLayout(gridBagLayout2);
   bottomPanel.setLayout(gridBagLayout1);
   messagePanel.setBorder(BorderFactory.createLoweredBevelBorder());
   replaceButton.setToolTipText("Save the new trace replacing the old trace.");
   replaceButton.setText("Replace old trace");
   replaceButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           replaceOldTrace();
         }
       });
   buttonPanel.setBorder(BorderFactory.createLoweredBevelBorder());
   discardButton.setToolTipText("Discard the new trace");
   discardButton.setText("Discard new trace");
   discardButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           DoneReplayDialog.this.setVisible(false);
         }
       });
   saveButton.setToolTipText("Save the new trace in a file.");
   saveButton.setText("Save as new file");
   saveButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           saveNewToFile();
         }
       });
   this.setModal(true);
   this.setTitle("Replay Complete");
   jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
   jScrollPane1.setMinimumSize(new Dimension(200, 200));
   jScrollPane1.setPreferredSize(new Dimension(200, 200));
   jTextPane.setMinimumSize(new Dimension(25, 80));
   jTextPane.setPreferredSize(new Dimension(40, 80));
   tracePanel.setLayout(borderLayout1);
   commentPanel.setLayout(borderLayout3);
   jPanel6.setLayout(borderLayout2);
   jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
   jScrollPane2.setMinimumSize(new Dimension(200, 100));
   jScrollPane2.setPreferredSize(new Dimension(200, 100));
   jLabel1.setText("Comment");
   jLabel2.setText("Traces (Old is Yellow, New is Pink)");
   tracePanel.setBorder(BorderFactory.createEtchedBorder());
   bottomPanel.setBorder(BorderFactory.createEtchedBorder());
   commentPanel.setBorder(BorderFactory.createEtchedBorder());
   this.getContentPane()
       .add(
           bottomPanel,
           new GridBagConstraints(
               0,
               3,
               1,
               1,
               1.0,
               1.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.HORIZONTAL,
               new Insets(0, 5, 5, 5),
               0,
               0));
   buttonPanel.add(saveButton, null);
   buttonPanel.add(replaceButton, null);
   buttonPanel.add(discardButton, null);
   bottomPanel.add(
       messagePanel,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
   messagePanel.add(messageLabel, null);
   this.getContentPane()
       .add(
           tracePanel,
           new GridBagConstraints(
               0,
               2,
               1,
               1,
               1.0,
               1.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.BOTH,
               new Insets(0, 0, 0, 0),
               0,
               0));
   tracePanel.add(jScrollPane1, BorderLayout.CENTER);
   tracePanel.add(jLabel2, BorderLayout.NORTH);
   this.getContentPane()
       .add(
           commentPanel,
           new GridBagConstraints(
               0,
               1,
               1,
               1,
               1.0,
               1.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.BOTH,
               new Insets(0, 5, 5, 5),
               0,
               0));
   commentPanel.add(jPanel6, BorderLayout.CENTER);
   jPanel6.add(jScrollPane2, BorderLayout.CENTER);
   commentPanel.add(jLabel1, BorderLayout.NORTH);
   jScrollPane2.getViewport().add(commentPane, null);
   jScrollPane1.getViewport().add(jTextPane, null);
   bottomPanel.add(
       buttonPanel,
       new GridBagConstraints(
           0,
           1,
           2,
           2,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
コード例 #5
0
ファイル: EditorServer.java プロジェクト: amarala/recoled
    public DocumentPanel() {
      super(new BorderLayout());

      JLabel lblDocument = new JLabel("Document: " + document.getTitle());
      lblDocument.setBorder(new EtchedBorder());

      textPane = new JTextPane(document);
      textPane.setEditable(false);
      textPane.setMargin(new Insets(5, 20, 5, 5));
      textPane.setMaximumSize(new Dimension(364, 1000000000));
      textPane.setPreferredSize(new Dimension(364, 400));
      textPane.setMinimumSize(new Dimension(364, 10));
      textPane.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              int length = document.getLength();
              int offset = e.getDot();

              if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1);

              Paragraph p = lockManager.getParFromOffset(offset);
              int pOffset = p.getOffset();

              lblCursor.setText(
                  "Document Length="
                      + String.valueOf(length)
                      + ", CaretOffset="
                      + String.valueOf(offset)
                      + ", Paragraph="
                      + p.toString()
                      + ", Offset in Paragraph="
                      + String.valueOf(offset - p.getOffset()));
            }
          });
      Box box = new Box(BoxLayout.X_AXIS);
      box.add(textPane);
      box.add(Box.createGlue());
      box.setBackground(Color.WHITE);
      box.setOpaque(true);
      box.setPreferredSize(new Dimension(600, 10000));

      lblCursor = new JLabel("Cursor");
      lblCursor.setBorder(new EtchedBorder());

      JPanel boxText = new JPanel(new BorderLayout());
      boxText.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxText.add(lblDocument, BorderLayout.NORTH);
      boxText.add(new JScrollPane(box), BorderLayout.CENTER);
      boxText.add(lblCursor, BorderLayout.SOUTH);

      JLabel lblPars = new JLabel("Paragraphs: ");
      lblPars.setBorder(new EtchedBorder());

      parList = new JList();
      parList.setPreferredSize(new Dimension(100, 300));
      parList.setEnabled(false);

      JPanel boxPars = new JPanel(new BorderLayout());
      boxPars.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxPars.add(lblPars, BorderLayout.NORTH);
      boxPars.add(new JScrollPane(parList), BorderLayout.CENTER);

      add(boxText, BorderLayout.CENTER);
      add(boxPars, BorderLayout.EAST);
    }