コード例 #1
0
 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);
 }
コード例 #2
0
 public void processCellResized(
     RadContainer container, final boolean isRow, final int cell, final int newSize) {
   int cellCount = isRow ? container.getGridRowCount() : container.getGridColumnCount();
   if (container.getParent().isXY() && cell == cellCount - 1) {
     processRootContainerResize(container, isRow, newSize);
   } else {
     for (RadComponent component : container.getComponents()) {
       GridConstraints c = component.getConstraints();
       if (c.getCell(isRow) == cell && c.getSpan(isRow) == 1) {
         Dimension preferredSize = new Dimension(c.myPreferredSize);
         if (isRow) {
           preferredSize.height = newSize;
           if (preferredSize.width == -1) {
             preferredSize.width = component.getDelegee().getPreferredSize().width;
           }
         } else {
           preferredSize.width = newSize;
           if (preferredSize.height == -1) {
             preferredSize.height = component.getDelegee().getPreferredSize().height;
           }
         }
         PreferredSizeProperty.getInstance(container.getProject())
             .setValueEx(component, preferredSize);
       }
     }
   }
 }
コード例 #3
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;
      }
    }
コード例 #4
0
  @Override
  public void updateMinimumSize() {
    final Dimension min;
    if (getTarget().isMinimumSizeSet()) {
      min = getTarget().getMinimumSize();
      min.width = Math.max(min.width, MINIMUM_WIDTH);
      min.height = Math.max(min.height, MINIMUM_HEIGHT);
    } else {
      min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
    }

    final int maxW, maxH;
    if (graphicsConfig instanceof TextureSizeConstraining) {
      maxW = ((TextureSizeConstraining) graphicsConfig).getMaxTextureWidth();
      maxH = ((TextureSizeConstraining) graphicsConfig).getMaxTextureHeight();
    } else {
      maxW = maxH = Integer.MAX_VALUE;
    }

    final Dimension max;
    if (getTarget().isMaximumSizeSet()) {
      max = getTarget().getMaximumSize();
      max.width = Math.min(max.width, maxW);
      max.height = Math.min(max.height, maxH);
    } else {
      max = new Dimension(maxW, maxH);
    }

    platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
  }
コード例 #5
0
  private void checkSizes() {
    Dimension vsz = scroll_pane.getViewport().getViewSize();
    Dimension csz = draw_area.getSize();
    Dimension nsz = new Dimension((int) (vsz.width * x_scale), (int) (vsz.height * y_scale));
    boolean chng = false;

    if (nsz.width > csz.width) {
      if (vsz.width >= csz.width) {
        csz.width = vsz.width;
        chng = true;
        x_scale = 1;
      }
    } else if (nsz.width < csz.width) {
      if (x_scale == 1) {
        csz.width = vsz.width;
        chng = true;
      }
    }

    if (nsz.height > csz.height) {
      if (vsz.height >= csz.height) {
        csz.height = vsz.height;
        chng = true;
        y_scale = 1;
      }
    } else if (nsz.height < csz.height) {
      if (y_scale == 1) {
        csz.height = vsz.height;
        chng = true;
      }
    }

    if (chng) draw_area.setSize(csz);
  }
コード例 #6
0
ファイル: Viewport.java プロジェクト: TurboVNC/turbovnc
 public Dimension getAvailableSize() {
   Dimension availableSize = getSize();
   if (!cc.opts.fullScreen) {
     Insets vpInsets = VncViewer.insets;
     availableSize.width -= vpInsets.left + vpInsets.right;
     availableSize.height -= vpInsets.top + vpInsets.bottom;
   }
   if (tb.isVisible()) availableSize.height -= tb.getHeight();
   if (availableSize.width < 0) availableSize.width = 0;
   if (availableSize.height < 0) availableSize.height = 0;
   return availableSize;
 }
コード例 #7
0
ファイル: VText.java プロジェクト: timburrow/OpenVnmrJ
 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;
   super.reshape(x, y, w, h);
 }
