Пример #1
0
    /**
     * Calculates the preferred size dimensions for the specified panal given the components in the
     * specified parent container.
     */
    public Dimension preferredLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int size = actions.size();
        if ((grip != null) && grip.isVisible()) {
          Dimension d = grip.getPreferredSize();
          dim.width += d.width;
          dim.width += hgap;
        }
        for (int i = 0; i < size; i++) {
          Component comp = (Component) actions.elementAt(i);
          if (comp.isVisible()) {
            Dimension d = comp.getPreferredSize();
            dim.width += d.width;
            dim.height = Math.max(dim.height, d.height);
            dim.width += hgap;
          }
        }
        Insets insets = target.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

        return dim;
      }
    }
 public void paint(Graphics g) {
   MetalBumps usedBumps;
   if (splitPane.hasFocus()) {
     usedBumps = focusBumps;
     g.setColor(primaryControlColor);
   } else {
     usedBumps = bumps;
     g.setColor(controlColor);
   }
   Rectangle clip = g.getClipBounds();
   Insets insets = getInsets();
   g.fillRect(clip.x, clip.y, clip.width, clip.height);
   Dimension size = getSize();
   size.width -= inset * 2;
   size.height -= inset * 2;
   int drawX = inset;
   int drawY = inset;
   if (insets != null) {
     size.width -= (insets.left + insets.right);
     size.height -= (insets.top + insets.bottom);
     drawX += insets.left;
     drawY += insets.top;
   }
   usedBumps.setBumpArea(size);
   usedBumps.paintIcon(this, g, drawX, drawY);
   super.paint(g);
 }
Пример #3
0
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
Пример #4
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
 @Override
 public Dimension getMinimumSize(JComponent c) {
   AbstractButton b = (AbstractButton) c;
   String style = (String) c.getClientProperty("Quaqua.Button.style");
   if (style == null) {
     style = "push";
   }
   if (style.equals("help")) {
     return getPreferredSize(c);
   }
   Dimension d = super.getMinimumSize(c);
   if (isFixedHeight(c)) {
     Dimension p = getPreferredSize(c);
     if (d != null && p != null) {
       d.height = Math.max(d.height, p.height);
     }
   }
   if (!QuaquaUtilities.isSmallSizeVariant(c)
       && style.equals("push") //
       && b.getIcon() == null
       && b.getText() != null) {
     if (d != null) {
       d.width = Math.max(d.width, UIManager.getInt("Button.minimumWidth"));
     }
   }
   return d;
 }
Пример #6
0
    /**
     * Returns the minimum dimensions this border requires in order to fully display the border and
     * title.
     *
     * @param c the component where this border will be drawn
     */
    public Dimension getMinimumSize(Component c) {
      Insets insets = getBorderInsets(c);
      Dimension minSize = new Dimension(insets.right + insets.left, insets.top + insets.bottom);
      minSize.width += label.getWidth();

      return minSize;
    }
Пример #7
0
 public Dimension getMaximumSize(JComponent c) {
   Dimension d = getPreferredSize(c);
   View v = (View) c.getClientProperty(BasicHTML.propertyKey);
   if (v != null) {
     d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
   }
   return d;
 }
Пример #8
0
  public ErrorListDialog(
      Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) {
    super(frame, title, true);

    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    Box iconBox = new Box(BoxLayout.Y_AXIS);
    iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
    iconBox.add(Box.createGlue());
    content.add(BorderLayout.WEST, iconBox);

    JPanel centerPanel = new JPanel(new BorderLayout());

    JLabel label = new JLabel(caption);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    centerPanel.add(BorderLayout.NORTH, label);

    JList errors = new JList(messages);
    errors.setCellRenderer(new ErrorListCellRenderer());
    errors.setVisibleRowCount(Math.min(messages.size(), 4));

    JScrollPane scrollPane =
        new JScrollPane(
            errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Dimension size = scrollPane.getPreferredSize();
    size.width = Math.min(size.width, 400);
    scrollPane.setPreferredSize(size);

    centerPanel.add(BorderLayout.CENTER, scrollPane);

    content.add(BorderLayout.CENTER, centerPanel);

    Box buttons = new Box(BoxLayout.X_AXIS);
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(new ActionHandler());

    if (showPluginMgrButton) {
      pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager"));
      pluginMgr.addActionListener(new ActionHandler());
      buttons.add(pluginMgr);
      buttons.add(Box.createHorizontalStrut(6));
    }

    buttons.add(ok);

    buttons.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttons);

    getRootPane().setDefaultButton(ok);

    pack();
    setLocationRelativeTo(frame);
    show();
  }
