List of utility methods to do JComponent Properties
JPanel | buildComponentPanel(JComponent component, int hgap, int vgap, boolean isOpaque) Adds the specified JComponent to a JPanel with a left flow layout. JPanel p = new JPanel(); if (component == null) return p; if (hgap < 0) hgap = 0; if (vgap < 0) vgap = 0; p.setLayout(new FlowLayout(FlowLayout.LEFT, hgap, vgap)); ... |
JPanel | buildComponentPanelRight(JComponent component, int hgap, int vgap, boolean isOpaque) Adds the specified JComponent to a JPanel with a right flow layout. JPanel p = new JPanel(); if (component == null) return p; if (hgap < 0) hgap = 0; if (vgap < 0) vgap = 0; p.setLayout(new FlowLayout(FlowLayout.RIGHT, hgap, vgap)); ... |
void | disableAll(JComponent component) disable All component.setEnabled(false); for (Component cmp : component.getComponents()) { if (cmp instanceof JComponent) { disableAll((JComponent) cmp); |
void | disposeParentWindow(JComponent component) dispose Parent Window Window window = SwingUtilities.windowForComponent(component);
if (window != null)
window.dispose();
|
void | doDisable(JComponent component) do Disable if (component.isEnabled())
component.setEnabled(false);
|
Map | getProperties(JComponent component) Convenience method for obtaining most non-null human readable properties of a JComponent. Map<Object, Object> retVal = new HashMap<Object, Object>(); Class<?> clazz = component.getClass(); Method[] methods = clazz.getMethods(); Object value = null; for (Method method : methods) { if (method.getName().matches("^(is|get).*") && method.getParameterTypes().length == 0) { try { Class returnType = method.getReturnType(); ... |
Map | getProperties(JComponent component) Convenience method for obtaining most non-null human readable properties of a JComponent. Class<?> clazz = component.getClass(); Method[] methods = clazz.getMethods(); Map<Object, Object> retVal = new HashMap<>(methods.length); Object value = null; for (Method method : methods) { if (method.getName().matches("^(is|get).*") && (method.getParameterTypes().length == 0)) { try { Class<?> returnType = method.getReturnType(); ... |
Map | getProperties(JComponent component) Convenience method for obtaining most non-null human readable properties of a JComponent. Map<Object, Object> retVal = new HashMap<>(); Class<?> clazz = component.getClass(); Method[] methods = clazz.getMethods(); Object value = null; for (Method method : methods) { if (method.getName().matches("^(is|get).*") && method.getParameterTypes().length == 0) { try { Class<?> returnType = method.getReturnType(); ... |
Rectangle | getVisibleBoundsOnScreen(JComponent component) Returns the specified component's visible bounds within the screen. Rectangle visibleRect = component.getVisibleRect();
Point onScreen = visibleRect.getLocation();
SwingUtilities.convertPointToScreen(onScreen, component);
visibleRect.setLocation(onScreen);
return visibleRect;
|
void | invert(JComponent c) Makes a Swing component inverted by swapping its foreground and background colors. Color invBackground = c.getForeground(); Color invForeground = c.getBackground(); c.setBackground(invBackground); c.setForeground(invForeground); |