コード例 #8
0
ファイル: BaseSliderUI.java プロジェクト: recon88/Botnak
 protected Dimension getThumbSize() {
   Dimension size = super.getThumbSize();
   if ((getThumbHorIcon() != null) && (getThumbVerIcon() != null)) {
     if (slider.getOrientation() == JSlider.HORIZONTAL) {
       size.width = getThumbHorIcon().getIconWidth();
       size.height = getThumbHorIcon().getIconHeight();
     } else {
       size.width = getThumbVerIcon().getIconWidth();
       size.height = getThumbVerIcon().getIconHeight();
     }
   }
   return size;
 }
コード例 #9
0
  public RoundButton(String label) {
    super(label);

    // These statements enlarge the button so that it
    // becomes a circle rather than an oval.
    Dimension size = getPreferredSize();
    size.width = size.height = Math.max(size.width, size.height);
    setPreferredSize(size);

    // This call causes the JButton not to paint
    // the background.
    // This allows us to paint a round background.
    setContentAreaFilled(false);
  }
コード例 #10
0
 @Override
 public Dimension getPreferredSize() {
   Dimension size = super.getPreferredSize();
   UIManager.LookAndFeelInfo info = LafManager.getInstance().getCurrentLookAndFeel();
   if (info != null && info.getName().contains("Windows")) size.width += 10;
   return size;
 }
コード例 #11
0
ファイル: SourcePanel.java プロジェクト: cecemel/Util
 public HeaderPanel(String heading) {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(background);
   JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT);
   Font labelFont = new Font("Dialog", Font.BOLD, 18);
   panelLabel.setFont(labelFont);
   this.add(panelLabel);
   this.add(Box.createHorizontalGlue());
   refresh = new JButton("Refresh");
   refresh.addActionListener(this);
   this.add(refresh);
   this.add(Box.createHorizontalStrut(5));
   root = new JComboBox();
   Dimension d = root.getPreferredSize();
   d.width = 90;
   root.setPreferredSize(d);
   root.setMaximumSize(d);
   File[] roots = directoryPane.getRoots();
   for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath());
   this.add(root);
   root.setSelectedIndex(directoryPane.getCurrentRootIndex());
   root.addActionListener(this);
   this.add(Box.createHorizontalStrut(17));
 }
コード例 #12
0
ファイル: DynamicCustomizer.java プロジェクト: Rajmohan/acre
 /**
  * Returns the preferred size of the viewport for a view component. For example the preferredSize
  * of a JList component is the size required to acommodate all of the cells in its list however
  * the value of preferredScrollableViewportSize is the size required for
  * JList.getVisibleRowCount() rows. A component without any properties that would effect the
  * viewport size should just return getPreferredSize() here.
  *
  * @return The preferredSize of a JViewport whose view is this Scrollable.
  * @see JViewport#getPreferredSize
  */
 public Dimension getPreferredScrollableViewportSize() {
   Dimension size = getPreferredSize();
   Dimension retval = new Dimension();
   retval.width = size.width > 600 ? 600 : size.width;
   retval.height = size.height > 400 ? 400 : size.height;
   return retval;
 }
コード例 #13
0
 @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;
 }
コード例 #14
0
 @Override
 public Dimension getPreferredSize() {
   final Dimension size = super.getPreferredSize();
   size.width += (myMoreRec.width + myDownIconInsets.left + myDownIconInsets.right);
   size.height += (myDownIconInsets.top + myDownIconInsets.bottom);
   return size;
 }