Пример #9
0
    public Dimension preferredLayoutSize(Container parent) {
      Dimension dim = new Dimension();

      Dimension captionSize = caption.getPreferredSize();
      dim.width = captionSize.width;

      for (int i = 0; i < pages.length; i++) {
        Dimension _dim = pages[i].getPreferredSize();
        dim.width = Math.max(_dim.width, dim.width);
        dim.height = Math.max(_dim.height, dim.height);
      }

      dim.width += PADDING * 2;
      dim.height += PADDING * 2;
      dim.height += nextButton.getPreferredSize().height;
      dim.height += captionSize.height;
      return dim;
    }
Пример #10
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   if (!inEditMode) {
     if ((h != nHeight) || (h < rHeight)) {
       adjustFont(w, h);
     }
   }
   super.reshape(x, y, w, h);
 }
  @Override
  public Dimension getPreferredSize() {
    Dimension d = super.getPreferredSize();
    Insets ins = getInsets();

    if (bSmallTitle) {
      if (getOrientation().isHorizontal()) {
        d.height = 16 + 2 + ins.top + ins.bottom;
      } else {
        d.width = 16 + 2 + ins.left + ins.right;
      }
    } else {
      if (getOrientation().isHorizontal()) {
        d.height = 16 + 2 + ins.top + ins.bottom;
      } else {
        d.width = 16 + 2 + ins.left + ins.right;
      }
    }
    return d;
  }
Пример #12
0
 public void setSizeRatio(double x, double y) {
   xRatio = x;
   yRatio = y;
   if (x > 1.0) xRatio = x - 1.0;
   if (y > 1.0) yRatio = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * xRatio);
   curLoc.y = (int) ((double) defLoc.y * yRatio);
   curDim.width = (int) ((double) defDim.width * xRatio);
   curDim.height = (int) ((double) defDim.height * yRatio);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
 }
Пример #13
0
  public Dimension getMinimumSize() {
    if (getLayout() != null) {
      // A layout manager has been set, so delegate to it
      return super.getMinimumSize();
    }

    if (moreOrLessButton != null) {
      Dimension d = moreOrLessButton.getMinimumSize();
      Insets i = getInsets();
      d.width += i.left + i.right;
      d.height += i.top + i.bottom;
      return d;
    } else {
      return super.getMinimumSize();
    }
  }
Пример #14
0
  public Dimension getMinimumSize(JComponent c) {
    if (!isMinimumSizeDirty) {
      return new Dimension(cachedMinimumSize);
    }
    Dimension size;
    Insets insets = getInsets();
    size = getDisplaySize();
    size.height += insets.top + insets.bottom;
    int buttonSize = iconAreaWidth();
    size.width += insets.left + insets.right + buttonSize;

    cachedMinimumSize.setSize(size.width, size.height);
    isMinimumSizeDirty = false;

    return size;
  }
