How do i use jbutton for mutiple frames(2frames)???

im an creating a movie database program and i have a problem with the jButtons on my second frame i dont know how to make them work when clicked on. i managed to make the jButtons work on my first frame but not on the second....
here is that code so far----
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
* real2.java
* Created on December 7, 2007, 9:00 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
* @author J
public class real2 extends JPanel  implements ActionListener{
    private JButton addnew;
    private JButton help;
    private JButton exit;
    private JFrame frame1;
    private JButton save;
    private JButton cancel;
    private JButton save2;
    private JLabel moviename;
    private JTextField moviename2;
    private JLabel director;
    private JTextField director2;
    private JLabel year;
    private JTextField year2;
    private JLabel genre;
    private JTextField genre2;
    private JLabel plot;
    private JTextField plot2;
    private JLabel rating;
    private JTextField rating2;
    /** Creates a new instance of real2 */
    public real2() {
        super(new GridBagLayout());
        //Create the Buttons.
        addnew = new JButton("Add New");
        addnew.addActionListener(this);
        addnew.setMnemonic(KeyEvent.VK_E);
        addnew.setActionCommand("Add New");
        help = new JButton("Help");
        help.addActionListener(this);
        help.setActionCommand("Help");
        exit = new JButton("Exit");
        exit.addActionListener(this);
        exit.setActionCommand("Exit");
       String[] columnNames = {"First Name",
                                "Last Name",
                                "Sport",
                                "# of Years",
                                "Vegetarian"};
        Object[][] data = {
            {"Mary", "Campione",
             "Snowboarding", new Integer(5), new Boolean(false)},
            {"Alison", "Huml",
             "Rowing", new Integer(3), new Boolean(true)},
            {"Kathy", "Walrath",
             "Knitting", new Integer(2), new Boolean(false)},
            {"Sharon", "Zakhour",
             "Speed reading", new Integer(20), new Boolean(true)},
            {"Philip", "Milne",
             "Pool", new Integer(10), new Boolean(false)}
        final JTable table = new JTable(data, columnNames);
        table.setPreferredScrollableViewportSize(new Dimension(600, 100));
        table.setFillsViewportHeight(true);
        //Create the scroll pane and add the table to it.
        JScrollPane scrollPane = new JScrollPane(table);
        //Add the scroll pane to this panel.
        add(scrollPane);
        GridBagConstraints c = new GridBagConstraints();
        c.weightx = 1;
        c.gridx = 0;
        c.gridy = 1;
        add(addnew, c);
        c.gridx = 0;
        c.gridy = 2;
        add(help, c);
        c.gridx = 0;
        c.gridy = 3;
        add(exit, c);
    public static void addComponentsToPane(Container pane){
        pane.setLayout(null);
        //creating the components for the new frame
        JButton save = new JButton("Save");
        JButton save2 = new JButton("Save and add another");
        JButton cancel = new JButton("Cancel");
        JLabel moviename= new JLabel("Movie Name");
        JTextField moviename2 = new JTextField(8);
        JLabel director = new JLabel("Director");
        JTextField director2 = new JTextField(8);
        JLabel genre = new JLabel("Genre");
        JTextField genre2 = new JTextField(8);
        JLabel year = new JLabel("year");
        JTextField year2 = new JTextField(8);
        JLabel plot = new JLabel("Plot");
        JTextField plot2 = new JTextField(8);
        JLabel rating = new JLabel("Rating(of 10)");
        JTextField rating2 = new JTextField(8);
        //adding components to new frame
        pane.add(save);
        pane.add(save2);
        pane.add(cancel);
        pane.add(moviename);
        pane.add(moviename2);
        pane.add(director);
        pane.add(director2);
        pane.add(genre);
        pane.add(genre2);
        pane.add(year);
        pane.add(year2);
        pane.add(plot);
        pane.add(plot2);
        pane.add(rating);
        pane.add(rating2);
        //setting positions of components for new frame
            Insets insets = pane.getInsets();
            Dimension size = save.getPreferredSize();
            save.setBounds(100 , 50 ,
                     size.width, size.height);
             size = save2.getPreferredSize();
            save2.setBounds(200 , 50 ,
                     size.width, size.height);
             size = cancel.getPreferredSize();
            cancel.setBounds(400 , 50 ,
                     size.width, size.height);
             size = moviename.getPreferredSize();
            moviename.setBounds(100 , 100 ,
                     size.width, size.height);
            size = moviename2.getPreferredSize();
            moviename2.setBounds(200 , 100 ,
                     size.width, size.height);
             size = director.getPreferredSize();
            director.setBounds(100, 150 ,
                     size.width, size.height);
             size = director2.getPreferredSize();
            director2.setBounds(200 , 150 ,
                     size.width, size.height);
            size = genre.getPreferredSize();
            genre.setBounds(100 , 200 ,
                     size.width, size.height);
             size = genre2.getPreferredSize();
            genre2.setBounds(200 , 200 ,
                     size.width, size.height);
             size = year.getPreferredSize();
            year.setBounds(100 , 250 ,
                     size.width, size.height);
            size = year2.getPreferredSize();
            year2.setBounds(200 , 250 ,
                     size.width, size.height);
             size = plot.getPreferredSize();
            plot.setBounds(100 , 300 ,
                     size.width, size.height);
             size = plot2.getPreferredSize();
            plot2.setBounds(200 , 300 ,
                     size.width, size.height);
            size = rating.getPreferredSize();
            rating.setBounds(100 , 350 ,
                     size.width, size.height);
             size = rating2.getPreferredSize();
            rating2.setBounds(200 , 350 ,
                     size.width, size.height);
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        frame.add(new real2());
        //Display the window.
        frame.setSize(600, 360);
        frame.setVisible(true);
        frame.pack();
    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
    public void actionPerformed(ActionEvent e) {
        if ("Add New".equals(e.getActionCommand())){
           frame1 = new JFrame("add");
           frame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
           addComponentsToPane(frame1.getContentPane());
           frame1.setSize(600, 500);
           frame1.setVisible(true);
            //disableing first frame etc:-
            if (frame1.isShowing()){
            addnew.setEnabled(false);
            help.setEnabled(false);
            exit.setEnabled(true);
            frame1.setVisible(true);
           }else{
            addnew.setEnabled(true);
            help.setEnabled(true);
            exit.setEnabled(true);           
        if ("Exit".equals(e.getActionCommand())){
            System.exit(0);
        if ("Save".equals(e.getActionCommand())){
            // whatever i ask it to do it wont for example---
            help.setEnabled(true);
        if ("Save" == e.getSource()) {
            //i tried this way too but it dint work here either
            help.setEnabled(true);
}so if someone could help me by either telling me what to type or by replacing what iv done wrong that would be great thanks...

(1)Java class name should begin with a capital letter. See: http://java.sun.com/docs/codeconv/
        JButton save = new JButton("Save");
        JButton save2 = new JButton("Save and add another");
        // ... etc. ...(2)Don't redeclare class members in a method as its local variable. Your class members become eternally null, a hellish null.
how to make them work when clicked on(3)Add action listener to them.

Similar Messages

  • Use preloader for individual frames?

    I have followed this video on how to build a preloader and I was able to incorporate it into my own site.  Now, I'm wondering now how to build a preloader for individual frames.  For example, I have a link called "Videos" that, when clicked, jumps to frame 10.  This is where I have all the videos visible in the main content area of my site.  However, I'd like to add a preloader so that as the videos load, visitors can see the progress.  Is there a way I can reuse the preloader.swf file I have already built for individual frames of my main site?
    Here is the code for the preloader.swf file which consists of a single dynamic text field located in the center called preloaderTxt:
    var l:Loader = new Loader();
    l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
    l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
    l.load(new URLRequest("WebsiteTest.swf"));
    function loop(e:ProgressEvent):void
        var perc:Number = e.bytesLoaded / e.bytesTotal;
        preloaderTxt.text = Math.ceil(perc*100).toString() + "%";
    function done(e:Event):void
        removeChildAt(0);
        preloaderTxt = null;
        addChild(l);

    (1)Java class name should begin with a capital letter. See: http://java.sun.com/docs/codeconv/
            JButton save = new JButton("Save");
            JButton save2 = new JButton("Save and add another");
            // ... etc. ...(2)Don't redeclare class members in a method as its local variable. Your class members become eternally null, a hellish null.
    how to make them work when clicked on(3)Add action listener to them.

  • How do i use ibooks for saving my lecture notes / power point slides please?

    Hi, how do I use ibooks for savng / storing my lecture notes on please? (on either a iphone or ipad). Also, can I save powerpoint slides to it too? thanks.

    iBooks can only read two formats -- .epub and pdf.  So you have to convert your lecture notes or powerpoints to one of those.  To do that, check the Save, Export, or Share functions of whatever app you are using to create your notes.

  • I have two users with different music on each itunes and i can only use one library, how do i use both for one iTouch?

    i have two users with different music on each itunes and i can only use one library, how do i use both for one iTouch?

    Chris, I believe this link may have the information you're looking for. Welcome to discussions!
    http://docs.info.apple.com/article.html?artnum=300432

  • How can I use TopLink for querys that have two and more tables?

    I use TopLink today, and I can use one table to query, but how can I use TopLink for querys that have two and more tables?
    Thank you for see and answer this question.

    You can write a custom SQL query and map it to an object as needed. You can also use the Toplink query language "anyOf" or "get" commands to map two tables as long as you map them as one to one (get command) or one to many (anyOf command) in the toplink mapping workbench.
    Zev.
    check out oracle.toplink.expressions.Expression in the 10.1.3 API

  • How can I use OCCI for oracle8.1.6?

    my database is oralce8.1.6 for solaris8.
    I want to develop database application by OCCI .
    But only oracle9i has OCCI.
    How can I do?
    Where can I get OCCI ,and how can I use it for oralce8.1.6?
    thank you very much!!

    OCI is available for all versions of Oracle including Oracle
    7/8/8i etc. However it is not installed by default with these
    versions. I am assuming that the default 9i installation
    includes OCI. You should be able to install OCI for other
    versions through one of the development platforms e.g. ProC/C++
    etc.

  • How can i use AME for the new OAF page.

    Dear all,
    I have developed a new OAF page and registered under Employee Self Service.
    How can i use AME for the approval process.
    Appreciate your ideas?
    zamora

    I will try to answer based on my experience of working with iProcurement and AME. It depends on how you want to make a call to AME , directly from OAF Page or from Workflow and your requirement. You didn't specify what you want to show the users on OAF Page and your business requirement.
    Before calling AME Engine from the OAF page or workflow, I guess you did already setup AME Transaction Type and it's Approval Groups, Conditions, Action Types and Rules. Do some testing from AME Business Analyst Test Workbench. Please note that, AME provides lot of PL/SQL API's that you have to call from your programs (java or workflow pl/sql)
    Let's look at the workflow and putting an OAF Page as notification.
    As Sameer said, you have kick-off workflow process from PR of CO and with in the workflow function, you make a call to AME Engine API's with the AME Transaction ID. This transactionId belongs to the AME Transsaction Type that you setup. Based on the rules setup, AME Engine generates list of approvers/approver and stores them AME Tables for that transactionId. Then, it sends a notification to the approver.
    In the workflow, where that notification is defined, in the message body you have to put an attribute(&XX_WF_FWK_RN) of type document/send. And this attribute will have the constant JSP:/OA_HTML/OA.jsp?OAFunc=XX_FUNC&paramId=-&DOCUMENT_ID-. This function is SSWA Jsp function that makes a web html call to your OAF Region.
    If your requirement is to just show the list of approvers on the OAF Page, you may have to call AME API diectly passing your AME TrasnactionId with other parameters. Then AME generates list of approvers and stores them in AME tables with each approver status. You can pickup those approvers using VO and show them on OAF Page.
    Hope this gives some idea.

  • How can i use RTFEditorKit for JTextField.

    hi all,
    how can i use RTFEditorKit for JTextField.
    thanks in advance
    daya

    Don't cross post. This is a Swing related question and you have already posted in the Swing forum:
    http://forum.java.sun.com/thread.jspa?threadID=619619&tstart=0

  • How can I use Siri for IPhone?

    How can I use Siri for IPhone?

    Siri only works on the iPhone 4S or iPhone 5. If you have one of those devices, turn it on in Settings > General > Siri.
    If you need more info than that, ask in the Apple forums.

  • How can I use music for ringtones on my iphone 4?

    How can I use music for ringtones on my iphone 4?

    You can take any MP3 file that it 40 seconds or less and change the file extension to M4R. Then drag it into iTunes. It will appear under Ringtones and transfer over next time you sync,

  • How do you use setRectOfInterest for AVCaptureSession

    I'm struggling with how to impliment AVCaptureSession 's setRectOfInterest method.
    To make things simple... there's some sample code in the WWDC sample code (2013) called QRchestra.
    Right now the scanning of barcodes is for the entire preview area... but lets say I want to limit it to half the screen.
    The ReceiveViewController gets the meta data from SessionManager.
    Now in RecieveViewController viewDidLoad I can do :
    self.sessionManager = [[SessionManager alloc] init];
    [self.sessionManager startRunning];
    AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.sessionManager.captureSession];
    CGRect metadataRect = [previewLayer metadataOutputRectOfInterestForRect:CGRectMake(160, 0, 320, 348)];
    That should give me the coordinates translated for the frame of refference of the preview screen.
    According to WWDC I would apply that to the metadata output :
    [metadataOutput setRectOfInterest:metadataRect];
    That sould be it - but the issue I am having is finding that metadataOutput object.
    It exists in SessionManager but must be private or something as it doesn't appear to be exposed to ReceiveView Controller vis self.SessionManager.
    Google has been of no help with setRectOfInterest so I'm coming to you fine people.
    Anyone able to shed some light on this for me?

    Not really my bag, this, but did you look at the class reference for AVMetadataObject? apparently you never create a metadata object directly but get one by using an AVCaptureMetadataOutput object. As best I can grok this on brief (totally underinformed) inspection, you start with a capture session then use the addOutput method to add an appropriate metadata object. The rectOfInterest property is set on that rather than on the session itself.
    If that doesn't help, sorry!

  • How can I use iCloud for storage without duplication problems?

    I recently set up iCloud to use on my Mac and PC.  With the exception of a single data file that I have stored in the cloud (as a working data file) that I use both on my Mac and PC....I want to use the rest of my 20 gigs of space on iCloud for storage/backup purposes only.  However, I have very little experience with iCloud; and it doesn't seem entirely intuitive to use iCloud.
    For example, if I store all of my music and pictures on iCloud, how do I stop Itunes and iphoto from duplicating the results of each music and picture file in those programs?  I ask this question because I have seen iTunes act up way too many times (in other circumstances) when it creates duplicate music files.
    Just to be clear, I want everything to remain on my local hard drive.  I only want to use iCloud for storage/backup only.  So, again, how do I stop iTunes and iPhoto from reading music and photo files once I successfully get them on iCloud?  (I am thinking I have to hide the archived files once I get them in iCloud, but unsure about how I go about doing that).  And here's my second question.  To upload my personal music and picture files to iCloud, can I simply drag and drop them into the iCloud drive on my computer and assume they will be successfully uploaded?
    My second question seems kind of basic too.  But, once again, iCloud does not seem entirely intuitive to use for a beginner.  For example, I recently purchased some music from the Itunes store.  And while I have it downloaded on my harddrive (like I wanted it)......I don't see it on the iCloud drive (on my computer)....nor do I see it when I log into icloud.com on the web site.  Thanks for any replies.

    If you have a Mac signed into your account running iPhoto, you might want to check iPhoto>Preferences>iCloud to make sure Automatic Upload isn't checked.  If it is checked, all new photos added to iPhoto are automatically added to your photo stream.

  • How can i use FNDLOAD for XML reports and data defnitions

    I registerd concurrent program and linked xml reports and data defnitions in staging instance, and successfully moved to DEV.. after that stage is refreshed and when i download the details from DEV and uploaded to Stage only concurrent program i can upload...Wheteher we can use FNDLOAD Command for the Data definitions or Data template for the XML Report,used FNDLOAD for the concurrent program, it uploaded only concurrent program details.

    Hi,
    Use XDOLoader.
    Note: 469585.1 - How To Use XDOLoader?
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=469585.1
    Regards,
    Hussein

  • How can I use DW for internal email

    Hi all,
    I am interested in using Dreamweaver to build something like email marketing, for internal corporate notifications. I want to be able to tract how many people are reading the email, and how many people use our site for ordering suplys, etc? I have never done this before, but I heard it can be done.
    I am interested in knowing:
    1. What's the best way to build it ( we are using images, Header, footer, links, etc.)
    2. Can I use CSS
    3. What is the best way to send it through email so people can view it? (we can't use an outside vendor)
    Any and all information would be greatfully appreciated.
    Thank  you,
    HDsuperglide

    First read this:
    http://alt-web.blogspot.com/2010/02/html-emails-and-newsletters.html
    Use an email service like Constant Contact or iContact that gives you stats about your email blasts.
    Put Google Analytics on your web pages to see where traffic comes from and if it's converting to sales.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • How can I use CWGraph3D for Visual C++,How the Variant operate?

    I have a VC++ project that use CWGraph3D to show data.
    How I use it's method Plot3DCurve(VARIANT& xVector,...)
    what's the VARIANT type.
    How do I use the VARIANT type to do this job?

    Thank you for response this question so soon.
    Because I do not have Measurement Studio for VC++,
    I do not have CNiVector data type.
    Now I have CCWSafeArray from Chris Matthews,
    National Instruments.
    I could use it's contructor and AccessData() method
    to create an array like this:
    double xArray[3]={0,1,2};
    double yArray[3]={0,1,2};
    double zArray[3]={7,8,9};
    double wArray[3]={0,0,0};
    CCWSafeArray xSafeArray(xArray,3);
    CCWSafeArray ySafeArray(yArray,3);
    CCWSafeArray zSafeArray(zArray,3);
    CCWSafeArray wSafeArray(wArray,3);
    m_Graph.Plot3DCurve(xSafeArray,ySafeArray,zSafeArray,wSafeArray);
    It works very well.
    But now I would like to use Plot3DSurface() method.
    I write C++ code like this:
    double xArray[3]={0,1,2};
    double yArray[3]={0,1,2};
    dou
    ble zMatrix[3][3]={{1,2,3},{4,5,6}.{7,8,9}};
    double wMatrix[3][3]={0};
    CCWSafeArray xSafeArray(xArray,3);
    CCWSafeArray ySafeArray(yArray,3);
    CCWSafeArray zSafeArray2D(zArray,3,3);//error line
    CCWSafeArray wSafeArray2D(wArray,3,3);//error line
    m_Graph.Plot3DSurface(xSafeArray,ySafeArray,zSafeArray2D,wSafeArray2D);
    It could not work.Complier tell me:
    error C2664: '__thiscall CCWSafeArray::CCWSafeArray(unsigned short,long,long,long)' : cannot convert parameter 1 from 'double [3][3]' to 'unsigned short'
    I don't know what's wrong.

Maybe you are looking for

  • Some info abt SCHEDULE LINES - VBEP; VBBE for OPEN quantites?

    Hi Experts, Pls. clarify me that, Am trying to show up the OPEN or BALANCE or BACK quantities in the report FOR EACH SCHEDULE LINE FOR EACH ITEM/POSNR. So, I need to look/subtract the VBEP-WMENG, VBFA-RFMNG for Delivery i.e. "J" VBTYP_N and the BALAN

  • Has anyone gotten Run_Report_Object to work in R12?

    We're trying to bypass the concurrent manager and launch reports directly from custom forms in order to dynamically validate report parameters. From what I've seen on this forum and elsewhere, the reports server was removed in R12. Does anyone know o

  • Shipping Costing - Invoice for the FWD Agent

    Hello: I am working with PO, Inbound Deliveries and Shippment in order to assign the import costs to all the items related to the shipment. I have a concern. I have created a Shipping Cost Document related to a Shipment, This document has a FWD Agent

  • How to print procedure in an executable program

    Hi Everyone                        I am having one procedure  PR_PRICING_T_1723_2000 using cu02.In this some code is written and i want to print the code lines of this procedure in my executable program output.Can anyone help me in finding where this

  • Call Manager upgrade to 10.x version

    Dear Community members, I need your urgent assistance. My company   purchased from Cisco Gold Partner  the licenses  for upgrade  from our existing CUCM 7.1.5 to the latest  version . My plan  was to make an upgrade in my lab first then  start in pro