@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; }
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; }
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); }
public Dimension getMaximumSize(JComponent c) { Dimension pref = getPreferredSize(progressBar); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { pref.width = Short.MAX_VALUE; } else { pref.height = Short.MAX_VALUE; } return pref; }
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); }
@Override public Dimension getMaximumSize(JComponent c) { String style = (String) c.getClientProperty("Quaqua.Button.style"); if (style != null && style.equals("help")) { return getPreferredSize(c); } Dimension d = super.getMaximumSize(c); if (isFixedHeight(c)) { Dimension p = getPreferredSize(c); d.height = Math.max(d.height, p.height); } return d; }
protected void configureScrollBarColors() { super.configureScrollBarColors(); // The following is a bit of a hack to force the size of the scrollbar. boolean isVertical = (this.scrollbar.getOrientation() == NORTH || this.scrollbar.getOrientation() == SOUTH); Dimension size = this.scrollbar.getPreferredSize(); if (isVertical) { size.width = this.scrollBarWidth; } else { size.height = this.scrollBarWidth; } this.scrollbar.setPreferredSize(size); }
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; }
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(); } }
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; }