Пример #15
0
    public void layoutContainer(Container parent) {
      Dimension size = parent.getSize();

      Dimension captionSize = caption.getPreferredSize();
      caption.setBounds(PADDING, PADDING, captionSize.width, captionSize.height);

      // make all buttons the same size
      Dimension buttonSize = cancelButton.getPreferredSize();
      buttonSize.width = Math.max(buttonSize.width, prevButton.getPreferredSize().width);
      buttonSize.width = Math.max(buttonSize.width, nextButton.getPreferredSize().width);

      // cancel button goes on far left
      cancelButton.setBounds(
          PADDING, size.height - buttonSize.height - PADDING, buttonSize.width, buttonSize.height);

      // prev and next buttons are on the right
      prevButton.setBounds(
          size.width - buttonSize.width * 2 - 6 - PADDING,
          size.height - buttonSize.height - PADDING,
          buttonSize.width,
          buttonSize.height);

      nextButton.setBounds(
          size.width - buttonSize.width - PADDING,
          size.height - buttonSize.height - PADDING,
          buttonSize.width,
          buttonSize.height);

      // calculate size for current page
      Rectangle currentPageBounds = new Rectangle();
      currentPageBounds.x = PADDING;
      currentPageBounds.y = PADDING * 2 + captionSize.height;
      currentPageBounds.width = size.width - currentPageBounds.x - PADDING;
      currentPageBounds.height =
          size.height - buttonSize.height - currentPageBounds.y - PADDING * 2;

      for (int i = 0; i < pages.length; i++) {
        Component page = pages[i];
        page.setBounds(currentPageBounds);
        page.setVisible(i == currentPage);
      }
    }
Пример #16
0
    private JTextField addField(JPanel directoryPanel, String label, String defaultText) {
      JTextField field = new JTextField(defaultText);

      directoryPanel.add(new JLabel(label, SwingConstants.RIGHT));

      Box fieldBox = new Box(BoxLayout.Y_AXIS);
      fieldBox.add(Box.createGlue());
      Dimension dim = field.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      field.setMaximumSize(dim);
      fieldBox.add(field);
      fieldBox.add(Box.createGlue());
      directoryPanel.add(fieldBox);
      JButton choose = new JButton("Choose...");
      choose.setRequestFocusEnabled(false);
      choose.addActionListener(new ActionHandler(field));
      directoryPanel.add(choose);

      return field;
    }
Пример #17
0
    TextPanel(String file) {
      super(new BorderLayout());

      JEditorPane text = new JEditorPane();

      try {
        text.setPage(TextPanel.this.getClass().getResource(file));
      } catch (Exception e) {
        text.setText("Error loading '" + file + "'");
        e.printStackTrace();
      }

      text.setEditable(false);

      JScrollPane scrollPane = new JScrollPane(text);
      Dimension dim = new Dimension();
      dim.width = 450;
      dim.height = 200;
      scrollPane.setPreferredSize(dim);
      TextPanel.this.add(BorderLayout.CENTER, scrollPane);
    }
