Ejemplo n.º 1
0
 /** To highlight a message, call #warnUser. */
 private void setStatusBarTextHighlighted(boolean highlighted, Color color) {
   // Use #coordinateLabel rather than (unattached) dummy label because
   // dummy label's background does not change when L&F changes. [Jon
   // Aquino]
   messageLabel.setForeground(highlighted ? Color.black : coordinateLabel.getForeground());
   messageLabel.setBackground(highlighted ? color : coordinateLabel.getBackground());
 }
  protected JPanel createConnectionPanel(final ConnectionDetails cd, final String text) {
    JPanel cP = new JPanel();
    cP.setLayout(new BoxLayout(cP, BoxLayout.X_AXIS));

    JLabel lab1 = new JLabel(text + ": ");

    JTextField conField = new JTextField(25);
    conField.setText(cd.getUser() + "@" + cd.getHost());
    conField.setEditable(false);
    conField.setFocusable(false);
    conField.setBackground(lab1.getBackground());

    cP.add(lab1);
    cP.add(conField);
    return cP;
  }
Ejemplo n.º 3
0
  public void openChangelog(Component parent) {

    JPanel p = new JPanel(new GridBagLayout());
    p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    GridBagConstraints gBC = new GridBagConstraints();
    gBC.anchor = GridBagConstraints.CENTER;
    gBC.fill = GridBagConstraints.HORIZONTAL;
    gBC.insets = new Insets(1, 1, 1, 1);

    JLabel a = new JLabel(getApplicationName());
    a.setFont(a.getFont().deriveFont(24f));
    UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER);

    String changelog = "";
    try {
      BufferedReader br =
          new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/changelog")));
      String line = br.readLine();
      while (line != null) {
        changelog += line + "\n";
        line = br.readLine();
      }
      br.close();
    } catch (Exception e) {
      changelog = "<Error opening changelog>\n";
    }

    javax.swing.JTextArea message = new javax.swing.JTextArea(changelog);
    message.setEditable(false);
    message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4));
    javax.swing.JLabel jl = new javax.swing.JLabel();
    message.setFont(jl.getFont());
    message.setBackground(jl.getBackground());

    //	MultilineLabel x = new MultilineLabel(changelog);
    //	x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0));
    //	x.setFont(x.getFont().deriveFont(12f));
    javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
    scrollPane.getViewport().add(message);
    scrollPane.setSize(400, 200);
    scrollPane.setPreferredSize(new java.awt.Dimension(400, 200));
    UIUtil.jGridBagAdd(p, scrollPane, gBC, GridBagConstraints.REMAINDER);

    JOptionPane.showMessageDialog(
        parent, p, "Change log", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon());
  }
Ejemplo n.º 4
0
  public void paintComponent(Graphics g) {
    Dimension d = getSize();

    Dimension a = ui.getPreferredSize();

    jcb.setBounds(0, (d.height - a.height) / 2, a.width, a.height);

    Graphics g2 = g.create(0, (d.height - a.height) / 2, a.width, a.height);

    ui.paint(g2, jcb, selected, implicit, false);

    int labelWidth = d.width - a.width - PAD, labelHeight = d.height;

    jl.setBounds(a.width + PAD, 0, labelWidth, labelHeight);

    g2 = g.create(a.width + PAD, 0, labelWidth, labelHeight);

    Color c = jl.getBackground();
    if (c != null) {
      g2.setColor(c);
      g2.fillRect(0, 0, labelWidth, labelHeight);
    }
    jl.paint(g2);
  }
