|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjview.JHiddenComponent
public class JHiddenComponent
This class helps in adding a button or other components to a frame that
disappears from view
until the mouse moves over it. It is not using internal frames (to spare
the window decoration), but manipulates the layered pane in a
RootPaneContainer. This layered pane is assumed to have no
layout manager (default case). The following steps are necessary to add
(in the example a button) as a hiding component to a top-level window.
prepareHidingComponent(java.awt.Component). This method assigns a
mouse listener to the component that brings the component to the foreground
on mouse exit and put it to the background on mouse exit.addHidingComponent(java.awt.Component, javax.swing.RootPaneContainer, int, boolean) method with the last argument
true, otherwise only the initial size is considered in placement of the
hidden component within the frame. The four alignment doubles are
the amount of the window size and the amount of the component's size
that are used for calculating the upper left corner of the hidden
component. For instance, to place a component in the upper right corner
(NORTHEAST), the weight on pane width is 1, and the weight of the
component size is -1 (height weights zero).JLayeredPane.FRAME_CONTENT_LAYER
in the background. If it should follow resizes, a component
listener is added to the layered pane that recalculates the position on
component resize events.Java(TM) SE Runtime Environment (build 1.6.0_22-b04),
Debian 2.6.26-1-686, it appeared that the component was visible until
the mouse moved over it for the first time. Additionally, if the mouse
left the window, it again popped up. To force the component to stay hidden
also in these circumstances, ensure the hiding of the component by a
call to ensureHidingComponent(java.awt.Component, java.awt.Window). This method adds a window
listener to the frame that sends the hidden component to the background
whenever the window is activated or de-activated.
| Nested Class Summary | |
|---|---|
private static class |
JHiddenComponent.ComponentHidden
|
private static class |
JHiddenComponent.MouseHidden
|
private static class |
JHiddenComponent.WindowHidden
|
| Constructor Summary | |
|---|---|
JHiddenComponent()
|
|
| Method Summary | |
|---|---|
static void |
addHidingComponent(Component c,
RootPaneContainer frame,
double panew,
double paneh,
double compw,
double comph,
boolean follow)
This method adds a (prepared) hiding component to a RootPaneContainer, i.e. |
static void |
addHidingComponent(Component c,
RootPaneContainer frame,
int gridbag,
boolean follow)
This method adds a (prepared) hiding component to a RootPaneContainer, i.e. |
static void |
ensureHidingComponent(Component c,
Window w)
This method is only necessary to keep a hiding component hidden if the main frame is shown. |
private static Point |
getUpLeft(Dimension pane,
Dimension comp,
double panew,
double paneh,
double compw,
double comph)
From four alignment parameters and the size of the frame plus the size of the component, we infer the position where the upper left corner of the hidden component should be. |
private static Dimension |
inferSize(Component c)
Tries to infer the size of the component. |
static void |
main(String[] arg)
|
static void |
prepareHidingComponent(Component c)
This method is called to prepare a component for hiding-until-mouse-over capablitities. |
static void |
prepareHidingComponent(Component c,
int mod)
This method is called to prepare a component for hiding-until-mouse-over capablitities. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JHiddenComponent()
| Method Detail |
|---|
public static void prepareHidingComponent(Component c)
public static void prepareHidingComponent(Component c,
int mod)
public static void addHidingComponent(Component c,
RootPaneContainer frame,
int gridbag,
boolean follow)
#ensureComponentHiding.To support generic placements, the anchor-constants in GridBagConstraints for absolute values are supported (CENTER plus compass directions). If invalid, center is used.
public static void addHidingComponent(Component c,
RootPaneContainer frame,
double panew,
double paneh,
double compw,
double comph,
boolean follow)
#ensureComponentHiding.
To support generic placements, the four placement indicators are used
to deduce the upper left corner (UL). A placement in the center would
thus require 0.5, 0.5, -0.5, -0.5.
panew - pane width*this=UL x coordinate.paneh - pane height*this=UL y coordinate.compw - component width*this: added to UL x (negative allowed).comph - component height*this: added to UL y (negative allowed).
private static Point getUpLeft(Dimension pane,
Dimension comp,
double panew,
double paneh,
double compw,
double comph)
private static Dimension inferSize(Component c)
public static void ensureHidingComponent(Component c,
Window w)
public static void main(String[] arg)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||