JComponent
|
+ JComponent()
# paintBorder(Graphics)
# paintComponent(Graphics)
# paintChildren(Graphics)
+ paint(Graphics)
+ revalidate()
+ repaint(Rectangle)
+ isOpaque() : boolean
+ isVisible() : boolean
+ getBorder() : Border
+ setOpaque(boolean)
+ setVisible(boolean)
+ setBorder(Border)
+ getX() : int
+ getY() : int
+ getWidth() : int
+ getHeight() : int
+ getSize(Dimension) : Dimension
+ getBounds(Rectangle) : Rectangle
+ getMaximumSize() : Dimension
+ getMinimumSize() : Dimension
+ getPreferredSize() : Dimension
+ setMaximumSize(Dimension)
+ setMinimumSize(Dimension)
+ setPreferredSize(Dimension)
|
|
Container
|
+ Container(LayoutManager)
+ setLayout(LayoutManager)
+ getLayout() : LayoutManager
+ add(Component)
+ add(Component, int)
+ add(Component, Object)
+ invalidate()
+ doLayout()
+ getComponents() : Component[]
|
Note the hierarchy:
|
A fixed-size button...
public class ArrowButton extends BasicArrowButton {
private Dimension pref;
public ArrowButton(int type, Action action) {
super(type);
int size = new JComboBox().getPreferredSize().height - 1;
pref = new Dimension(size, size);
addActionListener(action);
}
public Dimension getMaximumSize() { return pref; }
public Dimension getMinimumSize() { return pref; }
public Dimension getPreferredSize() { return pref; }
}
A text field that won't expand vertically...
public class BaseDialog extends JDialog {
public static JTextField stdTextField(int columns) {
final JTextField tf = new JTextField(columns) {
public Dimension getMaximumSize() {
Dimension max = super.getMaximumSize();
Dimension prf = getPreferredSize();
return new Dimension(max.width, prf.height);
}
};
// ...
|
|