コード例 #15
0
  /**
   * Randomly picks the location of a new window, such that it fits completely on the screen.
   *
   * @param desktopPane the desktop pane that the frame is being added to.
   * @param frame the JInternalFrame which is being added.
   * @param desiredSize the desired dimensions of the frame.
   */
  private static void setGoodBounds(
      JInternalFrame frame, JDesktopPane desktopPane, Dimension desiredSize) {
    RandomUtil randomUtil = RandomUtil.getInstance();
    Dimension desktopSize = desktopPane.getSize();

    Dimension d = new Dimension(desiredSize);
    int tx = desktopSize.width - d.width;
    int ty = desktopSize.height - d.height;

    if (tx < 0) {
      tx = 0;
      d.width = desktopSize.width;
    } else {
      tx = (int) (randomUtil.nextDouble() * tx);
    }

    if (ty < 0) {
      ty = 0;
      d.height = desktopSize.height;
    } else {
      ty = (int) (randomUtil.nextDouble() * ty);
    }

    frame.setBounds(tx, ty, d.width, d.height);
  }
コード例 #16
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;
  }
コード例 #17
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;
    }
コード例 #18
0
    @Override
    public void layoutContainer(final Container parent) {
      final int componentCount = parent.getComponentCount();
      if (componentCount == 0) return;
      final EditorEx history = myHistoryViewer;
      final EditorEx editor = componentCount == 2 ? myConsoleEditor : null;

      if (editor == null) {
        parent.getComponent(0).setBounds(parent.getBounds());
        return;
      }

      final Dimension panelSize = parent.getSize();
      if (panelSize.getHeight() <= 0) return;
      final Dimension historySize = history.getContentSize();
      final Dimension editorSize = editor.getContentSize();
      final Dimension newEditorSize = new Dimension();

      // deal with width
      final int width = Math.max(editorSize.width, historySize.width);
      newEditorSize.width = width + editor.getScrollPane().getHorizontalScrollBar().getHeight();
      history.getSoftWrapModel().forceAdditionalColumnsUsage();
      editor
          .getSettings()
          .setAdditionalColumnsCount(
              2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor));
      history
          .getSettings()
          .setAdditionalColumnsCount(
              2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history));

      // deal with height
      if (historySize.width == 0) historySize.height = 0;
      final int minHistorySize =
          historySize.height > 0
              ? 2 * history.getLineHeight() + (myShowSeparatorLine ? SEPARATOR_THICKNESS : 0)
              : 0;
      final int minEditorSize = editor.isViewer() ? 0 : editor.getLineHeight();
      final int editorPreferred =
          editor.isViewer() ? 0 : Math.max(minEditorSize, editorSize.height);
      final int historyPreferred = Math.max(minHistorySize, historySize.height);
      if (panelSize.height < minEditorSize) {
        newEditorSize.height = panelSize.height;
      } else if (panelSize.height < editorPreferred) {
        newEditorSize.height = panelSize.height - minHistorySize;
      } else if (panelSize.height < editorPreferred + historyPreferred) {
        newEditorSize.height = editorPreferred;
      } else {
        newEditorSize.height = editorPreferred == 0 ? 0 : panelSize.height - historyPreferred;
      }
      final Dimension newHistorySize =
          new Dimension(width, panelSize.height - newEditorSize.height);

      // apply
      editor
          .getComponent()
          .setBounds(0, newHistorySize.height, panelSize.width, newEditorSize.height);
      myForceScrollToEnd.compareAndSet(false, shouldScrollHistoryToEnd());
      history.getComponent().setBounds(0, 0, panelSize.width, newHistorySize.height);
    }
コード例 #19
0
ファイル: ActionBar.java プロジェクト: RoDaniel/featurehouse
  public ActionBar(View view, boolean temp) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    this.view = view;
    this.temp = temp;

    add(Box.createHorizontalStrut(2));

    JLabel label = new JLabel(jEdit.getProperty("view.action.prompt"));
    add(label);
    add(Box.createHorizontalStrut(12));
    add(action = new ActionTextField());
    action.setEnterAddsToHistory(false);
    Dimension max = action.getPreferredSize();
    max.width = Integer.MAX_VALUE;
    action.setMaximumSize(max);
    action.addActionListener(new ActionHandler());
    action.getDocument().addDocumentListener(new DocumentHandler());

    if (temp) {
      close = new RolloverButton(GUIUtilities.loadIcon("closebox.gif"));
      close.addActionListener(new ActionHandler());
      close.setToolTipText(jEdit.getProperty("view.action.close-tooltip"));
      add(close);
    }

    this.temp = temp;
  }
