Class InlineComponentTitledPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class InlineComponentTitledPanel extends JPanel
A panel with a component-containing border. Use a checkbox as the component, for example, to control the enablement of child widgets.

Users should modify the contents of this panel via the JPanel from getContentPane() -- add() and remove() methods have been overridden to modify the content pane; other calls to this panel should getContentPane() first.

Example:

  public class MyPanel extends InlineComponentTitledPanel {
    private JCheckBox enableCheckbox = null;
    public MyPanel() {
      super(new JCheckBox("Enable"), BorderFactory.createEtchedBorder());
      enableCheckbox = (JCheckBox) getTitleComponent();
      enableCheckbox.addActionListener(...);
      
      JPanel content = getContentPane();
      content.setLayout(new BorderLayout());
      add(new JButton("Click me"));
      ...
    }
    ...
  }
See Also:
  • Constructor Details

    • InlineComponentTitledPanel

      public InlineComponentTitledPanel(JComponent titleComponent)
      Create a panel with titleComponent in the top, left corner
      Parameters:
      titleComponent - widget to draw in the border
    • InlineComponentTitledPanel

      public InlineComponentTitledPanel(JComponent titleComponent, Border otherBorder)
      Create a panel with titleComponent in the top, left corner
      Parameters:
      titleComponent - widget to draw in the border
      otherBorder - secondary border to place around this panel
    • InlineComponentTitledPanel

      public InlineComponentTitledPanel(JComponent titleComponent, int titleJustification, int titlePosition)
      Create a panel with titleComponent in the prescribed location
      Parameters:
      titleComponent - widget to draw in the border
      titleJustification - top-bottom alignment
      titlePosition - left-right alignment
      See Also:
    • InlineComponentTitledPanel

      public InlineComponentTitledPanel(JComponent titleComponent, int titleJustification, int titlePosition, Border otherBorder)
      Create a panel with titleComponent in the prescribed location with a secondary border
      Parameters:
      titleComponent - widget to draw in the border
      titleJustification - top-bottom alignment
      titlePosition - left-right alignment
      otherBorder - secondary border to place around this panel
      See Also:
  • Method Details

    • doLayout

      public void doLayout()
      Overrides:
      doLayout in class Container
    • getTitleComponent

      public JComponent getTitleComponent()
    • setTitleComponent

      public void setTitleComponent(JComponent component)
    • setBorder

      public void setBorder(Border otherBorder)
      Sets the secondary border. NOTE: Rendering conflicts may occur with co-located sub-borders; a TitledBorder that renders in the same position (top, bottom, etc.) will cause the component to shift, and will be rendered-over if the new title resides in the same position and justification (left-to-right alignment) as the component.
      Overrides:
      setBorder in class JComponent
      Parameters:
      otherBorder -
      See Also:
    • setOtherBorder

      public void setOtherBorder(Border otherBorder)
    • getOtherBorder

      public Border getOtherBorder()
    • getContentPane

      public JPanel getContentPane()
      This class requires that all content be placed within a designated panel, this method returns that panel.
      Returns:
      panel The content panel
    • add

      public Component add(Component comp)
      Overrides:
      add in class Container
    • add

      public Component add(String name, Component comp)
      Overrides:
      add in class Container
    • add

      public Component add(Component comp, int index)
      Overrides:
      add in class Container
    • remove

      public void remove(int index)
      Overrides:
      remove in class Container
    • remove

      public void remove(Component comp)
      Overrides:
      remove in class Container
    • removeAll

      public void removeAll()
      Overrides:
      removeAll in class Container
    • setEnabled

      public void setEnabled(boolean enable)
      Overrides:
      setEnabled in class JComponent