Professional Documents
Culture Documents
Ribbon Component to
Swing
Kirill Grouchnikov
Amdocs
Agenda
> What is a ribbon?
> Swing ribbon implementation
> Swing ribbon structure
Basic terminology
Command buttons
Ribbon bands
Ribbon tasks
Miscellaneous
> Where to next?
2
What is a ribbon?
3
Ribbon demo
4
http://blogs.msdn.com/jensenh
5
Ribbon availability
> Available for WinForms, Win32, WPF, Silverlight
> Third-party vendors
6
Ribbon for Swing applications
Metal Looks Plastic XP
Nimbus A03
7
Ribbon for Swing applications
Office Blue 2007 Office Silver 2007
Creme Nebula
8
Ribbon for Swing applications
Black Moon Orange Metallic
9
Ribbon for Swing applications
http://flamingo.dev.java.net
10
Basic ribbon terminology
Ribbon gallery
Ribbon band Ribbon band expand button
11
Basic hierarchy
> Ribbon
Ribbon task
Contains tasks
Containing bands
> JRibbon
RibbonTask
AbstractRibbonBand Ribbon band
12
Basic building block
Command buttons
13
Command buttons
> AbstractCommandButton
JCommandButton
JCommandToggleButton
14
Command
buttons demo
15
Display state
AbstractCommandButton.setDisplayState(
CommandButtonDisplayState)
SMALL
16
Action and popup areas
JCommandButton.setCommandButtonKind(CommandButtonKind)
ActionButtonModel AbstractCommandButton.getActionModel()
PopupButtonModel JCommandButton.getPopupModel()
17
Simple popups
JCommandButton.setPopupCallback(PopupPanelCallback)
JCommandButton button = ...;
button.setPopupCallback(new PopupPanelCallback() {
public JPopupPanel getPopupPanel(
JCommandButton commandButton) {
JCommandPopupMenu menu =
new JCommandPopupMenu();
menu.addMenuButton(...);
menu.addMenuSeparator();
...
return menu;
}
});
18
Command button strips
JCommandButtonStrip
HORIZONTAL VERTICAL
19
Command button panels
JCommandButtonPanel
ROW_FILL COLUMN_FILL
20
Rich popups
JCommandButton button = ...;
button.setPopupCallback(new PopupPanelCallback() {
public JPopupPanel getPopupPanel(
JCommandButton commandButton) {
JCommandButtonPanel panel =
new JCommandButtonPanel(...);
panel.addButtonGroup(...);
panel.addButtonToGroup(...);
...
JCommandPopupMenu menu =
new JCommandPopupMenu(panel,
maxColumns, maxRows);
...
return menu;
}
});
21
Bands / tasks
demo
22
Ribbon bands
> AbstractRibbonBand
JRibbonBand
JFlowRibbonBand
23
Flow ribbon bands
JFlowRibbonBand
Adding content:
addFlowComponent(JComponent)
24
Regular ribbon bands
JRibbonBand
Can host:
> command buttons
> wrapped core / 3rd party components
> ribbon galleries
25
Hosting command buttons
JRibbonBand clipboardBand = new JRibbonBand(
“Clipboard”, ...);
...
clipboardBand.addCommandButton(cutButton,
RibbonElementPriority.MEDIUM);
26
Hosting core and 3rd party controls
Wrapped components
spanning multiple rows
27
Ribbon galleries
Hosted gallery Expanded gallery Expanded gallery
shown in a popup scrolled down
Hosted gallery
scrolled down
28
Groups in ribbon bands
Two unnamed
groups with
command buttons
Three unnamed
groups with
command buttons
29
Ribbon tasks
Ribbon task Ribbon task Ribbon task
Ribbon task Ribbon task
new RibbonTask(title,
AbstractRibbonBand... bands)
JRibbon.addTask(RibbonTask)
30
Contextual task groups
Contextual ribbon task group Contextual ribbon task group
31
Menu button /
taskbar demo
32
Application menu button
Application menu button
33
Application menu
Primary Secondary
menu group menu group
Footer
JRibbon.setApplicationMenu(RibbonApplicationMenu)
34
Taskbar panel
Taskbar panel
JRibbon.addTaskbarComponent(Component)
35
Tooltips / key
tips demo
36
Rich tooltips
Displayed below
the ribbon
37
Rich tooltips
38
Rich tooltips
Tooltip for
application menu
button
Footer section
and images
39
Key tips
P V
Esc Esc
40
Resizing /
minimized
demo
41
Ribbon resizing
42
Ribbon resizing, collapsing and scrolling
Scrolling tasks Scrolling bands
Expanding the
collapsed ribbon
band
43
Minimized mode
JRibbon.setMinimized(true)
User double-clicking a task button
User pressing Ctrl+F1
44
Big features recap
> Ribbon regular and flow bands
> Ribbon galleries
> Ribbon tasks and contextual task groups
> Application menu button and taskbar panel
> Resizing, collapsing and scrolling
> Rich tooltips and key tips
> Minimized mode
45
Under the hood
> Visual consistency across LAFs
> org.jvnet.flamingo.common.ui.BasicCommandButtonUI.paint
ButtonBackground
> Key tips
> org.jvnet.flamingo.ribbon.JRibbonFrame.KeyTipLayer
> Placing content in the title pane
> org.jvnet.substance.flamingo.ribbon.ui.SubstanceRibbonF
rameTitlePane
> More in the code…
46
What is missing - small
> Hosting small buttons in galleries
> Resizing popup panels
> Navigating with keyboard (arrows, tabs)
> Dragging controls to the taskbar panel
> Hosting taskbar panel below the ribbon
47
What is missing - medium
> Right-to-left support
> High DPI support
48
Potentially useful
> XML-driven ribbon content
> SWT version
> World domination
49
Try it now!
http://flamingo.dev.java.net
50
Kirill Grouchnikov
kirillcool@yahoo.com
http://flamingo.dev.java.net
http://www.pushing-pixels.org
51