コード例 #20
0
  /*
   *  Adjust the width of the scrollpane used by the popup
   */
  protected void popupWider(BasicComboPopup popup) {
    JList list = popup.getList();

    //  Determine the maximimum width to use:
    //  a) determine the popup preferred width
    //  b) limit width to the maximum if specified
    //  c) ensure width is not less than the scroll pane width

    int popupWidth =
        list.getPreferredSize().width
            + 5 // make sure horizontal scrollbar doesn't appear
            + getScrollBarWidth(popup, scrollPane);

    if (maximumWidth != -1) {
      popupWidth = Math.min(popupWidth, maximumWidth);
    }

    Dimension scrollPaneSize = scrollPane.getPreferredSize();
    popupWidth = Math.max(popupWidth, scrollPaneSize.width);

    //  Adjust the width

    scrollPaneSize.width = popupWidth;
    scrollPane.setPreferredSize(scrollPaneSize);
    scrollPane.setMaximumSize(scrollPaneSize);
  }
コード例 #21
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;
    }
コード例 #22
0
ファイル: JEditTextArea.java プロジェクト: zeph/grinder
    public Dimension minimumLayoutSize(Container parent) {
      Dimension dim = new Dimension();
      Insets insets = getInsets();
      dim.width = insets.left + insets.right;
      dim.height = insets.top + insets.bottom;

      Dimension centerPref = center.getMinimumSize();
      dim.width += centerPref.width;
      dim.height += centerPref.height;
      Dimension rightPref = right.getMinimumSize();
      dim.width += rightPref.width;
      Dimension bottomPref = bottom.getMinimumSize();
      dim.height += bottomPref.height;

      return dim;
    }
コード例 #23
0
  void jButtonWeights_actionPerformed(ActionEvent e) {
    NumberGeneratorDialog dlg =
        new NumberGeneratorDialog(
            (Frame) null,
            "Weights",
            "Weight of synaptic connections",
            mySynProps.getWeightsGenerator(),
            true);

    // Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dlg.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    dlg.setLocation(
        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    dlg.setVisible(true);

    jTextFieldWeights.setText(mySynProps.getWeightsGenerator().toShortString());

    // mySynProps.setWeightsGenerator(dlg.getFinalNumGen());
  }
コード例 #24
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#getPreferredSize(javax
   * .swing.JComponent)
   */
  @Override
  public Dimension getPreferredSize(JComponent c) {
    AbstractCommandButton button = (AbstractCommandButton) c;
    SubstanceButtonShaper shaper = SubstanceCoreUtilities.getButtonShaper(button);

    Dimension superPref = super.getPreferredSize(button);
    if (superPref == null) return null;

    if (shaper == null) return superPref;

    // fix for issue 35 on Flamingo - do not enforce
    // min size on buttons in the ribbon
    // Additional fix - buttons with popup action should
    // not have min size enforced as well
    // Additional fix - buttons in popup menus and breadcrumb bars should
    // not have min size enforced
    if ((button.getDisplayState() == CommandButtonDisplayState.MEDIUM)
        && (SwingUtilities.getAncestorOfClass(AbstractRibbonBand.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JBreadcrumbBar.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JCommandPopupMenu.class, button) == null)) {
      JButton dummy = new JButton(button.getText(), button.getIcon());
      Dimension result = shaper.getPreferredSize(dummy, superPref);
      if (FlamingoUtilities.hasPopupAction(button)) {
        result.width = superPref.width;
      }
      return result;
    }
    return superPref;
  }
コード例 #25
0
 public SVRowHeader(HSSFSheet sheet, JTable table) {
   super(new SVRowHeaderModel(sheet));
   Dimension d = getPreferredScrollableViewportSize();
   this.table = table;
   d.width = getPreferredSize().width;
   setPreferredScrollableViewportSize(d);
   setDefaultRenderer(Object.class, new RowHeaderRenderer(table));
 }
