954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

NetBeans Help

Hey guys!
This is the code for a program I started today:

/*
 * IdeaCaptureMain.java
 *
 * Created on Jan 25, 2011, 4:33:45 PM
 */

package Idea;
/**
 *
 * @author WolfShield
 */
public class IdeaCaptureMain extends javax.swing.JFrame {

    /** Creates new form IdeaCaptureMain */
    public IdeaCaptureMain() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        ProgressBar = new javax.swing.JProgressBar();
        progressBarSeparator = new javax.swing.JSeparator();
        MenuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        newSubMenu = new javax.swing.JMenu();
        newProjectMenuItem = new javax.swing.JMenuItem();
        newPictureMenuItem = new javax.swing.JMenuItem();
        newNoteMenuItem = new javax.swing.JMenuItem();
        openSubMenu = new javax.swing.JMenu();
        openProjectMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Idea Capture");

        fileMenu.setText("File");

        newSubMenu.setText("New...");

        newProjectMenuItem.setText("Project");
        newSubMenu.add(newProjectMenuItem);

        newPictureMenuItem.setText("Picture");
        newSubMenu.add(newPictureMenuItem);

        newNoteMenuItem.setText("Note");
        newSubMenu.add(newNoteMenuItem);

        fileMenu.add(newSubMenu);

        openSubMenu.setText("Open...");

        openProjectMenuItem.setText("Project");
        openSubMenu.add(openProjectMenuItem);

        fileMenu.add(openSubMenu);

        MenuBar.add(fileMenu);

        editMenu.setText("Edit");
        MenuBar.add(editMenu);

        setJMenuBar(MenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(progressBarSeparator, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(238, Short.MAX_VALUE)
                .addComponent(progressBarSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new IdeaCaptureMain().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JMenuBar MenuBar;
    private javax.swing.JProgressBar ProgressBar;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenuItem newNoteMenuItem;
    private javax.swing.JMenuItem newPictureMenuItem;
    private javax.swing.JMenuItem newProjectMenuItem;
    private javax.swing.JMenu newSubMenu;
    private javax.swing.JMenuItem openProjectMenuItem;
    private javax.swing.JMenu openSubMenu;
    private javax.swing.JSeparator progressBarSeparator;
    // End of variables declaration

}


What I would like to do is when the user clicks File->Open...->Project the 'File Chooser' window opens up. How would I do this in the IDE of NetBeans? The part where you drag and drop to create windows.

Thanks all!
-WolfShield

WolfShield
Posting Whiz in Training
236 posts since Oct 2010
Reputation Points: 28
Solved Threads: 4
 

Rt Click the Project Option in Design and select Event > Action > actionPerformed now enter the below code for actionPerformed.

JFileChooser fileChooser = new JFileChooser(".");
fileChooser.setMultiSelectionEnabled(true);
fileChooser.setMultiSelectionEnabled(true);
int status = fileChooser.showDialog(this, "Import");
if (status == JFileChooser.APPROVE_OPTION) {
     JOptionPane.showMessageDialog(this, "Done");
}
vealparry
Light Poster
27 posts since Jan 2011
Reputation Points: 10
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: