|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.japisoft.framework.dockable.JDock
Main component for the docking environnement. The user adds inner windows
calling the addInnerWindow
method. An inner window has always
an unique ID. This ID can be used after for selecting, maximizing, hiding,
restoring... the bound inner window. It is also possible to add an inner
window without ID calling the add
method, in this case the
inner window is called "anonymous" and the final user can't handle it.
Here sample of usage
// Main panel JDock pane = new JDock(); // Action for removing the default shadow // pane.setShadowMode( false ); // The default JDock layout is a BorderLayout JTextArea t; pane.addInnerWindow(new InnerWindowProperties("T1", "Tree", new JScrollPane( new JTree())), BorderLayout.WEST); pane.addInnerWindow(new InnerWindowProperties("TA", "Text Area", t = new JTextArea()), BorderLayout.CENTER); // We set an initial size as sample t.setPreferredSize(new Dimension(200, 50)); JFrame frame = new JFrame(); frame.getContentPane().add(pane.getView()); frame.setSize(600, 500); frame.setVisible(true);
By default the default layout is a BorderLayout
, but the user
can use another one like a GridbagLayout
calling
setLayout
on the JDock instance. This method MUST be called
before adding the inner windows. Note that the setPreferredSize
method can be used for setting an initial size to a component.
For saving the inner windows state, the getState
method can be
used. The result object can be stored using an ObjectOutputStream. For
restoring the JDock state, the user must called setState
.
Note that the state is not saved for anonymous inner window.
The user can change the look of the inner windows using the following
UIManager
properties :
// Sample for resetting the starting color of the header for each non selected inner window UIManager.put("jdock.innerwindow.gradient.startColor", Color.DARK_GRAY); // Sample for resetting the final color of the header for each non selected inner window UIManager.put("jdock.innerwindow.gradient.stopColor", Color.WHITE); // Sample for resetting the starting color of the header for each selected inner window UIManager.put("jdock.innerwindow.gradient.selectedStartColor", Color.RED .darker()); // Sample for resetting the final color of the header for each selected inner window UIManager.put("jdock.innerwindow.gradient.selectedStopColor", Color.WHITE);
By default an inner window has an header with a title and a set of actions
located at the right part of the window. The default actions are stored as
classes inside the CommonActionManager
. The available actions
are stored inside the com.japisoft.framework.dockable.action.common package.
The user can remove default action or add new default action with the
CommonActionManager. It is also possible to use custom actions using the
ActionModel. An instance of this class is available for each
inner window. The user can add / remove dynamically a swing action with it.
Here a sample
// We remove the ExtractAction inside the inner window with the T1 id ActionModel model1 = pane.getInnerWindowActionsForId("T1"); Action a1 = model1.getActionByClass(ExtractAction.class); model1.removeAction(a1); Action[] actions = new Action[] { new CopyAction(textArea), // Action sample new CutAction(textArea), // Action sample new PasteAction(textArea), // Action sample new ExtractAction() // This is a default action }; // We use a new actions toolbar for the inner window TA id pane.addInnerWindow(new InnerWindowProperties("TA", "Text Area", new BasicActionModel(actions), textArea), BorderLayout.CENTER);
More information at : http://www.swingall.com
Constructor Summary | |
JDock()
Default constructor. |
|
JDock(boolean shadowMode)
|
Method Summary | |
void |
add(javax.swing.JComponent view,
java.lang.Object constraint)
Add a component without bar. |
void |
addInnerWindow(InnerWindowProperties properties,
java.lang.Object constraint)
Insert a frame inside the JDock container. |
void |
addInnerWindow(javax.swing.JComponent view,
java.lang.Object constraint)
Add a component without bar. |
void |
addJDockListener(JDockListener listener)
Add a listener for the inner window state (selected, maximized, moved, removed...) |
void |
dispose()
Free all inner resources. |
void |
extractInnerWindow(java.lang.String id)
Extract and content of this inner window and put it inside a frame. |
java.awt.Color |
getBackground()
|
java.awt.Color |
getDraggingActiveWindow()
|
java.awt.Color |
getDraggingShadowColor()
|
ActionModel |
getInnerWindowActionsForId(java.lang.String id)
This method will return null for a wrong id. |
javax.swing.Icon |
getInnerWindowIconForId(java.lang.String id)
|
java.lang.String |
getInnerWindowTitleForId(java.lang.String id)
This method will return null for a wrong id. |
javax.swing.JComponent |
getInnerWindowViewForId(java.lang.String id)
This method will return null for a wrong id. |
java.awt.Dimension |
getMinimalInnerWindowSize()
|
java.awt.Color |
getResizingShadowColor()
|
State |
getState()
This action MUST only be used with inner windows having an ID |
javax.swing.JComponent |
getView()
|
void |
hideInnerWindow(java.lang.String id)
Hide the inner window with the following id. |
boolean |
isEnabledActionPopup()
|
boolean |
isEnabledDraggingShasow()
|
boolean |
isEnabledResizeShasow()
|
boolean |
isEnabledStatusBar()
|
boolean |
isInnerWindowFixed(java.lang.String id)
|
boolean |
isInnerWindowHidden(java.lang.String id)
|
boolean |
isMaximizedInnerWindow(java.lang.String id)
|
boolean |
isShadowMode()
|
void |
maximizedRestoredInnerWindow(java.lang.String id)
Maximized or restored this inner window depending on its state. |
void |
maximizeInnerWindow(java.lang.String id)
Put this inner window in a "full-window" mode. |
void |
removeInnerWindow(java.lang.String id)
Remove definitly the frame with the following id |
void |
removeJDockListener(JDockListener listener)
Remove a listener for the inner window state |
boolean |
resize(java.lang.String id,
int addedWidth,
int addedHeight)
This method can be used for dynamically resize an inner window |
void |
restoreInnerWindow(java.lang.String id)
Restore this inner window size if it has been maximized previously. |
void |
selectInnerWindow(java.lang.String id)
Highlight this window with the following id. |
void |
setBackground(java.awt.Color color)
Reset the jdock background |
void |
setDraggingActiveWindow(java.awt.Color color)
Reset the color while dragging an inner window under an active inner window. |
void |
setDraggingShadowColor(java.awt.Color color)
Reset the color while dragging an inner window. |
void |
setEnabledActionPopup(boolean enabled)
Enable a popup menu on the window bar icon. |
void |
setEnabledDraggingShadow(boolean enabled)
if true it will draw a shadow while dragging an inner
window. |
void |
setEnabledResizeShadow(boolean enabled)
if true it will draw a shadow while resizing an inner
window. |
void |
setEnabledStatusBar(boolean enabled)
Enable a status bar containg the hidden inner window. |
void |
setInnerWindowBackgroundForId(java.lang.String id,
java.awt.Color color)
Update the background color of the header for this inner window id. |
void |
setInnerWindowFixed(java.lang.String id,
boolean fixed)
It will fixe an inner window, thus it will not able to move to another inner window space. |
void |
setInnerWindowForegroundForId(java.lang.String id,
java.awt.Color color)
Update the foreground color of the header for this inner window id. |
void |
setInnerWindowIconForId(java.lang.String id,
javax.swing.Icon icon)
Update an icon for an inner window with the following id. |
void |
setInnerWindowTitleForId(java.lang.String id,
java.lang.String title)
Update a title for an inner window with the following id. |
void |
setLayout(java.awt.LayoutManager2 layout)
Reset a layout for initializing each frame. |
void |
setMenuWindow(javax.swing.JMenu menuWindow)
Here a menu for your main frame or dialog containg a set of available inner windows to be hidden or shown. |
void |
setMinimalInnerWindowSize(java.awt.Dimension dim)
Update the minimal frame size. |
void |
setResizingShadowColor(java.awt.Color color)
Reset the shadow color while resizing an inner window. |
void |
setShadowMode(boolean shadow)
Here a mode for displaying shadow around the inner windows. |
void |
setState(State state)
Reset the inner windows state (size and location). |
void |
showInnerWindow(java.lang.String id)
Show the inner window with the following id. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JDock()
public JDock(boolean shadowMode)
shadowMode
- Display a shadow for the inner frames. By default
true
Method Detail |
public void setShadowMode(boolean shadow)
true
public boolean isShadowMode()
true
if a shadow is displayed for the inner framespublic void setLayout(java.awt.LayoutManager2 layout)
BorderLayout
public void setMenuWindow(javax.swing.JMenu menuWindow)
menuWindow
- A menu for the set of framepublic void dispose()
public void add(javax.swing.JComponent view, java.lang.Object constraint)
addInnerWindow( view, constraint ).
view
- A component to insertconstraint
- A layout constraint. For a non BorderLayout, You must call
setLayout
before.public void addInnerWindow(InnerWindowProperties properties, java.lang.Object constraint)
constraint
- A layout constraint. For a non BorderLayout (the default
layout), You must call setLayout
before.public void addInnerWindow(javax.swing.JComponent view, java.lang.Object constraint)
add( view, constraint ).
view
- A component to insertconstraint
- A layout constraint. For a non BorderLayout, You must call
setLayout
before.public javax.swing.JComponent getView()
public void setEnabledStatusBar(boolean enabled)
enabled
- true
for having a status bar with the hidden
windowspublic boolean isEnabledStatusBar()
true
if a status bar is available with the inner
windowpublic void setEnabledActionPopup(boolean enabled)
true
public boolean isEnabledActionPopup()
true
if a popup menu is activated while clicking on the window iconpublic void setMinimalInnerWindowSize(java.awt.Dimension dim)
dim
- A minimal frame sizepublic java.awt.Dimension getMinimalInnerWindowSize()
public State getState()
public void setState(State state)
public java.lang.String getInnerWindowTitleForId(java.lang.String id)
null
for a wrong id.
public boolean isInnerWindowFixed(java.lang.String id)
id
- Inner window id
true
if the bound inner window cannot be movedpublic void setInnerWindowFixed(java.lang.String id, boolean fixed)
JDockException
will be thrown if the
id is unknown
id
- Inner window idfixed
- if true
the inner window is staticpublic ActionModel getInnerWindowActionsForId(java.lang.String id)
null
for a wrong id.
public void setInnerWindowTitleForId(java.lang.String id, java.lang.String title)
JDockException
will be thrown if the id is wrong
id
- Id of the inner windowtitle
- New title of the inner window (can be null
)public void setInnerWindowIconForId(java.lang.String id, javax.swing.Icon icon)
JDockException
will be thrown if the id is wrong
id
- Id of the inner windowicon
- New icon of the inner window (can be null
)public javax.swing.Icon getInnerWindowIconForId(java.lang.String id)
id
- Inner window id
public void setInnerWindowBackgroundForId(java.lang.String id, java.awt.Color color)
null
for restoring the default color
id
- An inner window idcolor
- An inner window header backgroundpublic void setInnerWindowForegroundForId(java.lang.String id, java.awt.Color color)
null
for restoring the default color
id
- An inner window idcolor
- An inner window header foregroundpublic javax.swing.JComponent getInnerWindowViewForId(java.lang.String id)
null
for a wrong id.
public void removeInnerWindow(java.lang.String id)
id
- an inner window Idpublic void hideInnerWindow(java.lang.String id)
JDockException
will be thrown if the id is unknown.
id
- an inner window Idpublic void showInnerWindow(java.lang.String id)
JDockException
will be thrown if the id is unknown.
id
- an inner window Idpublic boolean isInnerWindowHidden(java.lang.String id)
public void selectInnerWindow(java.lang.String id)
id
- An inner window idpublic void extractInnerWindow(java.lang.String id)
JDockException
will be thrown for an unknown inner window.
id
- An inner window idpublic void maximizeInnerWindow(java.lang.String id)
JDockException
will be thrown for an unknown id
public boolean isMaximizedInnerWindow(java.lang.String id)
id
- an Inner window id
true
if the inner window with the following id is
maximized. If the id is unknown it will return always
false
public void restoreInnerWindow(java.lang.String id)
JDockException
will be thrown for an unknown id
public void maximizedRestoredInnerWindow(java.lang.String id)
JDockException
will be thrown for an unknown id
id
- An inner window idpublic void setEnabledDraggingShadow(boolean enabled)
true
it will draw a shadow while dragging an inner
window. By default true
public boolean isEnabledDraggingShasow()
true
if a shadow is drawn while dragging an inner
window. By default true
public void setBackground(java.awt.Color color)
color
- Background colorpublic java.awt.Color getBackground()
public void setDraggingShadowColor(java.awt.Color color)
color
- Color for the shadow while dragging an inner windowpublic java.awt.Color getDraggingShadowColor()
public void setDraggingActiveWindow(java.awt.Color color)
color
- Color while dragging an inner window for an active inner
windowpublic java.awt.Color getDraggingActiveWindow()
public void setResizingShadowColor(java.awt.Color color)
color
- A color while resizing an inner windowpublic java.awt.Color getResizingShadowColor()
public boolean resize(java.lang.String id, int addedWidth, int addedHeight)
id
- An inner window idaddedWidth
- This is the value added to the width of the windowaddedHeight
- This is the value added to the height of the window
true
only if the operation is possiblepublic void addJDockListener(JDockListener listener)
public void removeJDockListener(JDockListener listener)
public void setEnabledResizeShadow(boolean enabled)
true
it will draw a shadow while resizing an inner
window. By default true
public boolean isEnabledResizeShasow()
true
if a shadow is drawn while resizing an inner
window. By default true
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |