Java Reference
In-Depth Information
// Shift-PgUp key moves view left block
Action shiftPgUpKeyAction =
new MoveAction(viewport, DECREASE, X_AXIS, BLOCK);
KeyStroke shiftPgUpKey = KeyStroke.getKeyStroke("shift PAGE_UP");
inputMap.put(shiftPgUpKey, "shiftPgUp");
actionMap.put("shiftPgUp", shiftPgUpKeyAction);
// Shift-PgDn key moves view right block
Action shiftPgDnKeyAction =
new MoveAction(viewport, INCREASE, X_AXIS, BLOCK);
KeyStroke shiftPgDnKey = KeyStroke.getKeyStroke("shift PAGE_DOWN");
inputMap.put(shiftPgDnKey, "shiftPgDn");
actionMap.put("shiftPgDn", shiftPgDnKeyAction);
frame.add(viewport, BorderLayout.CENTER);
frame.setSize(300, 200);
frame.setVisible(true);
}
};
EventQueue.invokeLater(runner);
}
}
Customizing a JViewport Look and Feel
Each installable Swing look and feel shares the same JViewport appearance with the
BasicViewportUI . There are no actual appearance differences. However, there still exists
a set of UIResource -related properties for the JViewport , as shown in Table 11-12. For the
JViewport component, there are four such properties.
Table 11-12. JViewport UIResource Elements
Property String
Object Type
Viewport.background
Color
Viewport.font
Font
Viewport.foreground
Color
ViewportUI
String
Summary
In this chapter, you explored several high-level Swing containers. With the Box class, you can
more easily utilize the BoxLayout manager to create a single row or column of components,
honoring the minimum, preferred, and maximum size of the components the best way possible.
Search WWH ::




Custom Search