Ejemplo n.º 5
0
  private void jbInit() throws Exception {
    titledBorder1 = new TitledBorder("");
    this.setLayout(baseLayout);

    double[][] lower_size = {
      {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL}
    };
    mLowerPanelLayout = new TableLayout(lower_size);

    mLowerPanel.setLayout(mLowerPanelLayout);

    double[][] dir_size = {
      {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL}
    };
    mDirectionsPanelLayout = new TableLayout(dir_size);
    mDirectionsPanel.setLayout(mDirectionsPanelLayout);

    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif"));
      mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif"));
      mDisabledRemoveIcon =
          new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif"));

      mAddNodeBtn.setIcon(mAddIcon);
      mRemoveNodeBtn.setIcon(mRemoveIcon);
      mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mAddNodeBtn.setText("Add");
      mRemoveNodeBtn.setText("Remove");
    }

    /*
    mAddNodeBtn.setMaximumSize(new Dimension(130, 33));
    mAddNodeBtn.setMinimumSize(new Dimension(130, 33));
    mAddNodeBtn.setPreferredSize(new Dimension(130, 33));
    mAddNodeBtn.setText("Add Node");
    */
    mAddNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    /*
    mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33));
    mRemoveNodeBtn.setText("Remove Node");
    */
    mRemoveNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mRemoveNode();
          }
        });
    mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    mHostnameLabel.setLabelFor(mHostnameField);
    mHostnameLabel.setText("Hostname:");

    mHostnameField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder());
    mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20));
    mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    mTitleLabel.setText("Add Cluster Nodes");
    mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration.");
    mDirectionsLabel.setLineWrap(true);
    mDirectionsLabel.setEditable(false);
    mDirectionsLabel.setBackground(mTitleLabel.getBackground());

    baseLayout.setHgap(5);
    baseLayout.setVgap(5);
    mLowerPanel.add(
        mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mListScrollPane1,
        new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mLowerPanel, BorderLayout.CENTER);
    mListScrollPane1.getViewport().add(lstNodes, null);
    mDirectionsPanel.add(
        mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mDirectionsLabel,
        new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mDirectionsPanel, BorderLayout.NORTH);
  }
Ejemplo n.º 6
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // TODO Auto-generated method stub
   if (e.getActionCommand().equalsIgnoreCase("Freedraw")) {
     canvas.setShape(0);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/free_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Line")) {
     canvas.setShape(1);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/line_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Rectangle")) {
     canvas.setShape(2);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/rectangle_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Square")) {
     canvas.setShape(3);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/square_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Oval")) {
     canvas.setShape(4);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/ellipse_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Circle")) {
     canvas.setShape(5);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/circle_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Text")) {
     canvas.setTextDialog(this);
     canvas.setShape(6);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/text_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Erase")) {
     canvas.setShape(7);
     pen.setPen(pen.getPen().getLineWidth(), BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);
     canvas.setPen(pen);
     btnIcon = new ImageIcon("images/erase_a.jpg");
     lblTool.setIcon(btnIcon);
   } else if (e.getActionCommand().equalsIgnoreCase("Fill")) {
     JToggleButton btn = (JToggleButton) e.getSource();
     styleBox.setMode(btn.isSelected());
     canvas.setMode(styleBox.getMode());
   } else if (e.getActionCommand().equalsIgnoreCase("PenColor")) {
     System.out.println(e.getActionCommand().toString());
     Color prevColor = lblColor.getBackground();
     Color newColor = JColorChooser.showDialog(this, "Choose Background Color", prevColor);
     pen.set_penColor(newColor);
     lblColor.setBackground(newColor);
     revalidate();
   } else if (e.getActionCommand().equalsIgnoreCase("Open")) {
     fileMenu.setCanvas(canvas);
     fileMenu.open();
   } else if (e.getActionCommand().equalsIgnoreCase("Save")) {
     fileMenu.setCanvas(canvas);
     fileMenu.save();
   } else if (e.getActionCommand().equalsIgnoreCase("SaveAs")) {
     fileMenu.setCanvas(canvas);
     fileMenu.saveAs();
   } else if (e.getActionCommand().equalsIgnoreCase("New")) {
     fileMenu.setCanvas(canvas);
     fileMenu.newCanvas();
   } else if (e.getActionCommand().equalsIgnoreCase("Exit")) {
     closeOperation();
   } else if (e.getActionCommand().equalsIgnoreCase("Connect")) {
     networkMenu.setCanvas(this, canvas);
     networkMenu.connect(this);
   } else if (e.getActionCommand().equalsIgnoreCase("Disconnect")) {
     networkMenu.setCanvas(this, canvas);
     networkMenu.disconnect(" left the session.");
   }
   revalidate();
   repaint();
 }
