Help ! JCheckBox in JFileChooser ??

hi..
how will include a JCheckBox in A JFileChooser.showOpenDialog ?? my requirement is to create a Read only check Box in the showOpenDialog box .. is that possible.. if so please do help..
Thanking you..
rG.

Quickest would be to sub JFileChooser.... :)
It can also be added to a panel, so that is a possible solve as well...

Similar Messages

  • Help with "simple" JFileChooser problem...

    Hi all,
    how do I set the font in a JFileChooser???
    I have tried everything, but it always uses the Look & Feels default font setting. Can I change the default Look&Feels font setting?
    Greatfully for any suggestions!
    Cheers
    Anders ;-D

    Hello!
    You can use the UIManager, e.g. UIManager.put("FileChooser.font", new Font("Arial",
    Font.BOLD, 14);
    Well, that didn't seem to help with my case either. So I tried something else: I overrided all of the defaults by using UIManager.put(key, value) this way I got all of the Fonts in the JFileChooser to change.
    Correct me if I'm wrong... ;)
    - Cathra -
    Sample Code that performs the requested:
    // Prepare the resources
    FontUIResource font12Arial = new FontUIResource( "Arial", Font.PLAIN, 12 );
    // Put values into UIDefaults (before initializing the JFileChooser)
    UIManager.put( "ToolTip.font", font12Arial );
    UIManager.put( "OptionPane.messageFont", font12Arial );
    // shown for example
    UIManager.put("FileChooser.openButtonText", "OpenUp");
    UIManager.put("Button.font", font12Arial);
    UIManager.put("Label.font", font12Arial);
    UIManager.put("Table.font", font12Arial);
    UIManager.put("TextField.font", font12Arial);
    UIManager.put("ScrollPane.font", font12Arial);
    UIManager.put("ComboBox.font", font12Arial);
    UIManager.put("CheckBox.font", font12Arial);
    UIManager.put("TitledBorder.font", font12Arial);
    UIManager.put("RadioButton.font", font12Arial);
    UIManager.put("ToolTip.font", font12Arial);
    UIManager.put("TextPane.font", font12Arial);
    UIManager.put("TextArea.font", font12Arial);
    UIManager.put("Tree.font", font12Arial);
    UIManager.put("List.font", font12Arial);
    UIManager.put("MenuBar.font", font12Arial);
    UIManager.put("Menu.font", font12Arial);
    UIManager.put("MenuItem.font", font12Arial);
    UIManager.put("TableHeader.font", font12Arial);
    UIManager.put("TabbedPane.font", font12Arial);
    // somewhere in the code:
    JFileChooser c = new JFileChooser();
    c.showOpenDialog(aParentFrame);

  • Small Help Needed in JFileChooser

    I've a small problem in using JFileChooser.
    I want to disable the doubleclick option if chosen is a file and enable if it is a folder
    or
    i want both the properties of singleclick and doubleclick to be same.
    i.e, if it is a folder as it gets inside the folder. incase of file it shudn't do anything (filechooser shudn't get closed). But as of now the file chooser is getting closed on double click on a file and it returns the selected file's name when i printed using chooser.getSelectedFile(). what i want now is, the filechooser shudn't return anything until i click the open button on the filechooser window.
    Can someone help me out in terlling me how to do this
    TIA

    um.... how about get the JDK?
    Also, please don't try to use a non-applet program as if it were an applet. It won't work.
    Also, please go through the Sun Java tutorials, especially the first ones about getting started.
    Edited by: Encephalopathic on Feb 26, 2008 9:56 PM

  • Help with custom JFileChooser

    Hello everyone,
    I would like to customize JFileChooser to display a panel with some text above the folder browse section.
    Is this possible... if so, could anyone provide some sample code on how to get this started?

    I'm afraid you're on your own. Noone has [ever done something like that before|http://www.google.com/search?q=customizing jfilechooser].

  • Help needed regarding JFileChooser

    hi, this is ravikiran,
    I am having a situation where when a save dialog appears, I must provide a default name for the file to be saved in the "File Name" field of save dialog.
    Which property of the JFileCooser must be set in order to do this.
    help me.
    thanx in advance.

    The is a method to set the directory and a method to set the file name.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • How to browse a file and extract its contents

    i want to browse a file and extract its contents.My code is given below but its not working .Can anybody help me please
    JFileChooser fc = new JFileChooser();
              int returnVal = fc.showOpenDialog(jfrm);
              if (returnVal == JFileChooser.APPROVE_OPTION)
              File file = fc.getSelectedFile();
              //This is where a real application would open the file.
              fileName=file.getName();
              //This is a file function to extract data from a file.
              //It reads data from a file that can be viewed on cmd
              jlab3.setText(fileName);
              try
    // Open the file that is the first
    // command line parameter
    FileInputStream fstream = new FileInputStream(fileName);
    // Convert our input stream to a
    // DataInputStream
              DataInputStream in =new DataInputStream(fstream);
    // Continue to read lines while
    // there are still some left to read
    // while (in.available() !=0)
    // Print file line to screen
              fileName1=in.readLine();
              jlab3.setText(fileName1);
              in.close();
    catch (Exception e)
              System.err.println("File input error");
              }

    JFileChooser fc = new JFileChooser();
    int returnVal = fc.showOpenDialog(jfrm);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File file = fc.getSelectedFile();
    //This is where a real application would open the file.
    fileName=file.getName();
    //This is a file function to extract data from a file.
    //It reads data from a file that can be viewed on cmd
    jlab3.setText(fileName);
    try
    // Open the file that is the first
    // command line parameter
    FileInputStream fstream = new FileInputStream(fileName);
    // Convert our input stream to a
    // DataInputStream
    DataInputStream in =new DataInputStream(fstream);
    // Continue to read lines while
    // there are still some left to read
    // while (in.available() !=0)
    // Print file line to screenHere you are reading the first line of the file
      fileName1=in.readLine();
    //}and here you are displaying the line in a (I suppose) JLabel. A JLabel is not very suitable for displaying a file content, except is the file contain few characters !!!
    jlab3.setText(fileName1);
    in.close();
    catch (Exception e)
    System.err.println("File input error");
    }If you want to read the complete file content you must uncomment lines inside while instruction, like this
    while (in.available() > 0) {  // I prefer to test in.available like this, instead of !=
      // append text to a StringBuffer (variable named sb here) or directly in a textarea.
      sb.append(in.readLine());
    ...

  • Submiting forms returns a "Save As File" dialog box

    I've got a form that users return via email, one user always gets a Save As File dialog box and since this doesn't match the instructions.  User doesn't return the form as others do.  Any help greatly appreiciated.

    JFileChooser does support a "save-as" dialog. Follow the link from the API documentation to the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html

  • How do I add a JCheckBox to a JTable - URGENT HELP NEEDED

    Hello All,
    This is kicking my butt. I need to create a JTable that I can dynamically add and delete rows of data to and this table must contain a JCheckBox which I can read the value of. I've been able to find examples out there that provides the ability to have a JCheckBox in the JTable, but do not also provide the function to add / delete rows from the JTable. I need to have both funtions in my table. Can somebody out there please help me with this?
    Here's a simple example that I'm working with as a test to figure this out. This example has the functionality to add rows of data.
    Thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    import javax.swing.table.*;
    public class TableTest extends JFrame implements ActionListener
         JButton btnAdd;
         BorderLayout layout;
         DefaultTableModel model;
         public static void main(String[] args)
              TableTest app = new TableTest();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TableTest()
              super("Table Example");
              layout = new BorderLayout();
              Container container = getContentPane();
              container.setLayout(layout);
              btnAdd = new JButton("Add");
              btnAdd.addActionListener(this);
              model = new DefaultTableModel();
              JTable table = new JTable(model);
              // Create a couple of columns
              model.addColumn("Col1");
              model.addColumn("Col2");
              // Append a row
              model.addRow(new Object[] { "v1", "v2" });
              model.addRow(new Object[] { "v3", "v4" });
              JScrollPane scrollPane = new JScrollPane(table);
              container.add(btnAdd, BorderLayout.NORTH);
              container.add(scrollPane,BorderLayout.CENTER);
              setSize(300, 200);
              setVisible(true);
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == btnAdd)
                   model.addRow(new Object[]{"Test", new Boolean(true)});
    }

    I got it, I added the public Class getColumnClass to new DefaultTableModel(). Here it is for your viewing pleasure.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    import javax.swing.table.*;
    public class TableTest extends JFrame implements ActionListener
         JButton btnAdd;
         BorderLayout layout;
         DefaultTableModel model;
         JTable table;
         public static void main(String[] args)
              TableTest app = new TableTest();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TableTest()
              super("Table Example");
              layout = new BorderLayout();
              Container container = getContentPane();
              container.setLayout(layout);
              btnAdd = new JButton("Add");
              btnAdd.addActionListener(this);
              model = new DefaultTableModel()
                   public Class getColumnClass(int col)
                        switch (col)
                             case 1 :
                                  return Boolean.class;
                             default :
                                  return Object.class;
              table = new JTable(model);
              // Create a couple of columns
              model.addColumn("Col1");
              model.addColumn("Col2");
              // Append a row
              model.addRow(new Object[] { "v1", new Boolean(false)});
              model.addRow(new Object[] { "v3", new Boolean(false)});
              JScrollPane scrollPane = new JScrollPane(table);
              container.add(btnAdd, BorderLayout.NORTH);
              container.add(scrollPane, BorderLayout.CENTER);
              setSize(300, 200);
              setVisible(true);
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == btnAdd)
                   model.addRow(new Object[] { "Karl", new Boolean(true)});

  • JFileChooser weird problem (Help!!!)

    Does anyone here have loading problem with JFileChooser?
    I have a class that inherited the JFileChooser class and another class that inherited the JFrame class and this class create an instance of the JFileChooser class.
    My program sometime will not show (but sometime will: no changes at all) and they are no exception being shown on the console window what so ever. I can solve my program by initializing the JFileChooser object after showing the application and not before but that stupid JFileChooser is so slow to initialize. What the hell is going on? Any help hint would be appreciated.

    I also want to add that the following code is in my JFileChooser class:
    protected JDialog createDialog(Component Parent)
    JDialog CustomDialog=super.createDialog(Parent);
    CustomDialog.setLocationRelativeTo(Parent);
    CustomDialog.setResizable(false);
    return CustomDialog;
    Aside from the abnormally, I don't not what else could be causing the problem!

  • JCheckBox/Action Listener help

    Hey
    I'm trying to make an applet with two tabs, a PurchasePanel and a StorePanel, and have data altered in one of them affect the data in the other. On the StorePanel, the data is input infields and through a ButtonListener command it is stored as both a String in a text field on the StorePanel, and as a check box on the PurchasePanel. Now, from the PurchasePanel I need to make an ActionListener function that when the CheckBoxes are pressed, some data is added to another textfield, and when it is unchecked the data is removed. I'm not sure I implemented the actionlistener correctly as the buttonlistener and the actionlistener commands aren't recognizing variables from each other. Any help is appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.Container;
    import java.text.*;
    public class StorePanel extends JPanel
    private ArrayList compList;
    private PurchasePanel purchasePanel;
    private JLabel brandName, price, memory, cpuType, cpuSpeed, info;
    private JTextArea cpuInfo;
    private JTextField BTL, PTL, MTL, TTL, STL;
    private JPanel smallPanel, leftPanel, rightPanel, wholePanel;
    private JScrollPane scrollBox;
    public int counter = 0;
    public StorePanel(ArrayList compList, PurchasePanel pPanel)
    this.compList = compList;
    this.purchasePanel = pPanel;
    brandName = new JLabel("Brand Name ");
    price = new JLabel("Price");
    memory = new JLabel("Memory");
    cpuType = new JLabel("CPU Type");
    cpuSpeed = new JLabel("CPU Speed");
    BTL = new JTextField();
    PTL = new JTextField();
    MTL = new JTextField();
    TTL = new JTextField();
    STL = new JTextField();
    JPanel smallPanel = new JPanel();
    smallPanel.setLayout(new GridLayout(5,2));
    smallPanel.add(brandName);
    smallPanel.add(BTL);
    smallPanel.add(price);
    smallPanel.add(PTL);
    smallPanel.add(memory);
    smallPanel.add(MTL);
    smallPanel.add(cpuType);
    smallPanel.add(TTL);
    smallPanel.add(cpuSpeed);
    smallPanel.add(STL);
    // organize components here
    // here is an example
    JButton button1 = new JButton("Store");
    button1.setSize(1,1);
    button1.addActionListener(new ButtonListener());
    info = new JLabel("INFORMATION", SwingConstants.CENTER);
    leftPanel = new JPanel();
    leftPanel.setLayout(new BorderLayout());
    leftPanel.add(info,BorderLayout.NORTH);
    leftPanel.add(smallPanel,BorderLayout.CENTER);
    leftPanel.add(button1,BorderLayout.SOUTH);
    cpuInfo = new JTextArea("No Computer",19,27);
    scrollBox = new JScrollPane(cpuInfo);
    rightPanel = new JPanel();
    rightPanel.add(scrollBox);
    wholePanel = new JPanel();
    wholePanel.setLayout(new BorderLayout());
    wholePanel.add(leftPanel,BorderLayout.WEST);
    wholePanel.add(rightPanel,BorderLayout.EAST);
    this.add(wholePanel);
    private class ButtonListener implements ActionListener
         public void actionPerformed(ActionEvent event)
              String BN = BTL.getText();
              String P = PTL.getText();
              String M = MTL.getText();
              String CT = TTL.getText();
              String CS = STL.getText();
              String error = "";
              String enter = "";
              String computerString = "";
              int speed = 0;
              int memory = 0;
              double price = 0;
              String status = "Yes";
              String bPrice = "";
              JCheckBox computer;
              try
                   speed = Integer.parseInt(CS);
                   memory = Integer.parseInt(M);
                   price = Double.parseDouble(P);
              catch (NumberFormatException exception)
                   info.setText("Enter a number for Price, Memory, or Speed.");
                   info.setForeground(Color.red);
                   status = "No";
              if(BN.length() == 0 || P.length() == 0 || M.length() == 0 || CT.length() == 0 || CS.length() == 0)
                   error = "Please Enter All Fields.";
                   status = "Empty";
              if(status == "Yes" || status == "Empty")
              if(error == "Please Enter All Fields.")
                   info.setText(error);
                   info.setForeground(Color.red);
              else
                   DecimalFormat myFormatter = new DecimalFormat("0,000.00");
                   bPrice = myFormatter.format(price);
                   if(counter == 0)
                        cpuInfo.replaceRange("",0,11);
                   enter = "\nBrandName:\t\t" + BN + "\nCPU:\t\t" + CT + "," + speed
                                  + "HZ\nMemory:\t\t" + memory + "M\nprice:\t\t$" + bPrice + "\n";
                   info.setText("Computer Added.");
                   info.setForeground(Color.red);
                   cpuInfo.append(enter);
                   counter ++;
                   computer = new JCheckBox("BrandName:"+BN+"CPU:"+CT+","+speed+"HZMemory:"+memory+"Mprice:$"+bPrice);
                   computer.addItemListener(new PurchasePanel.CheckBoxListener());
                   purchasePanel.leftPane.add(computer);
                   compList.add(computer);
    public class PurchasePanel extends JPanel
    private ArrayList compList;
    private JLabel CTP, Filler;
    private JTextArea totalPrice;
    protected JPanel rightPane, leftPane;
    protected JSplitPane wholePane;
    private JScrollPane scrollPane;
    private JCheckBox checked;
    private double TP = 0.00;
    public PurchasePanel(ArrayList compList)
         this.compList = compList;
         // organize components for purchase panel
         CTP = new JLabel("Current Total Purchase");
         Filler = new JLabel(" ");
    totalPrice = new JTextArea("$" + TP,18,22);
    scrollPane = new JScrollPane(totalPrice);
         rightPane = new JPanel();
         rightPane.setLayout(new BorderLayout());
    rightPane.add(CTP, BorderLayout.CENTER);
         rightPane.add(scrollPane, BorderLayout.SOUTH);
         leftPane = new JPanel();
         leftPane.setLayout(new BoxLayout(leftPane, BoxLayout.Y_AXIS));
         leftPane.setSize(800,700);
         leftPane.add(Filler);
         wholePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane);
         this.add(wholePane);
    private class CheckBoxListener implements ItemListener
         public void itemStateChanged(ItemEvent event)
                   if(StorePanel.ButtonListener.computer.getStateChange() == ItemEvent.SELECTED)
                        TP = TP + 10.05;
    public class Assignment6 extends JApplet
    private int APPLET_WIDTH = 650, APPLET_HEIGHT = 350;
    private JTabbedPane tPane;
    private StorePanel storePanel;
    private PurchasePanel purchasePanel;
    private ArrayList computerList;
    //The method init initializes the Applet with a Pane with two tabs
    public void init()
         //list of computers to be used in every panel
         computerList = new ArrayList();
         //customer purchase panel uses the list of computers
         purchasePanel = new PurchasePanel(computerList);
         //store inventory panel uses the list of computers and also
         //established a connection with purchasePanel
    storePanel = new StorePanel(computerList, purchasePanel);
    //create a tabbed pane with two tabs
    tPane = new JTabbedPane();
    tPane.addTab("Store Inventory", storePanel);
    tPane.addTab("Customer Purchase", purchasePanel);
    getContentPane().add(tPane);
    setSize (APPLET_WIDTH, APPLET_HEIGHT); //set Applet size
    }

    If you pass along references to the appropriate panel to the Listeners, then they can update the right thing accordingly eg.
    // To enable the StorePanel to add/erase data from a textfield by listening to a checkbox in the PurchasePanel class
    // PurchasePanel class
    checked.addItemListener(new CheckBoxListener(storePanel));
    // CheckBoxListener class
    public void itemStateChanged(ItemEvent e) {
        // When checkbox checked
        if(checked)
            storePanel.writeToTextField("blahblah");
        else
            storePanel.writeToTextField("");
    }That was pseudocode of course! If you need the PurchasePanel to listen to the button in the StorePanel, you need to do the reverse.

  • Missing pieces of components (JFileChooser, JButtons, etc) help?

    The normal window in the GUI i'm working on, works fine. When i bring up a new NetFrame (e.g. preferences) the components aren't drawn completely. None of the 3 buttons show up, a few check boxes in a tabbed pane show up (not all of them), etc. When i click where a button should be, it appears. When i switch to the other tab in the pane, its contents appear (except for a small missing bottom right corner of the border for a jtextarea), and when i switch back to the first tab, all of its contents appear. When i resize the panel, everything shows up.
    I've tried calling validate, revalidate, validateTree, repaint, show, pack, none of them do anything (pack rearranges things, but nothing new appears).
    I'm completely out of ideas!
    A previous version of the program works fine, so it is something wrong with my code (i.e. not my computer / packages etc).
    The thing that really stumps me, is that a JFileChooser appears incomplete -- only showing the file browser section, and the okay button (missing cancel button, and borders etc).
    I'm sorry i don't have any sample code to show, there too much to put it all, and i have no idea where the problem is.
    I'd appreciate any help or direction you have. THANKS!

    possibly related
    [http://forums.sun.com/thread.jspa?threadID=780103]

  • Need help for JFileChooser

    Hi,
    I need help on this one. I have a filechooser class which extended from JFileChooser class. Every thing works fine except this: I want to by hiting the "Enter" key to save the files. The "Enter" key works only when the focus is in the file name text field now, I want it to work when the focus is in the directory area, the file list area and the file type area as well. I try to add the KeyListener but how can I get hold of the component of the three areas of file chooser? I tried to add the KeyListener as Accessory, it didn't work either. Some one please help me.

    Try this to let your components react to ActionEvents
    comp.addActionListener(new  WhatIWantToDo());
    // WhatIWantToDo is the inner class.
    // Let it do what you want to be the reaction
    class WhatIWantToDo implements ActionListener {
    public void actionPerformed(ActionEvent event) {
    //  code on what you want to do
    }Or working without an inner class try this
    comp.addActionListener(new ActionListener() {
    // the event handling
    public void actionPerformed(ActionEvent event) {
    // your code for behavior
    // e.g. System.out.println("There is a reaction");
    // or specify a special named component as c1
    Object source = event.getSource();
    if (source == c1) doSomething();
    else if (source == c2) doOtherThings();
    });Hope this is of help for what you want. Else let me know.

  • Customizing JFileChooser (File Size) Need Help

    Can you help me with this. I want to customize my JFileChooser. I'm in a Windows environment so the file view that I see is same with that of the option pane of windows. What I would like to do is make the size that is viewed from the screen from ##KB to specific bytes size. (ex. 34421245). Can someone help me on this. I was able to see some codes on the net but those codes are not straightforward. They override the BasicFileChooserUI. Can someone help me on this. I don't want to override the BasicFileChooserUI instead I want to use the JFileChooser and change the size from ###KB to bytes. Thank you. ^_^

    Hi Rachel,
    My best idea for that is to load the swf files externally, so
    that each page is a different swf. A technique like this would be
    very simple and quick to use, because it only loads what you need
    when you need it.
    For example, you'd set the intro page to load right away, and
    then when you select "At Work" the intro page unloads and is
    replaced by the at work page.
    Another thing you may want to consider is holding the images
    in an xml file, and then using some basic flash/xml intergration to
    load each image as it's called. That way each image isn't stored in
    the flash file causing it to increase in size, and instead is
    actually loaded externally which is must faster.
    There are some great tutorials, if you're intrested, on how
    to do both of these at:
    http://www.kirupa.com/
    Hope I helped some!

  • Help needed with ItemListeners for JCheckboxes

    Hi,
    I have created a menu called "Test" and it contains toplevel menu item "File"
    and File Menu contains subitems "NEw" and "Exit".
    When i click File->NEW it displays a new Frame named f1 which contains 2
    Jradiobuttons(r1 and r2 ) and 6 Jcheckboxes(c1,c2,c3,c4,c5,c6).
    My Question is how can i write itemlisteners for checkboxes such that after compiling the program when i check anyone of the checkboxes c1,c2,c3 or all c1,c2,c3 then RadioButtob r1 should get enabled.
    similarly when i check anyone of the checkboxes c4,c5,c6 or all c4,c5,c6 then RadioButtob r2 should get enabled.
    I am sending the code i have written .
    Kindly help me.
    Thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    // Make a main window with a top-level menu: File
    public class MainWindow extends JFrame {
        public MainWindow() {
            super("Test");
            setSize(500, 500);
            // make a top level File menu
            FileMenu fileMenu = new FileMenu(this);
            // make a menu bar for this frame
            // and add top level menus File and Menu
            JMenuBar mb = new JMenuBar();
            mb.add(fileMenu);
            setJMenuBar(mb);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    exit();
        public void exit() {
            setVisible(false); // hide the Frame
            dispose(); // tell windowing system to free resources
            System.exit(0); // exit
        public static void main(String args[]) {
            w = new MainWindow();
            w.setVisible(true);
        private static MainWindow w ;
        protected JRadioButton r1, r2;
        protected JCheckBox  c1, c2,c3,c4,c5,c6;
        // Encapsulate the look and behavior of the File menu
        class FileMenu extends JMenu implements ActionListener {
            private MainWindow mw;
            private JMenuItem itmPE   = new JMenuItem("NEW");
            private JMenuItem itmExit = new JMenuItem("Exit");
            public FileMenu(MainWindow main) {
                super("File");
                this.mw = main;
                this.itmPE.addActionListener(this);
                this.itmExit.addActionListener(this);
                this.add(this.itmPE);
                this.add(this.itmExit);
            // respond to the Exit menu choice
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == this.itmPE) {
                    Frame f1 = new Frame("ProductMeasurementEvaluationTool");
                    f1.setSize(600,400);
                    f1.setLayout(null);
                    r1 = new JRadioButton("Radiobutton1");
                    r1.setBounds( 50, 70, 104, 24);
                    f1.add(r1);
                    r1.setBackground(Color.white);
                    r2 = new JRadioButton("Radiobutton2");
                    r2.setBounds( 280, 70, 104, 24);
                    f1.add(r2);
                    r2.setBackground(Color.white);
                    c1 = new JCheckBox("Checkbox1");
                    c1.setBounds( 80, 100, 93, 24);
                    f1.add(c1);
                    c1.setBackground(Color.white);
                    c2 = new JCheckBox("Checkbox2");
                    c2.setBounds( 80, 120, 93, 24);
                    f1.add(c2);
                    c2.setBackground(Color.white);
                    c3 = new JCheckBox("Checkbox3");
                    c3.setBounds( 80, 140, 93, 24);
                    f1.add(c3);
                    c3.setBackground(Color.white);
                    c4 = new JCheckBox("Checkbox4");
                    c4.setBounds( 320, 100, 93, 24);
                    f1.add(c4);
                    c4.setBackground(Color.white);
                    c5 = new JCheckBox("Checkbox5");
                    c5.setBounds( 320, 120, 93, 24);
                    f1.add(c5);
                    c5.setBackground(Color.white);
                    c6 = new JCheckBox("Checkbox6");
                    c6.setBounds( 320, 140, 93, 24);
                    f1.add(c6);
                    c6.setBackground(Color.white);
                    f1.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent e) {
                            System.exit(0);
                    f1.setVisible(true);
                }else {
                    mw.exit();
    }

    hi dek delirium,
    Thanks for the fast reply.. i have compiled the code but i got some errors ...
    i am using JCreator as IDE. i am posting the complete code and errors..
    thankyou
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.util.ArrayList;
    import javax.swing.*;
    import javax.swing.JComponent;
    // Make a main window with a top-level menu: File
    public class MainWindow extends JFrame {
        public MainWindow() {
            super("Test");
            setSize(500, 500);
            // make a top level File menu
            FileMenu fileMenu = new FileMenu(this);
            // make a menu bar for this frame
            // and add top level menus File and Menu
            JMenuBar mb = new JMenuBar();
            mb.add(fileMenu);
            setJMenuBar(mb);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    exit();
        public void exit() {
            setVisible(false); // hide the Frame
            dispose(); // tell windowing system to free resources
            System.exit(0); // exit
        public static void main(String args[]) {
            w = new MainWindow();
            w.setVisible(true);
        private static MainWindow w ;
        protected JRadioButton r1, r2;
        protected JCheckBox  c1, c2,c3,c4,c5,c6;
        // Encapsulate the look and behavior of the File menu
        class FileMenu extends JMenu implements ActionListener {
            private MainWindow mw;
            private JMenuItem itmPE   = new JMenuItem("NEW");
            private JMenuItem itmExit = new JMenuItem("Exit");
            public FileMenu(MainWindow main) {
                super("File");
                this.mw = main;
                this.itmPE.addActionListener(this);
                this.itmExit.addActionListener(this);
                this.add(this.itmPE);
                this.add(this.itmExit);
            // respond to the Exit menu choice
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == this.itmPE) {
                    Frame f1 = new Frame("ProductMeasurementEvaluationTool");
                    f1.setSize(600,400);
                    f1.setLayout(null);
                    r1 = new JRadioButton("Radiobutton1");
                    r1.setBounds( 50, 70, 104, 24);
                    f1.add(r1);
                    r1.setBackground(Color.white);
                    r2 = new JRadioButton("Radiobutton2");
                    r2.setBounds( 280, 70, 104, 24);
                    f1.add(r2);
                    r2.setBackground(Color.white);
                    CBGroup l1 = new CBGroup(r1); // Listener that enables r1
                    CBGroup l2 = new CBGroup(r2); // Listener that enables r1
                    c1 = new JCheckBox("Checkbox1");
                    c1.setBounds( 80, 100, 93, 24);
                    f1.add(c1);
                    c1.setBackground(Color.white);
                    c2 = new JCheckBox("Checkbox2");
                    c2.setBounds( 80, 120, 93, 24);
                    f1.add(c2);
                    c2.setBackground(Color.white);
                    c3 = new JCheckBox("Checkbox3");
                    c3.setBounds( 80, 140, 93, 24);
                    l1. add (c1,c2,c3);
                    f1.add(c3);
                    c3.setBackground(Color.white);
                    c4 = new JCheckBox("Checkbox4");
                    c4.setBounds( 320, 100, 93, 24);
                    f1.add(c4);
                    c4.setBackground(Color.white);
                    c5 = new JCheckBox("Checkbox5");
                    c5.setBounds( 320, 120, 93, 24);
                    f1.add(c5);
                    c5.setBackground(Color.white);
                    c6 = new JCheckBox("Checkbox6");
                    c6.setBounds( 320, 140, 93, 24);
                    l2.add (c4,c5,c6);
                    f1.add(c6);
                    c6.setBackground(Color.white);
                    f1.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent e) {
                            System.exit(0);
                    f1.setVisible(true);
                }else {
                    mw.exit();
        public class CBGroup {
            ArrayList<JCheckBox> triggers = new ArrayList<JCheckBox> ();
            JRadioButton controlledItem;
            public CBGroup(JRadioButton anItem) {
                controlledItem = anItem;
            public void add(JCheckBox... someTriggers) {
                for (JCheckBox cb : someTriggers) {
                    cb.addItemListener(new ItemListener() {
                        public void itemStateChanged(ItemEvent ie) {
                            controlItem();
                    triggers.add(cb);
            public boolean isAnyActive() {
                for (JCheckBox cb : triggers)
                    if (cb.isSelected())
                        return true;
                return false;
            private void controlItem() {
                controlledItem.setSelected(isAnyActive());
    }The errors i got are
    Z:\JCRA\MainWindow.java:115: <identifier> expected
    ArrayList<JCheckBox> triggers = new ArrayList<JCheckBox> ();
    ^
    Z:\JCRA\MainWindow.java:122: <identifier> expected
    public void add(JCheckBox... someTriggers) {
    ^
    Z:\JCRA\MainWindow.java:143: <identifier> expected
    ^
    Z:\JCRA\MainWindow.java:145: '}' expected
    ^
    4 errors

  • JFilechooser .....help please

    hi,
    while opening file "OPEN" or "SAVE" dialog using JFilechooser, in those dialog, can we have our desired icon instead of Java Application at left most corner in the dialog??
    any help please????

    setIconImage
    public void setIconImage(Image image)Sets the image to be displayed in the minimized icon for this frame. Not all platforms support the concept of minimizing a window.
    Parameters:
    image - the icon image to be displayed. If this parameter is null then the icon image is set to the default image, which may vary with platform.
    See Also:
    getIconImage()
    That may work...

Maybe you are looking for

  • #NAME shows in export to excel

    When an export to excel is done in a report some colunms display #NAME. These columns have a '-','*' , etc. as the leading character. Is there a way to have the correct data in the excel report? Thanks

  • From Applet to "external world" (continued)

    this question is an extension to a previous thread (http://forum.java.sun.com/thread.jsp?forum=31&thread=431830) URL callScriptURL = new URL("javascript:setGlob(" + param + ")"); seems to generate a MalformedURLException: this is what I got:: java.ne

  • Item selection issue

    I have a 15" Retina Macbook, less than a year old. This issue started quite randomly but has increased in frequency. Without any warning I become unable to make a selection, ie cicking on a link etc. I am able to move the cursor around the screen but

  • Smart Guides without the snapping

    I would want to see them but without the snapping. Ben

  • Incident management and Critical Master data table change management.

    Dears, I need to configure Incident management and Critical Master data table change management on our solman 7.0 server. I want to know how many days should be required for this activity and please share documents. Shivam