JCheckBox as a Title for the Panel

I have a group of checkboxes which will get enabled when their parent is checked.
I want to put all the child checkboxes in a panel and the panel tile should hold the parent checkbox.
So that whenever user checks/unchecks the parent checkbox, the child checkboxes gets enabled/disabled accordingly.
Note:
My aim is to have a checkbox as a title of the panel.
Any code sample will be helpful.
Thanks
Meghu

Hope this code will help you:
/** CheckTitledPanel - class defining a panel with a Check box title
* IMPORTANT NOTE: This class is managing 2 panels: the outer panel and the
*                 inner panel. The inner panel acts as a "content pane", so
*                 every method for adding/removing components or laying out
*                 the contents must be called on the inner panel.
*                 The method <code>getSubPanel()</code> is made for this
*                 purpose.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class CheckTitledPanel extends JPanel {
   private JCheckBox checkbox;          // The title check box
   private JPanel subpanel;             // The sub-panel (content pane)
   /** Constructs a new Check box titled panel
     * @param title  the title of the panel
   public CheckTitledPanel(String title) {
      // The outer panel is set with no layout 
      super(null);
      // Creates the check box for the title, enabled by default,
      // set its size and no border
      checkbox = new JCheckBox(title, true);
      checkbox.setSize(checkbox.getPreferredSize());
      checkbox.setBorder(null);
      // Add the listener for title checking
      checkbox.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            boolean enabled = checkbox.isSelected();
            // When clicked, we enable/disable all
            // the children of the sub-panel
            setComponentEnabled(subpanel, enabled);
            subpanel.revalidate();
      // Create the sub-panel
      subpanel = new JPanel();
      // Define the outer panel with titled border (on which
      // will be over-painted the check box)
      setBorder(BorderFactory.createTitledBorder("X"));
      // Add the 2 components: check box and sub-panel
      add(checkbox);
      add(subpanel);
      // Add the listener for panel resizing
      addComponentListener(new ComponentAdapter() {
         public void componentResized(ComponentEvent e) {
            Dimension size = getSize();
            Insets insets = getInsets();
            // Relocate and resize the sub-panel
            subpanel.setLocation(insets.left, insets.top);
            subpanel.setSize(size.width - insets.left - insets.right,
                             size.height - insets.top - insets.bottom);
            subpanel.doLayout();
            // Relocate and resize the check box
            checkbox.setLocation(insets.left + 2, 0);
            checkbox.setSize(checkbox.getSize().width, insets.top);
   /** Returns the preferred size of the panel */
   public Dimension getPreferredSize() {
      Dimension dim  = checkbox.getPreferredSize();
      Dimension dim2 = subpanel.getPreferredSize();
      Insets insets = getInsets();
      int width = dim.width + 12;
      if (dim2.width > width) width = dim2.width;     
      width = width + insets.left + insets.right;
      int height = dim2.height + insets.top + insets.bottom;
      return new Dimension(width, height);
   /** Returns the sub-panel (content pane)
     * @return  panel  the sub-panel
   public JPanel getSubPanel() {
      return subpanel;
   /** Standalone launching for tests */
   public static void main(String[] args) {
      CheckTitledPanel checkPanel = new CheckTitledPanel("Check to enable");
      checkPanel.getSubPanel().add(new JLabel("A label"));
      checkPanel.getSubPanel().add(new JTextField("A text field"));
      checkPanel.getSubPanel().revalidate();
      JFrame frame = new JFrame("Checkbox title test");
      frame.getContentPane().add(new JTextField("North field"), BorderLayout.NORTH);
      frame.getContentPane().add(new JTextField("South field"), BorderLayout.SOUTH);
      frame.getContentPane().add(new JTextField("West field"), BorderLayout.WEST);
      frame.getContentPane().add(new JTextField("East field"), BorderLayout.EAST);
      frame.getContentPane().add(checkPanel, BorderLayout.CENTER);
      frame.pack();
      frame.setVisible(true);
   /** Returns the sub-panel (content pane)
     * @return  panel  the sub-panel
   /** Enable/disable a component and its children
     * @param  rootcomp  the component to enable/disable
     * @param  enable    a boolean (true to enable)
   public static void setComponentEnabled(Component rootcomp, boolean enabled) {
      if (rootcomp==null) return;
      rootcomp.setEnabled(enabled);
      if (rootcomp instanceof java.awt.Container) {
         Component[] comps = ((Container)rootcomp).getComponents();
         String subvalues = "";
         for (int i=0; i<comps.length; i++) {
            setComponentEnabled(comps,enabled);
// The following methods can be overwritten if you want to manage children
// of the panel exactly the same way as a standard panel. In this case, you
// will no more need to call getSubPanel().
public Component add(Component comp) {
subpanel.add(comp);
public Component add(String name, Component comp) {
subpanel.add(name, comp);
public Component add(Component comp, int index) {
subpanel.add(comp, index);
public Component add(Component comp, Object constraints) {
subpanel.add(comp, constraints);
public Component add(Component comp, Object constraints, int index) {
subpanel.add(comp, constraints, index);
public Component findComponentAt(int x, int y) {
return subpanel.findComponentAt(x, y);
public Component findComponentAt(Point p) {
return subpanel.findComponentAt(p);
public Component getComponent(int n) {
return subpanel.getComponent(n);
public Component getComponentAt(int x, int y) {
return subpanel.getComponentAt(x, y);
public Component getComponentAt(Point p) {
return subpanel.getComponentAt(p);
public LayoutManager getLayout() {
return subpanel.getLayout()
public int getComponentCount() {
return subpanel.getComponentCount();
public Component[] getComponents()
return subpanel.getComponents();
public void remove(Component comp) {
subpanel.remove(comp);
public void remove(int index) {
subpanel.remove(index);
public void removeAll() {
subpanel.removeAll();
public void setLayout(LayoutManager mgr)
subpanel.setLayout(mgr);
Regards.

Similar Messages

  • How can I create a Title for the worksheet in Discoverer Plus

    Dear members,
    I am using discoverer 4i Plus to create workbooks. I am not finding an option to insert a title for the worksheet. In Discoverer Desktop we have a separate option to insert or edit a title. I am not sure how can we create titles in Plus.
    Any suggestions.
    Thanks
    Sandeep

    Hi,
    I am not able to login to Discoverer Desktop Using my Applications username. My Desktop Version is 4.1.37. The same username works in Discoverer 4i Plus and i can create workbook there.
    I went to Tools--->Options--->Connections and checked the option connect to both standard and application EUL's and while i am logging in i checked the small box which comes in the login screen. I do not know why this happening.
    I am also able to login as the database user in Desktop but not as an application user.
    I want to login into desktop as an application user and create a template workbook which has title and then assign that workbook to a particular responsibility since creating title cannot be done in Plus.
    I am not sure what's going wrong here because the Desktop works for database user but not for an application user. Any comments are highly appreciated.
    Thanks
    sandeep

  • TITLE for the Interactive report

    Hi,
    I like to show a Title for the Interactive Report in several different languages.
    But it seems if I just pick Interactive report, there will be no Title shown.
    What is proper way of doing this ?
    So, what I did was, I created a HTNL region, just to show the Title, but it seems the translation and XLF file doesn't pick it up
    Please help
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I have further to report.
    It looks like a bug.
    The REGION title text is missing in "TRANSLATE APPLICATION" in "SHARED COMPONENTS" under WINDOWS environment.
    The REGION title text is in SUN environment, but does not shown as translated in the browser.
    Thx
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to set a backgound pic for the panel

    I use a JTable as a member of a JPanel Object, and I want to set a backgound pic for the panel ,How to?

    Hello,
    import java.awt.*;
    import javax.swing.*;
    public class ImageTest extends JFrame
         public static void main(String[] args)
              new ImageTest();
         public ImageTest()
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              MainPanel pan = new MainPanel();
              pan.add(new JTable(6, 3));
              getContentPane().add(pan);
              pack();
              setVisible(true);
         class MainPanel extends JPanel
              private Toolkit tool = Toolkit.getDefaultToolkit();
              private MediaTracker media = new MediaTracker(this);
              private Image background = tool.getImage(yourImage);
              MainPanel()
                   super();
                   media.addImage(background, 0);
                   try
                   {     //wait to calcute sizes correctly
                        media.waitForID(0);
                   }catch (InterruptedException e){}
              public void paintComponent(Graphics g)
                   super.paintComponent(g);
                   g.drawImage(background, this.getX(), this.getY(), this);
              public Dimension getPreferredSize()
                   return new Dimension(background.getWidth(this), background.getHeight(this));
    }regards,
    Tim

  • Is there any way to enlarge the font for the panels in Bridge?

    Is there any way to enlarge the font for the panels in Bridge? Either CC or CS6?

    To change the default message font, use UIManager:   UIManager.put("OptionPane.messageFont",
          new Font("Lucida Console", Font.PLAIN, 12)); Per-instance, use HTML:   JOptionPane.showMessageDialog(
          "<html><font face='Lucida Console'>Your message here</font></html>");

  • Browser tab title for the site goes away.

    I have modified my master page to show the Title for the Site Home page in the Intranet Portal. The tag in the master page reads this:
    <title id="Title1" runat="server"><asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server">ABC</asp:ContentPlaceHolder> </title>
    When I browse the site in IE, the title "ABC" shows up in the browser tab but goes away after some time. In chrome, it gets replaced by the URL of the Site page:
    http://site/pages/default.aspx. It only happens when i'm on the Site Home page. When i'm on a different page or within sub-site, it retains the Name of that page. How can I resolve this so that Title stays as long
    as I'm on the site home page.
    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

    Hi K-Joshi,
    According to your description, my understanding is that you want to customize the browser title for a site in SharePoint 2010.
    Please change the Title tag in your master page as the followings:
    <title id="Title1" runat="server">
    <SharePoint:EncodedLiteral runat="server" text="ABC " EncodeMethod='HtmlEncode' />
    <asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server"/>
    </title>
    More information, please refer to the link:
    http://www.broculos.net/2013/07/how-to-customize-title-tag-in.html#.U3rvDHmKCM8
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • What are the UserChrome classes/ids for the panel widget?

    I am customizing my Firefox and it looks great, but I can't figure out how to customize the panel widget, like the one used in the downloads panel. I want to edit the widget browser-wide so that it can be compatible with addons that use that. I can't find an addon for this or the classes/ids that would work in the UserChrome.css file. I tried the DOM Inspector, but I couldn't figure out how to make that work.
    I'm using Aurora 27.0a2 on Windows XP.

    HI iansan5653
    I am not sure if you are trying to make a widget/extension? for the browser or just customize the appearance of the user. I believe you have to create an appearance and then allow the user to download the appearance to change the styles.
    I think you may want this webkit -moz-appearance[[https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance]]
    I did some research on this and the MozillaZine is a great reference for all of the Preferences to add stuff to the panels.
    Some more information
    * [[http://kb.mozillazine.org/Category:Preferences|MozillaZine Category:Preferences]]
    * This Menu editor may help [[https://addons.mozilla.org/en-US/firefox/addon/menu-editor/?src=search]]
    * UserChrome.css info [[http://kb.mozillazine.org/index.php?title=UserChrome.css&printable=yes]]
    * Visual Customizations [[http://kb.mozillazine.org/Category:Visual_customizations_%28Firefox%29]]
    *topics [[http://forums.mozillazine.org/viewtopic.php?t=1006795]]
    I have also seen extensions made by adding style to these items in the about:config. You could live update the items and see if the css makes changes live in the browser and see how the file renders. [[http://kb.mozillazine.org/About:config_entries#UI.]]
    But for better help on this I would recommend asking the mdn
    [[https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Mozilla_Extensions]]
    If you can define your set up, the Mozilla Developer Network may be the place for you. Hope this helps.

  • Regarding Title for the Screen

    Hi,
       I want the title of the screen as  Title name along with date & time ( date & time from table ).
      How can i set that ?
      Waiting for ur Reply...
    Regards
    Srinath

    Hi try this code ,
    Here you can give the values inside p1 and p2.
    DATA: title  TYPE string,
          prog   TYPE string,
          p1(10) TYPE c,
          p2(10) TYPE c.
    MODULE status_0100 OUTPUT.
      title = 'TITLE_0100'.
      prog  = '...'.
      p1 = '...'.
      p2 = '...'.
      SET TITLEBAR title OF PROGRAM prog WITH p1 p2.
    ENDMODULE.
    Regards,
    Amit.

  • Is it normal for the Panels to make slight noises when applied with some pressure such as opening the and closing the Mac? It sounds like the screws are not tight enough or is it normal?

    Hi, My Mac is around 2 months old, and I have recently come across a slight problem. I've experienced some slight noises happening such as when I open and close the macbook it makes some sort of clicking noises as if to say the panels are loose or have not been screwed properly... It only happens when pressure is applied e.g. when I am typing I tend to rest the palms of my hand on the two plain sections of the mac (next to the track pad) and this causes some sort of pressure to push down to the connecting panel underneath, this is when the clicking sound happens.
    I don't know maybe I'm just expecting too much or it might just be what I think it is, anyway if anyone has experience this issue, feel free to share your point of views or past similar experience. Thanks.

    Yes.. It's been a while, but I remember thinking the same thing!
    Below are a couple of other links where folks reported the same thing!
    http://discussions.apple.com/thread.jspa?messageID=5755300&#5755300
    http://discussions.apple.com/thread.jspa?messageID=6552175&#6552175

  • Title for the Legend in jfree charts

    Hi,
    I want to give the Legend a Header i.e a block above the legend stating the name of the Legend. I am unable to find a method that would help me with this.M using jfree1.0.2
    (a small example could be helpful)

    Hi Manish,
    Can try like this:
    Standard Field >> Do F1, Take the Data Element.
    Go to CMOD, on that screen Click Goto >> Text enhancements>> Keywords >> Change.
    Type the Data Element name noted earlier. Press Enter.
    A screen with several fields will be displayed. They contain the various descriptions for the data element selected. Depending on what screen/layout this data element is used the system will use one of the short, medium or long description fields.
    The Heading field, as its name suggests, will be used in the list header row of a layout. The Short Description field will be used when you select the function key F1 (help) on that field.
    The length of each field is :
    - Short field label: 10 characters
    - Medium field label: 20 characters
    - Long field label: 40 characters
    - Heading: 55 characters
    - Short Description: 60 characters
    Replace the texts with those that you want to appear. Save your changes (This will be a Customising Request). Note that this is a cross client change.
    Please note that F1 Help will still display the standard help, with only the First Line changed as per your corrections (Custom Field Name).
    Regards
    Saurabh

  • How to make one letter in the title for a panel bold

    I have a titled border and one letter of that title needs to be made bold. Any suggesstions on how this can be done?
    I tried using html but got the html text also displayed as such
    For text Title, using html i got this
    <b>T</b>itle

    For reference, what Suleena actually posted, before the forum software rendered it, was:
    For text Title, using html i got this
    <b>T</b>itledb

  • How to configure the zxp so that it will place the related files for the panel in specific folder other than the usual 'C:\Program Files (x86)\Common Files \Adobe\CEPServiceManager4\extensions\' folder ?

    Hi,
    I am Working on a panel for Adobe Premiere pro CC, Now we got a panel set up which will install all the related folders and files which are part of the Extension content folder in the
    C:\Program Files (x86)\Common Files \Adobe\CEPServiceManager4\extensions \Panel\CONFIG folder. But we need to change this location to C:\Users\USER\APPDATA folder or any other user specified folder during installation itself.
    Is there any way to do this from extension builder?
    Thanks and Regards,
    Anoop NR

    Thanks guys,
    Got it !! Hybrid extensions.
    I am using Adobe Extension builder 3 in Eclipse to code and create the zxp for Premiere pro panel.
    Seeing the hybrid extension part in  HTML Panels Tips: #10 Packaging / ZXP Installers | Photoshop, etc. I have added a hybrid extension panel using the bundle manifest editor in the extension builder. it creates an mxi file automatically with all the properties, I have to change the maximum host version number in the mxi file in order to make the extension work in the Premiere pro CC 2014. Using the Hybrid option in the Bundle manifest editor we can choose a set of folder paths for placing the files during installation itself and later can be used using 'csInterface.getSystemPath(SystemPath.CODE)' from javascript functions to modify them.
    Thanks for your relpies,
    Anoop NR

  • Where are the titles for the movies in os7

    What happened to the titles in OS7 in the Movies app?

    I noticed this problem right away.  They way they told me to fix it, is create some sort of jpeg document that has the name in it, and add it to the file on itunes as artwork.  So, for example, I made a powerpoint document with the name of each file as a separate slide.  Then I saved it as jpeg which created a folder with one document for each slide.  Then you have to select the file in itunes, go to Get Info, and then hit the artwork tab and add the corresponding jpeg file as artwork.  I tested this out and it works, but I have not and probably will not do it for all.  Just too much work and I hope they will fix it.

  • How to Change Date Format in the Title of the report.

    Hi Everyone,
    I want to change the Format of the Date in the title(Query run Date)taken by report through the variable "&Date" .
    The Format available is DD-MON-YY
    Desired Format is DD-MON-YYYY.
    Please let me know the same as early as possible.

    Hi NP,
    What I try to do is to reformat the default &date inserted into the Title for Discovere Plus and Viewer. When you edit the Title for the report, you can select the date from the Insert dropdown list to display the date when the report was run. The Date (shown &Date in the Title) has a default format of DD-MON-YY. As I have other date parameters displyed in the Title that have the format of DD-MON-YYYY specified by the user, I want to have the &Data in the same format. Please advise me how to achieve this.
    Thank yiou very much,
    J.K.

  • How to populate column titles for y values when using Write to Measurement File Express VI with a tab delimited text-based .lvm file?

    The .lvm file generated by the Write to Measurement File Express VI includes column heading titles for the y values, but they are a default value of "untitled".  See attached example of a sample file when opened in Excel, the values in question are highlighted.  Is there a way to specify the column titles when the file is written?
    This is a similar question to this posting, which received a work around response to use the Write to Spreadsheet File.vi, rather than a solution when using this VI.
    Message Edited by Hightop Raven on 05-02-2007 03:37 PM
    Attachments:
    column_titles.gif ‏13 KB

    Sorry for the late reply.  I was out of the office Friday.
    You can do it, but the code can get rather ugly.  Under the hood, the dynamic data type (the dark blue wire) is an array of waveforms.  In your case, the scalar values you convert to a dynamic data type are being converted to an array of waveforms, each waveform having one element.  You have two options.
    Explicitly convert your scalars to one-element waveforms (t0=0, dt=1) and add the title before conversion to a dynamic data type.
    Convert your dynamic data type to an array of waveforms and loop through them to add the column labels.  The conversion blocks are in the Signal Manipulation Express palette.
    I would recommend 2, since it is the easiest to add.  It is also the easiest to run only on the first iteration.  Just put a case selector around the loop, wire the selection to the While loop iterator, and set the case containing the label code to 0.  The default case simply passes through the dynamic data.
    My apologies for not including a screen shot.  I am in the process of upgrading my machine and can't run LabVIEW.  If you need one, let me know and I can post one tomorrow.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

Maybe you are looking for

  • Access to Entity Service from Portal Application

    Hi Experts, I have a hybrid application which will be making use of both Web Dynpro and Portal Applications. I decided to use Entity Services to store my back-end data and can access it fine from the Web Dynpro project. I have included the public par

  • C2-03 compatible on US mobile networks?

    I recently purchased the Nokia C2-03 for a senior staff member since Nokia advertises it as a quad-band phone. GSM 850/900/1800/1900 However the phone does not recognise any sim card inserted in the device when in the US. Is there any setting that ne

  • Transferring data

    I purchased a new MacBook Pro and want to transfer over files from my old PowerBook G4 (OS X.3.9). I hooked them both up to my wireless network and opened Migration Assistant on the new MacBook Pro. It tells me to open MA on the other computer and se

  • HotSync M125 with Win XP MC

    The Palm Desktop finally opened to my calendar after repeated installs/repairs of it(v4.1.4). However, when the M125 is connected via USB in the front of my Emachine (Win xp MC 2004) and I try to get it to sync via the cradle, I keep getting the mess

  • Server Virtualization with Windows Server Hyper-v and System Center Expiration

    Prometric says: STATUS: Passed, EXPIRATION: 22-03-2015. Does this means that I have to take the exam again before 22-03-2015?