Ejemplo n.º 7
0
 protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) {
   int accChar = l.getDisplayedMnemonic();
   g.setColor(l.getBackground());
   drawString(g, s, accChar, textX, textY);
 }
 public Color getFontColor() {
   return colorBox.getBackground();
 }
  @Override
  public void editLabel() {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("Edit ie hyperlink");
    }
    labelEditing = true;
    _jLabelTextField =
        new JTextField(getModel().getValue()) {
          /**
           * Overrides paint
           *
           * @see javax.swing.JComponent#paint(java.awt.Graphics)
           */
          @Override
          public void paint(Graphics g) {
            super.paint(g);
            if (getModel().isCustomButton()) {
              Rectangle bounds = getBounds();
              g.setColor(getBackgroundColor());
              g.fillRect(0, 0, ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE);
              g.fillRect(
                  0, bounds.height - ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE);
              g.fillRect(
                  bounds.width - ROUNDED_BORDER_SIZE, 0, ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE);
              g.fillRect(
                  bounds.width - ROUNDED_BORDER_SIZE,
                  bounds.height - ROUNDED_BORDER_SIZE,
                  ROUNDED_BORDER_SIZE,
                  ROUNDED_BORDER_SIZE);
            }
          }

          /**
           * Overrides getPreferredSize
           *
           * @see javax.swing.JComponent#getPreferredSize()
           */
          @Override
          public Dimension getPreferredSize() {
            if (getModel().isCustomButton()) {
              String s = _jLabelTextField.getText();
              if (s == null) {
                return new Dimension(30, 15);
              } else {
                return new Dimension(
                    (int)
                        (getFontMetrics(getFont()).getStringBounds(s, getGraphics()).getWidth()
                            + 32),
                    15);
              }
            } else {
              return super.getPreferredSize();
            }
          }
        };
    _jLabelTextField.setFont(_jLabel.getFont());
    _jLabelTextField.setForeground(_jLabel.getForeground());
    _jLabelTextField.setBackground(_jLabel.getBackground());
    if (getModel().isCustomButton()) {
      _jLabelTextField.setBorder(
          BorderFactory.createMatteBorder(0, 15, 1, 15, _jLabel.getBackground()));
    } else {
      _jLabelTextField.setBorder(BorderFactory.createEmptyBorder(0, 10, 1, 10));
    }
    // _jLabelTextField.setForeground(getFlexoNode().getTextColor());
    _jLabelTextField.setBounds(_jLabel.getBounds());
    _jLabelTextField.setHorizontalAlignment(SwingConstants.CENTER);
    _jLabelTextField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            finalizeEditHyperlink();
          }
        });
    _jLabelTextField.getDocument().addDocumentListener(new TriggerRepaintDocumentListener(this));
    _jLabelTextField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent arg0) {
            finalizeEditHyperlink();
          }
        });
    remove(_jLabel);
    add(_jLabelTextField);
    _jLabelTextField.requestFocusInWindow();
    _jLabelTextField.selectAll();
    _jLabelTextField.revalidate();
    _jLabelTextField.repaint();
    revalidate();
    repaint();
  }