コード例 #26
0
  public Dimension getPreferredSize(JComponent c) {
    Dimension size;
    Insets border = progressBar.getInsets();
    FontMetrics fontSizer = progressBar.getFontMetrics(progressBar.getFont());

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      size = new Dimension(getPreferredInnerHorizontal());
      // Ensure that the progress string will fit
      if (progressBar.isStringPainted()) {
        // I'm doing this for completeness.
        String progString = progressBar.getString();
        int stringWidth = SwingUtilities2.stringWidth(progressBar, fontSizer, progString);
        if (stringWidth > size.width) {
          size.width = stringWidth;
        }
        // This uses both Height and Descent to be sure that
        // there is more than enough room in the progress bar
        // for everything.
        // This does have a strange dependency on
        // getStringPlacememnt() in a funny way.
        int stringHeight = fontSizer.getHeight() + fontSizer.getDescent();
        if (stringHeight > size.height) {
          size.height = stringHeight;
        }
      }
    } else {
      size = new Dimension(getPreferredInnerVertical());
      // Ensure that the progress string will fit.
      if (progressBar.isStringPainted()) {
        String progString = progressBar.getString();
        int stringHeight = fontSizer.getHeight() + fontSizer.getDescent();
        if (stringHeight > size.width) {
          size.width = stringHeight;
        }
        // This is also for completeness.
        int stringWidth = SwingUtilities2.stringWidth(progressBar, fontSizer, progString);
        if (stringWidth > size.height) {
          size.height = stringWidth;
        }
      }
    }

    size.width += border.left + border.right;
    size.height += border.top + border.bottom;
    return size;
  }
コード例 #27
0
 @Override
 public Dimension getPreferredSize() {
   Dimension size = super.getPreferredSize();
   if (myWidth != -1) {
     size.width = myWidth;
   }
   return size;
 }
コード例 #28
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;
 }
コード例 #29
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();
  }
コード例 #30
0
  /** The minumum size is the size of the display area plus insets plus the button. */
  public Dimension getMinimumSize(JComponent c) {
    if (!isMinimumSizeDirty) {
      return new Dimension(cachedMinimumSize);
    }
    Dimension size = getDisplaySize();
    Insets insets = getInsets();
    size.height += insets.top + insets.bottom;
    if (comboBox.isEditable()) {
      Insets editorBorderInsets = UIManager.getInsets("ComboBox.editorBorderInsets");
      size.width += editorBorderInsets.left + editorBorderInsets.right;
      // size.height += editorBorderInsets.top + editorBorderInsets.bottom;
      // The combo editor benefits from extra space for the caret.
      // To make editable and non-editable equally wide,
      // we always add 1 pixel.
      size.width += 1;
    } else if (arrowButton != null) {
      Insets arrowButtonInsets = arrowButton.getInsets();
      size.width += arrowButtonInsets.left;
    }
    int buttonWidth = getEditableButtonWidth();
    size.width += insets.left + insets.right + buttonWidth;

    // Honor corrections made in #paintCurrentValue
    ListCellRenderer renderer = comboBox.getRenderer();
    if (renderer instanceof JComponent) {
      JComponent component = (JComponent) renderer;
      Insets rendererInsets = component.getInsets();
      Insets editorInsets = UIManager.getInsets("ComboBox.editorInsets");
      int offsetLeft = Math.max(0, editorInsets.left - rendererInsets.left);
      int offsetRight = Math.max(0, editorInsets.right - rendererInsets.right);
      // int offsetTop    = Math.max(0, editorInsets.top - rendererInsets.top);
      // int offsetBottom = Math.max(0, editorInsets.bottom - rendererInsets.bottom);
      size.width += offsetLeft + offsetRight;
      // size.height += offsetTop + offsetBottom;
    }

    // The height is oriented on the JTextField height
    Dimension textFieldSize = PHANTOM.getMinimumSize();
    size.height = Math.max(textFieldSize.height, size.height);

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

    return new Dimension(size);
  }