java.awt.Insets Java Examples
The following examples show how to use
java.awt.Insets.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroupLayout.java From TencentKona-8 with GNU General Public License v2.0 | 7 votes |
/** * Lays out the specified container. * * @param parent the container to be laid out * @throws IllegalStateException if any of the components added to * this layout are not in both a horizontal and vertical group */ public void layoutContainer(Container parent) { // Step 1: Prepare for layout. prepare(SPECIFIC_SIZE); Insets insets = parent.getInsets(); int width = parent.getWidth() - insets.left - insets.right; int height = parent.getHeight() - insets.top - insets.bottom; boolean ltr = isLeftToRight(); if (getAutoCreateGaps() || getAutoCreateContainerGaps() || hasPreferredPaddingSprings) { // Step 2: Calculate autopadding springs calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0, width); calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0, height); } // Step 3: set the size of the groups. horizontalGroup.setSize(HORIZONTAL, 0, width); verticalGroup.setSize(VERTICAL, 0, height); // Step 4: apply the size to the components. for (ComponentInfo info : componentInfos.values()) { info.setBounds(insets, width, ltr); } }
Example #2
Source File: MultiBorderLayout.java From workcraft with MIT License | 6 votes |
private Dimension layoutSize(final Container target, final DimensionGetter getter) { synchronized (target.getTreeLock()) { final Dimension northSize = sumHorizontal(northList, getter); final Dimension southSize = sumHorizontal(southList, getter); final Dimension westSize = sumVertical(westList, getter); final Dimension eastSize = sumVertical(eastList, getter); final Dimension centerSize = sumCenter(centerList, getter); final Dimension dim = new Dimension( max(northSize.width, southSize.width, westSize.width + centerSize.width + eastSize.width), northSize.height + max(westSize.height, centerSize.height, eastSize.height) + southSize.height); final Insets insets = target.getInsets(); dim.width += insets.left + insets.right; dim.height += insets.top + insets.bottom; return dim; } }
Example #3
Source File: ColorWellUI.java From pumpernickel with MIT License | 6 votes |
@Override public void paint(Graphics g0, JComponent c) { Graphics2D g = (Graphics2D) g0; JColorWell well = (JColorWell) c; Color color = well.getColorSelectionModel().getSelectedColor(); Border border = c.getBorder(); Insets borderInsets = border.getBorderInsets(c); if (color.getAlpha() < 255) { TexturePaint checkers = PlafPaintUtils.getCheckerBoard(8); g.setPaint(checkers); g.fillRect(borderInsets.left, borderInsets.top, c.getWidth() - borderInsets.left - borderInsets.right, c.getHeight() - borderInsets.top - borderInsets.bottom); } g.setColor(color); g.fillRect(borderInsets.left, borderInsets.top, c.getWidth() - borderInsets.left - borderInsets.right, c.getHeight() - borderInsets.top - borderInsets.bottom); }
Example #4
Source File: GroupLayout.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Lays out the specified container. * * @param parent the container to be laid out * @throws IllegalStateException if any of the components added to * this layout are not in both a horizontal and vertical group */ public void layoutContainer(Container parent) { // Step 1: Prepare for layout. prepare(SPECIFIC_SIZE); Insets insets = parent.getInsets(); int width = parent.getWidth() - insets.left - insets.right; int height = parent.getHeight() - insets.top - insets.bottom; boolean ltr = isLeftToRight(); if (getAutoCreateGaps() || getAutoCreateContainerGaps() || hasPreferredPaddingSprings) { // Step 2: Calculate autopadding springs calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0, width); calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0, height); } // Step 3: set the size of the groups. horizontalGroup.setSize(HORIZONTAL, 0, width); verticalGroup.setSize(VERTICAL, 0, height); // Step 4: apply the size to the components. for (ComponentInfo info : componentInfos.values()) { info.setBounds(insets, width, ltr); } }
Example #5
Source File: MatteBorder.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private Insets computeInsets(Insets insets) { if (tileIcon != null && top == -1 && bottom == -1 && left == -1 && right == -1) { int w = tileIcon.getIconWidth(); int h = tileIcon.getIconHeight(); insets.top = h; insets.right = w; insets.bottom = h; insets.left = w; } else { insets.left = left; insets.top = top; insets.right = right; insets.bottom = bottom; } return insets; }
Example #6
Source File: MetalBorders.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public Insets getBorderInsets(Component c, Insets insets) { Insets margin = null; if (c instanceof AbstractButton) { margin = ((AbstractButton)c).getMargin(); } if (margin == null || margin instanceof UIResource) { // default margin so replace insets.left = left; insets.top = top; insets.right = right; insets.bottom = bottom; } else { // Margin which has been explicitly set by the user. insets.left = margin.left; insets.top = margin.top; insets.right = margin.right; insets.bottom = margin.bottom; } return insets; }
Example #7
Source File: PasswordDialog.java From javamoney-examples with Apache License 2.0 | 6 votes |
private Panel createPasswordPanel() { Panel panel = new Panel(); String gap = ": "; // Build panel. panel.setAnchor(GridBagConstraints.EAST); panel.add(getSharedProperty("password") + gap, 0, 0, 1, 1, 0, 50); panel.add(getProperty("retype") + gap, 0, 1, 1, 1, 0, 50); panel.setFill(GridBagConstraints.HORIZONTAL); panel.add(getFields()[PASSWORD], 1, 0, 1, 1, 100, 0); panel.add(getFields()[PASSWORD_CONFIRM], 1, 1, 1, 1, 0, 0); panel.setInsets(new Insets(10, 10, 10, 150)); return panel; }
Example #8
Source File: ScrollPaneLayout.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the <code>Rectangle</code> <code>available</code> based on if * the horizontal scrollbar is needed (<code>wantsHSB</code>). * The location of the hsb is updated in <code>hsbR</code>, and * the viewport border insets (<code>vpbInsets</code>) are used to offset * the hsb. This is only called when <code>wantsHSB</code> has * changed, eg you shouldn't invoked adjustForHSB(true) twice. */ private void adjustForHSB(boolean wantsHSB, Rectangle available, Rectangle hsbR, Insets vpbInsets) { int oldHeight = hsbR.height; if (wantsHSB) { int hsbHeight = Math.max(0, Math.min(available.height, hsb.getPreferredSize().height)); available.height -= hsbHeight; hsbR.y = available.y + available.height + vpbInsets.bottom; hsbR.height = hsbHeight; } else { available.height += oldHeight; } }
Example #9
Source File: MarkerBarUI.java From microba with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void calculateViewRectAndBaseline(MarkerBar bar) { Insets insets = bar.getInsets(); viewRect.x = insets.left; viewRect.y = insets.top; viewRect.width = bar.getWidth() - (insets.right + viewRect.x); viewRect.height = bar.getHeight() - (insets.bottom + viewRect.y); if (bar.getOrientation() == SwingConstants.HORIZONTAL) { baselineLeft = viewRect.x + MARKER_BODY_WIDTH / 2; baselineLength = viewRect.width - MARKER_BODY_WIDTH - 1; if (bar.isFliped()) { baselineTop = viewRect.y; } else { baselineTop = viewRect.y + viewRect.height - 1; } } else { baselineLeft = viewRect.y + MARKER_BODY_WIDTH / 2; baselineLength = viewRect.height - MARKER_BODY_WIDTH - 1; if (bar.isFliped()) { baselineTop = viewRect.x + viewRect.width - 1; } else { baselineTop = viewRect.x; } } }
Example #10
Source File: BasicLabelUI.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private String layout(JLabel label, FontMetrics fm, int width, int height) { Insets insets = label.getInsets(null); String text = label.getText(); Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon(); Rectangle paintViewR = new Rectangle(); paintViewR.x = insets.left; paintViewR.y = insets.top; paintViewR.width = width - (insets.left + insets.right); paintViewR.height = height - (insets.top + insets.bottom); paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0; paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0; return layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR); }
Example #11
Source File: MotifBorders.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Reinitialize the insets parameter with this Border's current Insets. * @param c the component for which this border insets value applies * @param insets the object to be reinitialized */ public Insets getBorderInsets(Component c, Insets insets) { if (!(c instanceof JPopupMenu)) { return insets; } FontMetrics fm; int descent = 0; int ascent = 16; String title = ((JPopupMenu)c).getLabel(); if (title == null) { insets.left = insets.top = insets.right = insets.bottom = 0; return insets; } fm = c.getFontMetrics(font); if(fm != null) { descent = fm.getDescent(); ascent = fm.getAscent(); } insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT; return insets; }
Example #12
Source File: CharacterSheetLayout.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void layoutContainer(Container target) { Component[] children = target.getComponents(); if (children.length > 0) { Dimension size = children[0].getPreferredSize(); Dimension avail = target.getSize(); Insets insets = target.getInsets(); int x = insets.left; int y = insets.top; int margin = mSheet.getScale().scale(MARGIN); for (Component child : children) { child.setBounds(x, y, size.width, size.height); x += size.width + margin; if (x + size.width + insets.right > avail.width) { x = insets.left; y += size.height + margin; } } } }
Example #13
Source File: MultiSplitContainer.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void mousePressed(MouseEvent e) { if (inDivider) { canDrag = true; dragX = e.getX(); offsetX = dragX - dividerOffsets.get(offsetIdx); Insets insets = getInsets(); minX = offsetIdx == 0 ? insets.left : dividerOffsets.get(offsetIdx - 1) + DIVIDER_SIZE; maxX = offsetIdx == dividerOffsets.size() - 1 ? getWidth() - insets.right - DIVIDER_SIZE : dividerOffsets.get(offsetIdx + 1) - DIVIDER_SIZE; c1 = visibleComponents.get(offsetIdx); c2 = visibleComponents.get(offsetIdx + 1); relWidth = componentsWeights.get(c1) + componentsWeights.get(c2); } }
Example #14
Source File: FlatPopupFactory.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override public void show() { if( dropShadowDelegate != null ) dropShadowDelegate.show(); if( mediumWeightPanel != null ) showMediumWeightDropShadow(); super.show(); // fix location of light weight popup in case it has left or top drop shadow if( lightComp != null ) { Insets insets = lightComp.getInsets(); if( insets.left != 0 || insets.top != 0 ) lightComp.setLocation( lightComp.getX() - insets.left, lightComp.getY() - insets.top ); } }
Example #15
Source File: DrawingViewPlacardPanel.java From openAGV with Apache License 2.0 | 6 votes |
/** * Creates a button to toglle the labels. * * @param view The DrawingView the button will belong to. * @return The created button. */ private JToggleButton toggleLabelsButton(final OpenTCSDrawingView drawingView) { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setToolTipText( labels.getString("drawingViewPlacardPanel.button_toggleLabels.tooltipText") ); toggleButton.setIcon(ImageDirectory.getImageIcon("/menu/comment-add.16.png")); toggleButton.setMargin(new Insets(0, 0, 0, 0)); toggleButton.setFocusable(false); toggleButton.addItemListener( (ItemEvent event) -> drawingView.setLabelsVisible(toggleButton.isSelected()) ); return toggleButton; }
Example #16
Source File: MotifBorders.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Reinitialize the insets parameter with this Border's current Insets. * @param c the component for which this border insets value applies * @param insets the object to be reinitialized */ public Insets getBorderInsets(Component c, Insets insets) { if (!(c instanceof JPopupMenu)) { return insets; } FontMetrics fm; int descent = 0; int ascent = 16; String title = ((JPopupMenu)c).getLabel(); if (title == null) { insets.left = insets.top = insets.right = insets.bottom = 0; return insets; } fm = c.getFontMetrics(font); if(fm != null) { descent = fm.getDescent(); ascent = fm.getAscent(); } insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT; return insets; }
Example #17
Source File: VerticalFlowLayout.java From xyTalk-pc with GNU Affero General Public License v3.0 | 6 votes |
/** * Returns the preferred dimensions given the components * in the target container. * * @param target the component to lay out */ public Dimension preferredLayoutSize(Container target) { Dimension tarsiz = new Dimension(0, 0); for (int i = 0; i < target.getComponentCount(); i++) { Component m = target.getComponent(i); if (m.isVisible()) { Dimension d = m.getPreferredSize(); tarsiz.width = Math.max(tarsiz.width, d.width); if (i > 0) { tarsiz.height += hgap; } tarsiz.height += d.height; } } Insets insets = target.getInsets(); tarsiz.width += insets.left + insets.right + hgap * target.getComponentCount(); tarsiz.height += insets.top + insets.bottom + vgap * target.getComponentCount(); return tarsiz; }
Example #18
Source File: InternalUtilities.java From LGoodDatePicker with MIT License | 6 votes |
/** * getScreenWorkingArea, This returns the working area of the screen. (The working area excludes * any task bars.) This function accounts for multi-monitor setups. If a window is supplied, * then the the monitor that contains the window will be used. If a window is not supplied, then * the primary monitor will be used. */ static public Rectangle getScreenWorkingArea(Window windowOrNull) { Insets insets; Rectangle bounds; if (windowOrNull == null) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); insets = Toolkit.getDefaultToolkit().getScreenInsets(ge.getDefaultScreenDevice() .getDefaultConfiguration()); bounds = ge.getDefaultScreenDevice().getDefaultConfiguration().getBounds(); } else { GraphicsConfiguration gc = windowOrNull.getGraphicsConfiguration(); insets = windowOrNull.getToolkit().getScreenInsets(gc); bounds = gc.getBounds(); } bounds.x += insets.left; bounds.y += insets.top; bounds.width -= (insets.left + insets.right); bounds.height -= (insets.top + insets.bottom); return bounds; }
Example #19
Source File: PortraitPane.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Dimension getPreferredSize() { Insets insets = getInsets(); int width = 0; int height = 0; if (insets != null) { width += insets.left + insets.right; height += insets.top + insets.bottom; } if (portrait != null) { if (scale < 1) { width += (int) (scale * portrait.getWidth()); height += (int) (scale * portrait.getHeight()); } else { width += portrait.getWidth(); height += portrait.getHeight(); } } return new Dimension(width, height); }
Example #20
Source File: OutlineHeader.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * @param column The column. * @return The bounds of the specified header column. */ public Rectangle getColumnBounds(Column column) { Insets insets = getInsets(); Rectangle bounds = new Rectangle(insets.left, insets.top, getWidth() - (insets.left + insets.right), getHeight() - (insets.top + insets.bottom)); bounds.x = mOwner.getColumnStart(column); bounds.width = column.getWidth(); return bounds; }
Example #21
Source File: GroupLayout.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void setBounds(Insets insets, int parentWidth, boolean ltr) { int x = horizontalSpring.getOrigin(); int w = horizontalSpring.getSize(); int y = verticalSpring.getOrigin(); int h = verticalSpring.getSize(); if (!ltr) { x = parentWidth - x - w; } component.setBounds(x + insets.left, y + insets.top, w, h); }
Example #22
Source File: EnableButton.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public EnableButton(Group group, int type) { super(icons[type]); this.group = group; this.type = type; addActionListener(this); setMargin(new Insets(0, 0, 0, 0)); setBorderPainted(false); }
Example #23
Source File: RosterMemberCallButton.java From Spark with Apache License 2.0 | 5 votes |
/** * Decorates the button with the approriate UI configurations. */ private void decorate() { setBorderPainted(false); setOpaque(true); setContentAreaFilled(false); setMargin(new Insets(0, 0, 0, 0)); }
Example #24
Source File: EnableButton.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public EnableButton(Group group, int type) { super(icons[type]); this.group = group; this.type = type; addActionListener(this); setMargin(new Insets(0, 0, 0, 0)); setBorderPainted(false); }
Example #25
Source File: ConnectionPropertiesPanel.java From bigtable-sql with Apache License 2.0 | 5 votes |
private void addSqlTextAreaPanel(final GridBagConstraints gbc) { gbc.weighty = .7; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(10, 25, 10, 10); JPanel textPanel = new JPanel(); textPanel.setLayout(new BorderLayout()); textPanel.add(sqlTextArea, BorderLayout.CENTER); add(textPanel, gbc); }
Example #26
Source File: SplitDialog.java From javamoney-examples with Apache License 2.0 | 5 votes |
private Panel createDetailsPanel() { Panel panel = new Panel(); Panel details = new Panel(); String gap = ": "; // Build details panel. details.setAnchor(GridBagConstraints.EAST); details.add(getProperty("sum") + gap, 0, 0, 1, 1, 0, 33); details.add(getProperty("unassigned") + gap, 0, 1, 1, 1, 0, 33); details.add(getProperty("total") + gap, 0, 2, 1, 1, 0, 34); details.setAnchor(GridBagConstraints.WEST); for(int len = 0; len < getLabels().length; ++len) { details.add(getLabels()[len], 1, len, 1, 1, 100, 0); } details.setBorder(createTitledBorder(getProperty("details"))); // Build panel. panel.setFill(GridBagConstraints.BOTH); panel.add(details, 0, 0, 1, 1, 100, 100); panel.setInsets(new Insets(0, 15, 0, 15)); return panel; }
Example #27
Source File: ToolBarSeparatorPainter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override protected PaintContext getPaintContext() { //the paint context returned will have a few dummy values. The //implementation of doPaint doesn't bother with the "decode" methods //but calculates where to paint the circles manually. As such, we //only need to indicate in our PaintContext that we don't want this //to ever be cached return new PaintContext( new Insets(1, 0, 1, 0), new Dimension(38, 7), false, CacheMode.NO_CACHING, 1, 1); }
Example #28
Source File: EditSettingsControlPanel.java From VanetSim with GNU General Public License v3.0 | 5 votes |
/** * Creates the panel which is shown when mix zones are enabled. * * @return the mix zones panel */ private final JPanel createMixPanel(){ JPanel panel = new JPanel(); panel.setOpaque(false); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.PAGE_START; c.weightx = 1; c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.insets = new Insets(5,0,5,0); JLabel jLabel1 = new JLabel(Messages.getString("EditSettingsControlPanel.mixZoneSize")); //$NON-NLS-1$ panel.add(jLabel1,c); mixZoneRadius_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); mixZoneRadius_.setPreferredSize(new Dimension(60,20)); mixZoneRadius_.setValue(100); mixZoneRadius_.addPropertyChangeListener("value", this); //$NON-NLS-1$ c.gridx = 1; c.weightx = 0; panel.add(mixZoneRadius_,c); c.gridx = 0; c.gridwidth = 2; ++c.gridy; fallbackInMixZonesCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.fallbackCommunicationInMixZones"), true); //$NON-NLS-1$ fallbackInMixZonesCheckBox_.addItemListener(this); panel.add(fallbackInMixZonesCheckBox_,c); ++c.gridy; fallbackInMixZonesPanel_ = createMixFallBackPanel(); panel.add(fallbackInMixZonesPanel_,c); return panel; }
Example #29
Source File: BasicGraphicsUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap) { if(b.getComponentCount() > 0) { return null; } Icon icon = b.getIcon(); String text = b.getText(); Font font = b.getFont(); FontMetrics fm = b.getFontMetrics(font); Rectangle iconR = new Rectangle(); Rectangle textR = new Rectangle(); Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE); SwingUtilities.layoutCompoundLabel( b, fm, text, icon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewR, iconR, textR, (text == null ? 0 : textIconGap) ); /* The preferred size of the button is the size of * the text and icon rectangles plus the buttons insets. */ Rectangle r = iconR.union(textR); Insets insets = b.getInsets(); r.width += insets.left + insets.right; r.height += insets.top + insets.bottom; return r.getSize(); }
Example #30
Source File: ButtonToolBar.java From HubPlayer with GNU General Public License v3.0 | 5 votes |
public ButtonToolBar() { setMargin(new Insets(0, 5, 5, 5)); setFloatable(false); setOpaque(false); setBorderPainted(false); }