Ejemplo n.º 10
0
  /**
   * Creates the gui.
   *
   * @param owner the owner
   * @param dev the dev
   * @param r the r
   */
  private void createGui(Component owner, CombinerDevice dev, Remote r) {
    setLocationRelativeTo(owner);
    Container contentPane = getContentPane();
    remote = r;

    protocolHolder = new JPanel(new BorderLayout());
    protocolHolder.setBorder(BorderFactory.createTitledBorder("Protocol Parameters"));

    Insets insets = protocolHolder.getInsets();
    double bt = insets.top;
    double bl = insets.left + 10;
    double br = insets.right;
    double bb = insets.bottom;
    double b = 10; // space around border
    double i = 5; // space between rows
    double v = 20; // space between groupings
    double f = TableLayout.FILL;
    double p = TableLayout.PREFERRED;
    double size[][] = { // 0  1   2  3  4  5   6  7   8  9  10 11
      {b, bl, p, b, p, br, b, f, b}, // cols
      {b, p, i, p, v, bt, p, bb, i, f, b} // rows
    };
    tl = new TableLayout(size);
    mainPanel = new JPanel(tl);
    contentPane.add(mainPanel, BorderLayout.CENTER);

    JLabel label = new JLabel("Protocol:", SwingConstants.RIGHT);
    mainPanel.add(label, "2, 1");

    boolean allowUpgrades = r.getProcessor().getEquivalentName().equals("S3C80");
    java.util.List<Protocol> allProtocols =
        ProtocolManager.getProtocolManager().getProtocolsForRemote(r, allowUpgrades);
    java.util.List<Protocol> protocols = new ArrayList<Protocol>();
    if (allowUpgrades) protocols.add(new ManualProtocol(null, null));
    for (Protocol protocol : allProtocols) {
      if (protocol.getDefaultCmd().length() == 1) protocols.add(protocol);
    }
    if (dev == null) device = new CombinerDevice((Protocol) protocols.get(1), new Value[0]);
    else device = new CombinerDevice(dev);

    device.getProtocol().reset();

    protocolList = new JComboBox(protocols.toArray());
    protocolList.addActionListener(this);
    label.setLabelFor(protocolList);
    protocolList.setToolTipText(
        "Select the protocol to be used for this device upgrade from the drop-down list.");
    mainPanel.add(protocolList, "4, 1");

    deviceNotes = new JTextField();
    new TextPopupMenu(deviceNotes);
    deviceNotes.getDocument().addDocumentListener(this);
    JPanel temp = new JPanel(new BorderLayout());
    temp.add(deviceNotes, BorderLayout.CENTER);
    temp.setBorder(BorderFactory.createTitledBorder("Notes"));

    mainPanel.add(temp, "7, 1, 7, 3");

    label = new JLabel("Protocol ID:", SwingConstants.RIGHT);
    mainPanel.add(label, "2, 3");

    protocolID = new JTextField();
    label.setLabelFor(protocolID);
    protocolID.setEditable(false);
    protocolID.setToolTipText("This is the protocol ID that corresponds to the selected protocol.");
    mainPanel.add(protocolID, "4, 3");

    label = new JLabel("Fixed Data:", SwingConstants.RIGHT);
    mainPanel.add(label, "2, 6");

    fixedData = new JTextField(" ");
    fixedData.setEditable(false);
    mainPanel.add(fixedData, "4, 6");

    boolean flag = (device.getProtocol().getClass() == ManualProtocol.class);
    fixedData.setEditable(flag);
    protocolID.setEditable(flag);

    mainPanel.add(protocolHolder, "1, 5, 5, 7");

    protocolNotes = new JTextArea(15, 60);
    protocolNotes.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    protocolNotes.setText(protocols.get(0).getNotes());
    protocolNotes.setBackground(label.getBackground());
    protocolNotes.setToolTipText("Notes about the selected protocol.");
    protocolNotes.setEditable(false);
    protocolNotes.setLineWrap(true);
    protocolNotes.setWrapStyleWord(true);
    JScrollPane scrollPane = new JScrollPane(protocolNotes);
    scrollPane.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Protocol Notes"), scrollPane.getBorder()));
    mainPanel.add(scrollPane, "1, 9, 7, 9");

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(panel, BorderLayout.SOUTH);

    okButton = new JButton("OK");
    okButton.addActionListener(this);
    panel.add(okButton);

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    panel.add(cancelButton);

    update();
    pack();

    Rectangle rect = getBounds();
    int x = rect.x - rect.width / 2;
    int y = rect.y - rect.height / 2;
    setLocation(x, y);
  }