Java Code Examples for javax.swing.JComponent#getClientProperty()
The following examples show how to use
javax.swing.JComponent#getClientProperty() .
These examples are extracted from open source projects.
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 Project: netbeans File: DefaultTabbedContainerUI.java License: Apache License 2.0 | 6 votes |
public Dimension minimumLayoutSize(Container parent) { JComponent c = tabDisplayer; Object orientation = c.getClientProperty ( TabDisplayer.PROP_ORIENTATION); Dimension tabSize = tabDisplayer.getPreferredSize(); Insets ins = container.getInsets(); Dimension result = new Dimension(); Dimension contentSize = contentDisplayer.getPreferredSize(); if (tabDisplayer.getSelectionModel().getSelectedIndex() == -1) { contentSize.width = 0; contentSize.height = 0; } if (orientation == TabDisplayer.ORIENTATION_NORTH || orientation == TabDisplayer.ORIENTATION_SOUTH) { result.height = ins.top + ins.bottom + contentSize.height + tabSize.height; result.width = ins.left + ins.right + Math.max (contentSize.width, tabSize.width); } else { result.width = ins.left + ins.right + contentSize.width + tabSize.width; result.height = ins.top + ins.bottom + Math.max (contentSize.height, tabSize.height); } return result; }
Example 2
Source Project: visualvm File: FilterUtils.java License: GNU General Public License v2.0 | 6 votes |
public static void filterSubclasses(String className, JComponent filterPanel) { Object filterString = filterPanel.getClientProperty("FILTER_STRING"); // NOI18N if (filterString instanceof JTextComponent) { ((JTextComponent)filterString).setText(className); } else { return; } Object filterType = filterPanel.getClientProperty("FILTER_TYPE"); // NOI18N if (filterType instanceof FilterType) { ((FilterType)filterType).filterImpl(FILTER_INSTANCEOF, Icons.getIcon(LanguageIcons.CLASS), Bundle.OQLFilterUtils_FilterSubclass()); } else { return; } Object filterAction = filterPanel.getClientProperty("FILTER_ACTION"); // NOI18N if (filterAction instanceof AbstractAction) { ((AbstractAction)filterAction).actionPerformed(null); } else { return; } }
Example 3
Source Project: jbox2d File: TestbedSidePanel.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void stateChanged(ChangeEvent e) { JComponent component = (JComponent) e.getSource(); TestbedSetting setting = (TestbedSetting) component.getClientProperty(SETTING_TAG); switch (setting.constraintType) { case BOOLEAN: JCheckBox box = (JCheckBox) e.getSource(); setting.enabled = box.isSelected(); break; case RANGE: JSlider slider = (JSlider) e.getSource(); setting.value = slider.getValue(); JLabel label = (JLabel) slider.getClientProperty(LABEL_TAG); label.setText(setting.name + ": " + setting.value); break; } model.getPanel().grabFocus(); }
Example 4
Source Project: FlatLaf File: FlatTextFieldUI.java License: Apache License 2.0 | 6 votes |
static void paintPlaceholder( Graphics g, JTextComponent c, Color placeholderForeground ) { // check whether text component is empty if( c.getDocument().getLength() > 0 ) return; // check for JComboBox Container parent = c.getParent(); JComponent jc = (parent instanceof JComboBox) ? (JComboBox<?>) parent : c; // get placeholder text Object placeholder = jc.getClientProperty( FlatClientProperties.PLACEHOLDER_TEXT ); if( !(placeholder instanceof String) ) return; // compute placeholder location Insets insets = c.getInsets(); FontMetrics fm = c.getFontMetrics( c.getFont() ); int x = insets.left; int y = insets.top + fm.getAscent() + ((c.getHeight() - insets.top - insets.bottom - fm.getHeight()) / 2); // paint placeholder g.setColor( placeholderForeground ); FlatUIUtils.drawString( c, g, (String) placeholder, x, y ); }
Example 5
Source Project: seaglass File: TextComponentPainter.java License: Apache License 2.0 | 6 votes |
/** * Test if we should also paint the line seperators. * @param c * @return */ private boolean isPaintLineSeperators(JComponent c) { boolean paintLines = c instanceof JTextArea; // Global settings String globalOverride = System.getProperty("SeaGlass.JTextArea.drawLineSeparator"); if (globalOverride != null && globalOverride.length() > 0) { paintLines = Boolean.valueOf(globalOverride); } // Settings per component Boolean overrideProperty = (Boolean) c.getClientProperty("SeaGlass.JTextArea.drawLineSeparator"); if (overrideProperty != null) { paintLines = overrideProperty; } return paintLines; }
Example 6
Source Project: netbeans File: ComponentPanel.java License: Apache License 2.0 | 5 votes |
private Dimension getSize(JComponent component) { Object object = component.getClientProperty(PrintManager.PRINT_SIZE); if (object instanceof Dimension) { return (Dimension) object; } return null; }
Example 7
Source Project: pumpernickel File: DialogFooter.java License: MIT License | 5 votes |
/** * This indicates that an action button risks losing user's data. On Macs an * unsafe button is spaced farther away from safe buttons. */ public static boolean isUnsafe(JComponent c) { Boolean b = (Boolean) c.getClientProperty(PROPERTY_UNSAFE); if (b == null) b = Boolean.FALSE; return b.booleanValue(); }
Example 8
Source Project: netbeans File: JComponentByLabelFinder.java License: Apache License 2.0 | 5 votes |
public boolean checkComponent(Component c) { if (c instanceof JComponent) { JComponent jc = (JComponent) c; Object o = jc.getClientProperty("labeledBy"); //NOI18N if (o != null && o instanceof JLabel) { JLabel lbl = (JLabel) o; return label.equals(lbl.getText().trim()); } } return false; }
Example 9
Source Project: Java8CN File: NimbusDefaults.java License: Apache License 2.0 | 5 votes |
/** * Gets the style. Creates it if necessary. * @return the style */ SynthStyle getStyle(JComponent c, Region r) { // if the component has overrides, it gets its own unique style // instead of the shared style. if (c.getClientProperty("Nimbus.Overrides") != null) { Map<Region, SynthStyle> map = overridesCache.get(c); SynthStyle s = null; if (map == null) { map = new HashMap<Region, SynthStyle>(); overridesCache.put(c, map); } else { s = map.get(r); } if (s == null) { s = new NimbusStyle(prefix, c); map.put(r, s); } return s; } // lazily create the style if necessary if (style == null) style = new NimbusStyle(prefix, null); // return the style return style; }
Example 10
Source Project: pumpernickel File: VectorImageInspector.java License: MIT License | 5 votes |
BooleanProperty getPopupRequested(JComponent jc) { BooleanProperty b = (BooleanProperty) jc .getClientProperty(PROPERTY_POPUP_REQUESTED); if (b == null) { b = new BooleanProperty(PROPERTY_POPUP_REQUESTED, false); jc.putClientProperty(PROPERTY_POPUP_REQUESTED, b); } return b; }
Example 11
Source Project: netbeans File: GridUtils.java License: Apache License 2.0 | 5 votes |
/** * Determines whether the specified component is a padding component. * * @param comp component to check. * @return {@code true} if the specified component is a padding component, * returns {@code false} otherwise. */ public static boolean isPaddingComponent(Component comp) { boolean padding = false; if (comp instanceof JComponent) { JComponent jcomp = (JComponent)comp; padding = jcomp.getClientProperty(PADDING_COMPONENT) != null; } return padding; }
Example 12
Source Project: pumpernickel File: ContextualMenuHelper.java License: MIT License | 5 votes |
/** * Return the ContextualMenuHelper the static helper methods refer to. * * @param jc * the component to retrieve a common ContextualMenuHelper for. * @return the common ContextualMenuHelper for the argument. This will * create one if it doesn't already exist. */ public static ContextualMenuHelper getContextualMenuHelper(JComponent jc) { ContextualMenuHelper cmh = (ContextualMenuHelper) jc .getClientProperty(MENU_KEY); if (cmh == null) { cmh = new ContextualMenuHelper(jc); jc.putClientProperty(MENU_KEY, cmh); } return cmh; }
Example 13
Source Project: netbeans File: TerminalContainerCommon.java License: Apache License 2.0 | 5 votes |
/** * Return Attributes associated with 'comp'. * Create and attach of none exist. * @param comp * @return */ protected final Attributes attributesFor(JComponent comp) { Object o = comp.getClientProperty(PROP_ATTRIBUTES); if (o == null) { Attributes a = new Attributes(); comp.putClientProperty(PROP_ATTRIBUTES, a); return a; } else { return (Attributes) o; } }
Example 14
Source Project: FlatLaf File: FlatClientProperties.java License: Apache License 2.0 | 4 votes |
/** * Checks whether a client property of a component is a color and returns its value. * If the client property is not set, or not a color, defaultValue is returned. */ static Color clientPropertyColor( JComponent c, String key, Color defaultValue ) { Object value = c.getClientProperty( key ); return (value instanceof Color) ? (Color) value : defaultValue; }
Example 15
Source Project: rapidminer-studio File: PopupBorder.java License: GNU Affero General Public License v3.0 | 4 votes |
@Override public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { JComponent popup = (JComponent) c; g.translate(x, y); try { this.bottomLeft = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_LEFT_PIC); if (this.bottomLeft != null) { g.drawImage(this.bottomLeft, 0, h - 5, c); } this.bottomRight = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_RIGHT_PIC); if (this.bottomRight != null) { g.drawImage(this.bottomRight, w - 5, h - 5, c); } this.right = (Image) popup.getClientProperty(RoundedPopupFactory.RIGHT_PIC); if (this.right != null) { g.drawImage(this.right, w - 1, 0, c); } this.bottom = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_PIC); if (this.bottom != null) { g.drawImage(this.bottom, 5, h - 1, c); } } catch (Exception exp) { // do nothing } if (ShadowedPopupMenuBorder.POPUP_BOTTOM_LEFT != null) { g.drawImage(ShadowedPopupMenuBorder.POPUP_BOTTOM_LEFT, 0, h - 5, popup); } if (ShadowedPopupMenuBorder.POPUP_BOTTOM_RIGHT != null) { g.drawImage(ShadowedPopupMenuBorder.POPUP_BOTTOM_RIGHT, w - 5, h - 5, popup); } ColorUIResource c1 = new ColorUIResource(150, 150, 150); Color c4 = new Color(160, 160, 160, 100); ColorUIResource c2 = new ColorUIResource(135, 135, 135); g.setColor(UIManager.getColor("MenuItem.background")); g.drawLine(1, 0, w - 4, 0); g.drawLine(1, 1, w - 4, 1); g.drawLine(1, 0, 1, h - 7); g.drawLine(5, h - 3, w - 6, h - 3); g.setColor(UIManager.getColor("MenuItem.fadingColor")); g.drawLine(w - 3, 2, w - 3, h - 5); g.setColor(c1); g.drawLine(0, 0, 0, h - 6); g.setColor(c4); g.drawLine(5, h - 1, w - 6, h - 1); g.drawLine(w - 1, 2, w - 1, h - 6); g.setColor(c2); g.drawLine(w - 2, 0, w - 2, h - 6); g.drawLine(5, h - 2, w - 6, h - 2); g.translate(-x, -y); }
Example 16
Source Project: PyramidShader File: ContextualMenuHelper.java License: GNU General Public License v3.0 | 4 votes |
/** Clear any registered contextual menu information for this component. * * @param component the component to purge all contextual menu info for. */ public static void clear(JComponent component) { ContextualMenuHelper cmh = (ContextualMenuHelper)component.getClientProperty(MENU_KEY); if(cmh==null) return; cmh.popup.removeAll(); }
Example 17
Source Project: netbeans File: EditorActionUtilities.java License: Apache License 2.0 | 4 votes |
public static boolean isUseLargeIcon(JComponent c) { Object prefIconSize = c.getClientProperty("PreferredIconSize"); //NOI18N return (prefIconSize instanceof Integer) && (((Integer) prefIconSize).intValue() >= LARGE_ICON_SIZE); }
Example 18
Source Project: seaglass File: TableHeaderRendererSortedState.java License: Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public boolean isInState(JComponent c) { String sortOrder = (String) c.getClientProperty("Table.sortOrder"); return sortOrder != null && ("ASCENDING".equals(sortOrder) || "DESCENDING".equals(sortOrder)); }
Example 19
Source Project: pumpernickel File: MultiThumbSliderUI.java License: MIT License | 3 votes |
/** * This retrieves a property. If the component has this property manually * set (by calling <code>component.putClientProperty()</code>), then that * value will be returned. Otherwise this method refers to * <code>UIManager.get()</code>. If that value is missing, this returns * <code>defaultValue</code> * * @param jc * @param propertyName * the property name * @param defaultValue * if no other value is found, this is returned * @return the property value */ public static <K> K getProperty(JComponent jc, String propertyName, K defaultValue) { Object jcValue = jc.getClientProperty(propertyName); if (jcValue != null) return (K) jcValue; Object uiValue = UIManager.get(propertyName); if (uiValue != null) return (K) uiValue; return defaultValue; }
Example 20
Source Project: netbeans File: EditorRegistry.java License: Apache License 2.0 | 2 votes |
static Item item(JComponent c) { return (Item)c.getClientProperty(Item.class); }