コード例 #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
 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));
 }
コード例 #3
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);
    }