diff --git a/wiki/tutorial8.md b/wiki/tutorial8.md index b69b91d..f1d9089 100644 --- a/wiki/tutorial8.md +++ b/wiki/tutorial8.md @@ -1,4 +1,4 @@ -# Lesson 8 : Customizing the User Interface +# Lesson 8: Customizing the User Interface This is the 8th part of the VLDocking Framework for Java Swing applications. @@ -12,10 +12,9 @@ This lesson describes how to change the Look And Feel of VLDocking. VLDocking uses UI delegate classes to paint the look and feel of many of its components. -Theses classes are dynamically loaded at startup, and use many UI properties to give your application the desired appearance. Here is the list of the current UI delegates : +These classes are dynamically loaded at startup, and use many UI properties to give your application the desired appearance. Here is the list of the current UI delegates : - - +
Component UI Delegate class
@@ -24,8 +23,8 @@ Theses classes are dynamically loaded at startup, and use many UI properties to -
Component UI Delegate class
DockViewcom.vlsolutions.swing.docking.ui.DockViewUI
DockViewTitleBarcom.vlsolutions.swing.docking.ui.DockViewTitleBarUI
AutoHideExpandPanelcom.vlsolutions.swing.docking.ui.AutoHideExpandPanelUI
AutoHideButtonPanelcom.vlsolutions.swing.docking.ui.AutoHideButtonPanelUI
AutoHideButtoncom.vlsolutions.swing.docking.ui.AutoHideButtonUI
- + + ### Replacing UI Delegates @@ -33,7 +32,7 @@ Theses classes are dynamically loaded at startup, and use many UI properties to Please note that most UI settings are accessible with UI properties, and thus cas be changed without the need of writing a java class. The only case where you should have to write your own -UI delegate class is when you want a very different rendering (non rectangular for example). +UI delegate class is when you want a very different rendering (non-rectangular, for example). So, if you need a very different rendering for your dockables, then you will have to provide your custom classes. @@ -41,8 +40,9 @@ So, if you need a very different rendering for your dockables, then you will hav Here is how to declare them : +#### Legacy way to declare them - * pre-install the default ui settings in you main() method, or any method prior DockingDesktop usage + * pre-install the default ui settings in your `main()` method, or any method prior DockingDesktop usage * put your new settings as UIManager properties Example : @@ -55,10 +55,29 @@ Example : // and start customizing... UIManager.put("DockViewTitleBarUI", "your.own.ui.UIDelegateClassName"); // (replaced the DockViewTitleBar UI by another class) - ... } ``` +#### LookAndFeel friendly way + + * Define it in your custom `LookAndFeel#getDefaults` + * Set CustomLookAndFeel class name using `UIManager.setLookAndFeel` + +```java +import javax.swing.*; + +public class CustomLookAndFeel extends BasicLookAndFeel implements LookAndFeel { + + @Override + public UIDefaults getDefaults() { + UIDefaults defaults = UIManager.getDefaults(); + defaults.put("DockViewTitleBarUI", "your.own.ui.UIDelegateClassName"); + return defaults; + } +} + + +``` ### Updating the existing UI @@ -68,11 +87,15 @@ The easiest way to update the UI is by tweaking the UIManager properties. For example, if you want a special border for maximized dockable, use : ```java - // declare your border - Border myBorder = ... - // put it in the UI property map. - UIManager.put("DockView.maximizedDockableBorder", myBorder); - // and that's it ! +public class Main { + public static void main(String[] args) { + // declare your border + Border myBorder = new MyBorder(); + // put it in the UI property map. + UIManager.put("DockView.maximizedDockableBorder", myBorder); + // and that's it! + } +} ``` @@ -80,23 +103,24 @@ Please note that *to avoid having your own UI settings beeing erased* by the def you will have to follow the pattern : - * pre-install the default ui settings in you main() method, or any method prior DockingDesktop usage + * pre-install the default ui settings in your `main()` method, or any method prior DockingDesktop usage * put your new settings as UIManager properties ```java +public class Main { public static void main(String[] args) { // first, preload the UI to avoid erasing your own customizations DockingUISettings.getInstance().installUI(); // declare your border - Border myBorder = ... + Border myBorder = new MyBorder(); // and start customizing... UIManager.put("DockView.maximizedDockableBorder", myBorder); - ... } +} ``` Now that you know how to proceed, here is the long list of customizable properties... @@ -104,7 +128,7 @@ Now that you know how to proceed, here is the long list of customizable properti ## Customizable properties ### Border properties - +
@@ -126,20 +150,22 @@ Now that you know how to proceed, here is the long list of customizable properti -
UI property type effect
ToolBarPanel.rightBorder Border Border used when a toolbar in on the right of a container
FloatingDialog.dialogBorder Border Border used for the FloatingDialog
FloatingDialog.titleBorder Border Border used for the title (drag header) of the FloatingDialog
+ + ### Color properties - +
-
UI property type effect
DockingDesktop.notificationColor Color blinking color for notifications
+ + ### Icons - +
@@ -184,12 +210,13 @@ property must also be set to true -
UI property type effect
DockTabbedPane.menu.float Icon Icon for the float button, in tab pop-up menu
DockTabbedPane.menu.closeAll Icon Icon for the "close all" button, in tab pop-up menu
DockTabbedPane.menu.closeAllOther Icon Icon for the "close all other" button, in tab pop-up menu
+ + ### Labels and Fonts - +
@@ -205,11 +232,12 @@ property must also be set to true -
UI property type effect
DockTabbedPane.restoreButtonText String Text for the restore button in tab
DockTabbedPane.maximizeButtonText String Text for the maximize button in tab
DockTabbedPane.floatButtonText String Text for the float button in tab
+ + ### Displaying buttons in title bars - +
@@ -220,11 +248,12 @@ property must also be set to true -
UI property type effect
DockViewTitleBar.isRestoreButtonDisplayed boolean display or not the restore button in the title bar
DockViewTitleBar.isFloatButtonDisplayed boolean display or not the float button in the title bar
DockViewTitleBar.isAttachButtonDisplayed boolean display or not the attach button in the title bar
+ + ### KeyStrokes - +
@@ -232,12 +261,13 @@ property must also be set to true -
UI property type effect
DockingDesktop.maximizeActionAccelerator KeyStroke KeyStroke for maximize/restore action (on selected dockable)
DockingDesktop.dockActionAccelerator KeyStroke KeyStroke for hide/dock action (on selected dockable)
DockingDesktop.floatActionAccelerator KeyStroke KeyStroke for float/attach action (on selected dockable)
+ + ### UI Delegates - +
UI propertytypeeffect
@@ -247,14 +277,15 @@ property must also be set to true -
UI propertytypeeffect
AutoHideButtonUI class name UI delegate for the AutoHideButton
AutoHideButtonPanelUI class name UI delegate for the AutoHideButtonPanel
AutoHideExpandPanelUI class name UI delegate for the AutoHideExpandPanel
DockViewTitleBar.height int Height of the title bars
DockingSplitPaneUI class name UI delegate for SplitContainer component
ToolBarGripperUI class name UI delegate for the toolbar "gripper"
+ + ### Cursors Starting from version 2.0.3 it is now possible to change the mouse cursor images used during drag gestures. - +
UI propertytypeeffect
@@ -264,7 +295,7 @@ drag gestures. ### Other properties -
UI propertytypeeffect
DragControler.stopDragCursor java.awt.Image Image (max 32x32) used when the mouse pointer is above a place where drop is not possible
DragControler.detachCursor Image Image used to denote a floating action
DragControler.dragCursor Image Image used (together with a shape) to denote a position where drop is possible
+
@@ -293,8 +324,12 @@ You can choose select between the following provided styles (more to come) with ```java - // version 1.0 style - DockingPreferences.setShadowDesktopStyle(); +public class Main { + public static void main(String[] args) { + // version 1.0 style + DockingPreferences.setShadowDesktopStyle(); + } +} ``` ![](shadowed_style.jpg) @@ -302,8 +337,12 @@ You can choose select between the following provided styles (more to come) with _The "Shadow Style"_ ```java - // or version 1.0 alternative style - DockingPreferences.setDottedDesktopStyle(); +public class Main { + public static void main(String[] args) { + // or version 1.0 alternative style + DockingPreferences.setDottedDesktopStyle(); + } +} ``` ![](dotted_style.jpg) @@ -311,8 +350,12 @@ You can choose select between the following provided styles (more to come) with _The "Dotted Style"_ ```java - // or version 2.0 default style - DockingPreferences.setFlatDesktopStyle(); +public class Main { + public static void main(String[] args) { + // or version 2.0 default style + DockingPreferences.setFlatDesktopStyle(); + } +} ``` ![](flat_style.jpg)
UI property type effect