Java Utililty Methods JComponent Container

List of utility methods to do JComponent Container

  1. HOME
  2. Java
  3. J
  4. JComponent Container

Description

The list of methods to do JComponent Container are organized into topic(s).

Method

void allignBottom(JComponent lead, JComponent target)
allign Bottom
allignBottom(lead, target, -1, -1);
void centerComponent(final JComponent target)
Centers JComponent on screen
final Rectangle screen = getScreenRect();
final Rectangle frameSize = target.getBounds();
final int x = (screen.width - frameSize.width) / 2;
final int y = (screen.height - frameSize.height) / 2;
target.setLocation(x, y);
void centerOnComponet(Window target, JComponent parent)
center On Componet
Dimension targetSize = target.getSize();
Point location = parent.getLocationOnScreen();
Dimension sourceSize = parent.getSize();
Point sourceCenter = new Point(location.x + sourceSize.width / 2, location.y + sourceSize.height / 2);
Point frameLocation = new Point(sourceCenter.x - targetSize.width / 2,
 sourceCenter.y - targetSize.height / 2);
target.setLocation(frameLocation);
Rectangle checkComponents(final Component _rootComponent, final String _print, final int _currentColumn, final int _currentRow)
Check the components.
int depth = _currentColumn;
int amount = _currentRow;
int maxDepth = _currentColumn;
if (_rootComponent.getWidth() <= 0 || _rootComponent.getHeight() <= 0) {
 System.err.println(_print + _rootComponent.getClass().getSimpleName() + _rootComponent.getSize());
} else {
 System.out.println(_print + _rootComponent.getClass().getSimpleName()
 );
...
JRootPane findMainRootPane(Component component)
find Main Root Pane
while (component != null) {
 Container parent = component.getParent();
 if (parent == null) {
 return component instanceof RootPaneContainer ? ((RootPaneContainer) component).getRootPane()
 : null;
 component = parent;
return null;
JRootPane findRootPane(Component component)
find Root Pane
while (component != null) {
 if (component instanceof JRootPane) {
 return (JRootPane) component;
 component = getParent(component);
return null;
RootPaneContainer findRootPaneContainer(Component c)
Locates the RootPaneContainer for the given component
if (c == null) {
 return null;
} else if (c instanceof RootPaneContainer) {
 return (RootPaneContainer) c;
} else {
 return findRootPaneContainer(c.getParent());
RootPaneContainer findRootPaneContainer(Component root)
Finds the nearest RootPaneContainer of the provided Component.
while (root != null) {
 if (root instanceof RootPaneContainer) {
 return (RootPaneContainer) root;
 } else if (root instanceof JPopupMenu && root.getParent() == null) {
 root = ((JPopupMenu) root).getInvoker();
 } else {
 root = root.getParent();
return null;
RootPaneContainer findRootPaneContainer(final Component source)
Find the root pane container in the current hierarchy.
Component comp = source;
while ((comp != null) && !(comp instanceof RootPaneContainer)) {
 comp = comp.getParent();
if (comp instanceof RootPaneContainer) {
 return (RootPaneContainer) comp;
return null;
...
Rectangle getActiveRectangle(JComponent c)
get Active Rectangle
Dimension d = c.getSize();
Insets ins = c.getInsets();
int left = ins.left;
int width = d.width - ins.right - ins.left;
int top = ins.top;
int height = d.height - ins.bottom - ins.top;
Rectangle ret = new Rectangle(left, top, width, height);
return ret;
...


AltStyle によって変換されたページ (->オリジナル) /