Пример #18
0
 public void setEditMode(boolean s) {
   if (s) {
     addMouseListener(ml);
     setOpaque(s);
     if (font != null) {
       setFont(font);
       fontH = font.getSize();
       rHeight = fontH;
     }
     defDim = getPreferredSize();
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     curDim.width = defDim.width;
     curDim.height = defDim.height;
     xRatio = 1.0;
     yRatio = 1.0;
   } else {
     removeMouseListener(ml);
     if ((bg != null) || (isActive < 1)) setOpaque(true);
     else setOpaque(false);
   }
   inEditMode = s;
 }
  public InfoPanelForDrawable(
      final Map map_line2treenodes, final String[] y_colnames, final Drawable dobj) {
    super();
    super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /* Define DecialFormat for the displayed time */
    if (fmt == null) {
      fmt = (DecimalFormat) NumberFormat.getInstance();
      fmt.applyPattern(FORMAT);
    }
    if (tfmt == null) tfmt = new TimeFormat();
    if (Normal_Border == null) {
      /*
      Normal_Border = BorderFactory.createCompoundBorder(
                      BorderFactory.createRaisedBevelBorder(),
                      BorderFactory.createLoweredBevelBorder() );
      */
      Normal_Border = BorderFactory.createEtchedBorder();
    }
    if (Shadow_Border == null) {
      Shadow_Border =
          BorderFactory.createTitledBorder(
              Normal_Border,
              " Preview State ",
              TitledBorder.LEFT,
              TitledBorder.TOP,
              Const.FONT,
              Color.magenta);
    }

    drawable = dobj;

    // Set the CategoryLabel Icon
    Dimension panel_max_size;
    Category type = null;
    CategoryLabel label_type = null;
    JPanel top_panel = new JPanel();
    top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.X_AXIS));
    if (drawable instanceof Shadow && ((Shadow) drawable).getSelectedSubCategory() != null) {
      type = ((Shadow) drawable).getSelectedSubCategory();
      label_type = new CategoryLabel(type);
      ((Shadow) drawable).clearSelectedSubCategory();
      top_panel.setBorder(Shadow_Border);
    } else {
      type = drawable.getCategory();
      label_type = new CategoryLabel(type);
      top_panel.setBorder(Normal_Border);
    }
    top_panel.add(STRUT);
    top_panel.add(label_type);
    top_panel.add(GLUE);
    top_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel_max_size = top_panel.getPreferredSize();
    panel_max_size.width = Short.MAX_VALUE;
    top_panel.setMaximumSize(panel_max_size);
    super.add(top_panel);

    // Determine the text of the drawable
    TextAreaBuffer textbuf;
    int num_cols, num_rows;
    textbuf = new TextAreaBuffer(map_line2treenodes, y_colnames);
    if (drawable instanceof Shadow) textbuf.setShadowText((Shadow) drawable, type);
    else if (drawable instanceof Composite) textbuf.setCompositeText((Composite) drawable);
    else textbuf.setPrimitiveText((Primitive) drawable);
    textbuf.finalized();
    num_cols = textbuf.getColumnCount();
    num_rows = textbuf.getRowCount();

    // Set the TextArea
    JTextArea text_area;
    int adj_num_cols;
    text_area = new JTextArea(textbuf.toString());
    adj_num_cols = Routines.getAdjNumOfTextColumns(text_area, num_cols);
    num_cols = (int) Math.ceil(adj_num_cols * 85.0d / 100.0d);
    text_area.setColumns(num_cols);
    text_area.setRows(num_rows);
    text_area.setEditable(false);
    text_area.setLineWrap(true);
    JScrollPane scroller = new JScrollPane(text_area);
    scroller.setAlignmentX(Component.LEFT_ALIGNMENT);
    super.add(scroller);
  }
 /** Constructor (create and layout page) */
 public SOAPMonitorPage(String host_name) {
   host = host_name;
   // Set up default filter (show all messages)
   filter = new SOAPMonitorFilter();
   // Use borders to help improve appearance
   etched_border = new EtchedBorder();
   // Build top portion of split (list panel)
   model = new SOAPMonitorTableModel();
   table = new JTable(model);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table.setRowSelectionInterval(0, 0);
   table.setPreferredScrollableViewportSize(new Dimension(600, 96));
   table.getSelectionModel().addListSelectionListener(this);
   scroll = new JScrollPane(table);
   remove_button = new JButton("Remove");
   remove_button.addActionListener(this);
   remove_button.setEnabled(false);
   remove_all_button = new JButton("Remove All");
   remove_all_button.addActionListener(this);
   filter_button = new JButton("Filter ...");
   filter_button.addActionListener(this);
   list_buttons = new JPanel();
   list_buttons.setLayout(new FlowLayout());
   list_buttons.add(remove_button);
   list_buttons.add(remove_all_button);
   list_buttons.add(filter_button);
   list_panel = new JPanel();
   list_panel.setLayout(new BorderLayout());
   list_panel.add(scroll, BorderLayout.CENTER);
   list_panel.add(list_buttons, BorderLayout.SOUTH);
   list_panel.setBorder(empty_border);
   // Build bottom portion of split (message details)
   details_time = new JLabel("Time: ", SwingConstants.RIGHT);
   details_target = new JLabel("Target Service: ", SwingConstants.RIGHT);
   details_status = new JLabel("Status: ", SwingConstants.RIGHT);
   details_time_value = new JLabel();
   details_target_value = new JLabel();
   details_status_value = new JLabel();
   Dimension preferred_size = details_time.getPreferredSize();
   preferred_size.width = 1;
   details_time.setPreferredSize(preferred_size);
   details_target.setPreferredSize(preferred_size);
   details_status.setPreferredSize(preferred_size);
   details_time_value.setPreferredSize(preferred_size);
   details_target_value.setPreferredSize(preferred_size);
   details_status_value.setPreferredSize(preferred_size);
   details_header = new JPanel();
   details_header_layout = new GridBagLayout();
   details_header.setLayout(details_header_layout);
   details_header_constraints = new GridBagConstraints();
   details_header_constraints.fill = GridBagConstraints.BOTH;
   details_header_constraints.weightx = 0.5;
   details_header_layout.setConstraints(details_time, details_header_constraints);
   details_header.add(details_time);
   details_header_layout.setConstraints(details_time_value, details_header_constraints);
   details_header.add(details_time_value);
   details_header_layout.setConstraints(details_target, details_header_constraints);
   details_header.add(details_target);
   details_header_constraints.weightx = 1.0;
   details_header_layout.setConstraints(details_target_value, details_header_constraints);
   details_header.add(details_target_value);
   details_header_constraints.weightx = .5;
   details_header_layout.setConstraints(details_status, details_header_constraints);
   details_header.add(details_status);
   details_header_layout.setConstraints(details_status_value, details_header_constraints);
   details_header.add(details_status_value);
   details_header.setBorder(etched_border);
   request_label = new JLabel("SOAP Request", SwingConstants.CENTER);
   request_text = new SOAPMonitorTextArea();
   request_text.setEditable(false);
   request_scroll = new JScrollPane(request_text);
   request_panel = new JPanel();
   request_panel.setLayout(new BorderLayout());
   request_panel.add(request_label, BorderLayout.NORTH);
   request_panel.add(request_scroll, BorderLayout.CENTER);
   response_label = new JLabel("SOAP Response", SwingConstants.CENTER);
   response_text = new SOAPMonitorTextArea();
   response_text.setEditable(false);
   response_scroll = new JScrollPane(response_text);
   response_panel = new JPanel();
   response_panel.setLayout(new BorderLayout());
   response_panel.add(response_label, BorderLayout.NORTH);
   response_panel.add(response_scroll, BorderLayout.CENTER);
   details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
   details_soap.setTopComponent(request_panel);
   details_soap.setRightComponent(response_panel);
   details_soap.setResizeWeight(.5);
   details_panel = new JPanel();
   layout_button = new JButton("Switch Layout");
   layout_button.addActionListener(this);
   reflow_xml = new JCheckBox("Reflow XML text");
   reflow_xml.addActionListener(this);
   details_buttons = new JPanel();
   details_buttons.setLayout(new FlowLayout());
   details_buttons.add(reflow_xml);
   details_buttons.add(layout_button);
   details_panel.setLayout(new BorderLayout());
   details_panel.add(details_header, BorderLayout.NORTH);
   details_panel.add(details_soap, BorderLayout.CENTER);
   details_panel.add(details_buttons, BorderLayout.SOUTH);
   details_panel.setBorder(empty_border);
   // Add the two parts to the age split pane
   split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
   split.setTopComponent(list_panel);
   split.setRightComponent(details_panel);
   // Build status area
   start_button = new JButton("Start");
   start_button.addActionListener(this);
   stop_button = new JButton("Stop");
   stop_button.addActionListener(this);
   status_buttons = new JPanel();
   status_buttons.setLayout(new FlowLayout());
   status_buttons.add(start_button);
   status_buttons.add(stop_button);
   status_text = new JLabel();
   status_text.setBorder(new BevelBorder(BevelBorder.LOWERED));
   status_text_panel = new JPanel();
   status_text_panel.setLayout(new BorderLayout());
   status_text_panel.add(status_text, BorderLayout.CENTER);
   status_text_panel.setBorder(empty_border);
   status_area = new JPanel();
   status_area.setLayout(new BorderLayout());
   status_area.add(status_buttons, BorderLayout.WEST);
   status_area.add(status_text_panel, BorderLayout.CENTER);
   status_area.setBorder(etched_border);
   // Add the split and status area to page
   setLayout(new BorderLayout());
   add(split, BorderLayout.CENTER);
   add(status_area, BorderLayout.SOUTH);
 }
Пример #21
0
 public RowLabel(String s) {
   super(s);
   Dimension d = this.getPreferredSize();
   d.width = 140;
   this.setPreferredSize(d);
 }