Command Bars for Menus and Icons


I began work on Decaf more or less in the middle. It wasn't long before I realized that I'd need a capable programmer's editor as the fundamental part of the IDE. Having written one, I then realized that I'd need an even more basic application framework to host the editor and the other IDE components. That started me on the CommandBar class.

One thing I was sure I wanted were icons on the main menu bar. This departs from tradition, but it lets the expert user switch off the menu bar in favor of a more compact set of icons. In the first graphic, you see the same set of menu choices, first as a menu and next as an icon bar.

Horizontal menu and icon bar

My goal in having the icon version is to provide an expert bar for experienced users. That might look like this.

Horizontal expert bar: all main menu choices are reduced to icons

The expert version still has the full main menu. As the graphic shows, the choices are flat until the mouse pointer is above them.

Most commercial icon collections have a tiny 16 by 16 pixel version and a more readable 24 by 24 version. The tiny ones are used in dropdown menus. (Next to the word "Print" the printer icon doesn't need to be very clear.) My icons are 20 by 20 — a size that combines with text and still lets the icons be clear.

(Aside - I'm happy with most of the icons I painted, but I'm not so sure about Edit and I'm definitely searching for a better Insert. I won't be offended if someone suggests hiring a genuine artist.)

Screen shot of ertical command bars

As you see in the graphic on the left, the same menu and icon bar can be vertical. Not shown here, if there is no icon, the command bar will use the name instead. If the name is used, it is turned ninety degrees for the vertical bar, so that bar doesn't get unnecessarily wide. You'll see an example in the application framework sample.


The applet here lets you launch your own command bars and watch them in action. (The commands don't do anything in these samples.)

I tossed in the vertical button as a quick suggestion of what you would be getting, and a reminder that Graphics2D can do things like rotating text.

If you fiddle with the command bars you may notice two bugs. First, the content area doesn't correctly repaint — but that's just because there is no content. Second, the tooltips aren't always right. Looks like we're going to have to replace Sun's tooltips with some of our own.

The LaunchCommandBars applet is in the applets package. The CommandBar and supporting classes AppFrame, Command and Commands are in the appFramework package.


The following table shows the icons I've created so far. Many will be familiar — deliberately so. The "docks" series will be new, but see if it doesn't become second nature after you use the application framework for a minute or so.

File menu icon
file.gif
edit menu icon
edit.gif
find menu icon
find.gif
insert menu icon
insert.gif
macro menu icon
macro.gif
view menu icon
view.gif
window menu icon
window.gif
help menu icon
help.gif
 
edit menu disabled icon
edit-dis.gif
find menu disabled icon
find-dis.gif
 
new icon
new.gif
open file icon
open.gif
save file icon
save.gif
save file as icon
saveAs.gif
print icon
print.gif
new disabled icon
new-dis.gif
open file disabled icon
open-dis.gif
save file disabled icon
save-dis.gif
save file as disabled icon
saveAs-dis.gif
print disabled icon
print-dis.gif
cut icon
cut.gif
copy icon
copy.gif
paste icon
paste.gif
delete icon
delete.gif
redo icon
redo.gif
undo icon
undo.gif
cut disabled icon
cut-dis.gif
copy disabled icon
copy-dis.gif
paste disabled icon
paste-dis.gif
delete disabled icon
delete-dis.gif
redo disabled icon
redo-dis.gif
undo disabled icon
undo-dis.gif
up icon
up.gif
down icon
down.gif
left icon
left.gif
right icon
right.gif
top icon
top.gif
bottom icon
bottom.gif
home icon
home.gif
end icon
end.gif
up disabled icon
up-dis.gif
down disabled icon
down-dis.gif
left disabled icon
left-dis.gif
right disabled icon
right-dis.gif
top disabled icon
top-dis.gif
bottom disabled icon
bottom-dis.gif
home disabled icon
home-dis.gif
end disabled icon
end-dis.gif
docking icon
docks.gif
dock top icon
dock-top.gif
doc bottom icon
dock-bottom.gif
dock left icon
dock-left.gif
dock right icon
dock-right.gif
dock horizontal icon
docks-h.gif
dock vertical icon
docks-v.gif
tear off horizontal icon
fly-horizontal.gif
tear off vertical icon
fly-vertical.gif
dock horizontal to vertical icon
docks-h2v.gif
dock vertical to horizontal icon
docks-v2h.gif


java consultant home page icon