/** * Creates a {@code BottomBar} of the given size. * * @param size the height of the {@code BottomBar}. */ public BottomBar(BottomBarSize size) { createAndInstallBackgroundPainter(); createAndInstallBorder(); // fBottomBar.forceOuterAreasToHaveTheSameWidth(); // TODO use the actual border insets instead of the hard-coded value 2. // calculate the height of the bottom bar. this includes adding two pixels to incorporate // the height of the line border. int height = size.getHeight() + 2; fBottomBar.getComponent().setPreferredSize(new Dimension(-1, height)); // install a listener that will repaint this component when the parent window's focus state // changes. WindowUtils.installJComponentRepainterOnWindowFocusChanged(fBottomBar.getComponent()); }
private void createAndInstallBorder() { FocusStateMatteBorder outterBorder = new FocusStateMatteBorder( 1, 0, 0, 0, MacColorUtils.getTexturedWindowToolbarBorderFocusedColor(), MacColorUtils.getTexturedWindowToolbarBorderUnfocusedColor(), fBottomBar.getComponent()); Border innerBorder = BorderFactory.createMatteBorder(1, 0, 0, 0, getBorderHighlightColor()); Border lineBorders = BorderFactory.createCompoundBorder(outterBorder, innerBorder); // TODO determine if there is a good standard for this. there doesn't seem to be any // TODO consistent value used by Apple. // left and right edge padding. int padding = 5; fBottomBar .getComponent() .setBorder( BorderFactory.createCompoundBorder( lineBorders, BorderFactory.createEmptyBorder(0, padding, 0, padding))); }
/** * Adds the given component to the side of this {@code BottomBar}. * * @param toolToAdd the tool to add to this {@code BottomBar}. */ public void addComponentToCenter(JComponent toolToAdd) { fBottomBar.addComponentToCenter(toolToAdd); }
/** * Adds the given component to the left side of this {@code BottomBar} followed by the given an * empty space of the given pixel width. * * @param toolToAdd the tool to add to this {@code BottomBar}. * @param spacer_pixels the amount of space to post-pend the added component with. */ public void addComponentToLeft(JComponent toolToAdd, int spacer_pixels) { fBottomBar.addComponentToLeft(toolToAdd, spacer_pixels); }
/** * Adds the given component to the left side of this {@code BottomBar}. * * @param toolToAdd the tool to add to this {@code BottomBar}. */ public void addComponentToLeft(JComponent toolToAdd) { fBottomBar.addComponentToLeft(toolToAdd); }
private void createAndInstallBackgroundPainter() { fBottomBar.setBackgroundPainter(createDefaultPainter()); }
public void forceOuterAreasToHaveTheSameWidth() { fBottomBar.forceOuterAreasToHaveTheSameWidth(); }
/** * Gets the user interface component representing this {@code BottomBar}. The returned {@link * JComponent} should be added to a container that will be displayed. * * @return the user interface component representing this {@code BottomBar}. */ public JComponent getComponent() { return fBottomBar.getComponent(); }