Totally lost - can anyone please help?

Hi,
Can anyone please help with the following...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
public class project
    public static void main(String[] args)
     //   Time time = new Time();
     //   System.out.println(time.getTime());
    right r = new right();
    left l = new left();
    JPanel p = new JPanel();       
    JPanel p2 = new JPanel(); 
    JPanel p3 = new JPanel();  
    JFrame aFrame = new JFrame();
    aFrame.setTitle("Swing 3");
    aFrame.setBounds(0, 0, 700, 500);
    Container contentPane = aFrame.getContentPane();
     //  add(new left());
     //       add(new right());
     //p.add(new left());
     //p.add(new right());
     r.textArea.setText("Red");
   p.add(l);
   p.add(r);
   p3.add(p);
   ///p3.add(p2);
   contentPane.add(p3);
   aFrame.setVisible(true);
===================================
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
public class left extends JPanel implements ActionListener
   public JButton redButton,greenButton,blueButton,yellowButton;   
   public left()
      JPanel pp = new JPanel();
      setLayout(new BorderLayout());
      redButton = new JButton("Red");
      redButton.addActionListener(this); // step 4
      greenButton = new JButton("Green");
      greenButton.addActionListener(this);
      blueButton = new JButton("Blue");
      blueButton.addActionListener(this);
      yellowButton = new JButton("Yellow");
      yellowButton.addActionListener(this);
      pp.add(redButton);
      pp.add(greenButton);
      pp.add(blueButton);
      pp.add(yellowButton);
      add(pp,BorderLayout.NORTH);
   public void actionPerformed(ActionEvent e)
       // e.getSource()  // returns name of the button
        if (e.getSource() == redButton){
           // r.setT("red");
                    System.out.println("red button");
        if (e.getSource() == greenButton)
          //r.textArea.setText("green");
                System.out.println("green button");
        if (e.getSource() == blueButton)
          //r.textArea.setText("blue");
                System.out.println("blue button");
        if (e.getSource() == yellowButton)
           // r.textArea.setText("yellow");
                    System.out.println("yellow button");
===================================
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
public class right extends JPanel
   JButton oneButton,twoButton;
   public JTextArea textArea;
   public right()
       JPanel jp = new JPanel();
       setLayout(new BorderLayout());
       oneButton = new JButton("one");
       twoButton = new JButton("two");
       textArea = new JTextArea();
       jp.add(oneButton);
       jp.add(twoButton);
       add(jp,BorderLayout.SOUTH);
       add(textArea,BorderLayout.NORTH);
}In the left class I want to be able to click a button and then display a message in the JTextArea. I want main to be global - so the r object can be accessed anywhere.
If anyone could get this to work I'd be really grateful.

import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ProjectRx
    public static void main(String[] args)
        // For the buttons in left to set text in the textArea
        // in right the two classes must communicate in some way.
        // Left must have a way to talk to right.
        // Option 1:
        //     Pass a reference to right to left which left can use
        //     to access the textArea in right.
        ProjectRightRx r = new ProjectRightRx();
        r.textArea.setText("Red");
        ProjectLeftRx l = new ProjectLeftRx(r);
        // Option 2:
        //     You could send a reference to the textArea to left
        //     instead of the reference to its enclosing class.
        //r.textArea.setText("Red");
        //ProjectLeftRx l = new ProjectLeftRx(r.textArea);
        JFrame aFrame = new JFrame();
        aFrame.setTitle("Swing 3");
        aFrame.setSize(400, 400);
        aFrame.setLocation(100,100);
        Container contentPane = aFrame.getContentPane();
        contentPane.add(r, "First");
        contentPane.add(l, "Last");
        aFrame.setVisible(true);
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ProjectLeftRx extends JPanel implements ActionListener
    ProjectRightRx r;
    public JButton redButton,greenButton,blueButton,yellowButton;   
    public ProjectLeftRx(ProjectRightRx r)
        this.r = r;
        JPanel pp = new JPanel();
        pp.setBorder(BorderFactory.createTitledBorder("Left"));
        setLayout(new BorderLayout());
        redButton = new JButton("Red");
        redButton.addActionListener(this); // step 4
        greenButton = new JButton("Green");
        greenButton.addActionListener(this);
        blueButton = new JButton("Blue");
        blueButton.addActionListener(this);
        yellowButton = new JButton("Yellow");
        yellowButton.addActionListener(this);
        pp.add(redButton);
        pp.add(greenButton);
        pp.add(blueButton);
        pp.add(yellowButton);
        add(pp,BorderLayout.NORTH);
    public void actionPerformed(ActionEvent e)
        // e.getSource()   returns object that generated this event
        // To get the name of the button you can try:
        JButton button = (JButton)e.getSource();
        String name = button.getActionCommand();  // or,
                      // button.getText();
        String ac = e.getActionCommand();
        System.out.println("name = " + name + "  ac = " + ac);
        if (e.getSource() == redButton){
//            r.setT("red");
            System.out.println("red button");
        if (e.getSource() == greenButton)
            r.textArea.setText("green");
            System.out.println("green button");
        if (e.getSource() == blueButton)
            r.textArea.setText("blue");
            System.out.println("blue button");
        if (e.getSource() == yellowButton)
            r.textArea.setText("yellow");
            System.out.println("yellow button");
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ProjectRightRx extends JPanel
   JButton oneButton,twoButton;
   public JTextArea textArea;
   public ProjectRightRx()
       JPanel jp = new JPanel();
       setLayout(new BorderLayout());
       oneButton = new JButton("one");
       twoButton = new JButton("two");
       textArea = new JTextArea(10,25);
       jp.add(oneButton);
       jp.add(twoButton);
       add(new JLabel("Right", JLabel.CENTER), BorderLayout.NORTH);
       add(jp,BorderLayout.SOUTH);
       add(textArea,BorderLayout.CENTER);
}

Similar Messages

  • Hi can anyone please help me! My I phone is in recovery mode i lost it and it was returned to me fully working. I ran an update and it shut down. I have loads of pics and vids of my little girls including my youngest counting to ten for the first time.

    Hi can anyone please help. My I Phone is in recovery mode. I have loads of pics and vids including my little girl counting to ten for the first time.
    Can I recover these files or have I lost them? I lost the phone last week and it was returned working but with an update to install I did this and it shut down.
    If anyone can please help I would be eternally in your debt I have loads of sentimental pctures in here but cant get to them.

    Sorry, but if it's in recovery mode, anything on the phone is already gone. If you had PhotoStream turned on, hopefully the photos will still be out there.
    You have no choice at this point but to restore from your last backup.

  • I change my apple ID and password like a week now and after changing all my information and MY apple ID, i noticed that i lost all my picture in my camer roll and my photo stream too ;(.. Can anyone please help me how to bring it back all my photos?

    I change my apple ID and password like a week now and after changing all my information and MY apple ID, i noticed that i lost all my picture in my camer roll and my photo stream too ;(.. Can anyone please help me how to bring it back all my photos?

    I don't know about your camera roll, but for photostream just do this:
    Go into Settings > iCloud > Delete Account and then sign back in using your Apple ID information.
    Make sure to do the same thing with your iTunes and App Store options.
    Settings > iTunes and App Store > Click Email and sign out, then sign back in.

  • Apple TV won't load up. the light flashes and the logo appears on the TV then it just goes off and starts again. I've tried restoring via USB on 5 different computers and I keep getting error message 9? Can anyone please help?

    I have a black Apple TV that has recently stopped working. It loads the Apple Logo on screen then goes off and starts again. It's as if it is stuck in a loop. I've tried a re-boot and this has failed. I have tried a restore using a USB cable on 5 different computers, including a Mac Book Pro and it downloads the update file but when it tries to restore I get the error code 9 showing on screen. I just can't get it to do anything.
    Can anyone please help?

    Thanks for that information!
    I'm sure I will be calling AppleCare, but the problem is, they charge for the phone calls don't they? Because I don't have money to be spending to be on the phone with a support service.
    In other things, it seemed like the only time my MacBook was working was when I had Snow Leopard without the 10.6.8 update download that was supposed to be done to prepare for OS X Lion.
    When I look at the information of my HD it says that I have 10.6.8 but that was the install that it claimed to have failed and caused me to restart resulting in all of the repeated problems.
    Also, because my computer is currently down, and I've lost all files how would that effect the use of my iPhone? Because if it doesn't get fixed by the time OS 5 is released, how would I be able to upgrade?!

  • I have accidentally deleted an sms that I require from my iphone 4s. Can anyone please help me to get this back?

    I have accidentally deleted an sms that I require from my iphone 4s. Can anyone please help me to recover this?

    If it wasn't present the last time you backed up your phone, then you've lost it forever.  There's no "trash" on the iPhone that you can "undelete"

  • HT201401 Q) Can anyone please help me with this: My in coming call ringing tone not working?

    Q) Can anyone please help me with this: My in coming call-messges ringing tone not working? All I am getting in Vabration + Flashing light when receiveing messages or incoming Calls. I am missing my phone Calls constantly. Please Help me?
    I have just received this phone as a replacement from my insurance company, as I had lost my own phone. It has taken them 3 weeks to sort this out. This has ruined my business because it has taken so long. I really do not have time to send it back to them. Because it will waist another three weeks for them to sort it out again. Please Help!

    HA! By Jove I've Got it! it was simples..
    TURN ON THE RINGING ON / OFF BUTTON ON THE SIDE OF YOUR PHONE JUST ABOVE THE VOLUME BUTTONS. THEN MAKE SURE THE VOLUME IS UP TO THE HIGHEST. NOW JUST TRY THIS!
    I ALSO LOOKED UP A MANUAL ON IPHONE4:
    Ringtones, Ring/Silent switch, and vibrate
    iPhone comes with ringtones that sound for incoming calls, Clock alarms, and the Clock timer.
    You can also purchase ringtones from songs in iTunes. See Chapter 22, iTunes Store, on page 94.
    Set the default ringtone: Go to Settings > Sounds > Ringtone.
    Turn the ringer on or off: Flip the switch on the side of iPhone.
    Important:  Clock alarms still sound even if you set the Ring/Silent switch to silent.
    Turn vibrate on or off: Go to Settings > Sounds.
    Assign a different ringtone for a contact: In Contacts, choose a contact, tap edit, then tap
    Ringtone and choose a ringtone.
    For more information, see Sounds on page 139.
    THE REASON MY PHONE HAD NO RING TONE, WAS SIMPLY BECAUSE THE VOLUME WAS TURNED DOWN. :-/
    I HOPE THIS HELPS OTHERS INFUTURE!   :-D

  • What do i do ? My i phone 4 has no option to reduce the motion picture. It is causing me a serious problem. Can anyone please help ?

    After several attempts to get some help from Apple, it has become clear to me that my i phone 4 has no options within accessibility to reduce the motion picture.
    I have a serious problem with the new software but unfortunatly i cannot go backwards with this update. Apple for obvious reasons will not advise any downgrading options. Can anyone please help me? Is there a third party option here. I do not want to pay for a new phone or replace the i phone as i run a mac,desktop and i pad... !! Thank you.

    Giansh2006 wrote:
    I don't quite understand why you have asked me about why I'm keeping my URL secret?
    It's only that I'm not clear why you are reluctant to post it. If you have a podcast in the iTunes Store then it's there for the world to see - they might search on its subject or title, for example, even if they don't actually know about it from you. If you look at other posts in this forum you will see that usually people post their URLs and then I can examine the feed and hopefully find out from that what the problem is. Without this information no-one can give you anything more than wild guesses.
    If you are still reluctant to post the details and want to have a bash at diagnosing the problem yourself you may find my web pages helpful:
    How do I make a podcast?
    how to diagnose a podcast feed
    Why don't my podcast episodes show the podcast image?

  • HT201263 When my ipod touch is in recovery mode, when i try to restore it, the itunes page says the website has timed out so it won't recover. Can anyone please help me?

    When my ipod touch is in recovery mode (when I try to re-store it) the itunes page sayes the website has been timed out and so it won't re-store. There is a limited time, whilst restoring the ipod, it lasts for approx 5 mins, then asks to start again all over again. Can anyone please help me?

    This device is not eligible for the requested build (Also sometimes displayed as an "error 3194")
    Update to the latest version of iTunes. Mac OS X 10.5.8 (Leopard) users may need to download iTunes 10.6.3.
    Third-party security software or router security settings can also cause this issue. To resolve this, followTroubleshooting security software issues.
    Downgrading to a previous version of iOS is not supported. If you have installed software to performunauthorized modifications to your iOS device, that software may have redirected connections to the update server (gs.apple.com) within the Hosts file. Uninstall the unauthorized modification software from the computer.
    Edit out the "gs.apple.com" redirect from your hosts file, and then restart the computer for the host file changes to take affect. For steps to edit the Hosts file and allow iTunes to communicate with the update server, see iTunes: Troubleshooting iTunes Store on your computer, iPhone, iPad, or iPod—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > The hosts file may also be blocking the iTunes Store. If you do not uninstall the unauthorized modification software prior to editing the hosts file, that software may automatically modify the hosts file again on restart.
    Avoid using an older or modified .ipsw file. Try moving the current .ipsw file (see Advanced Steps > Rename, move, or delete the iOS software file (.ipsw) below for file locations), or try restoring in a new user to ensure that iTunes downloads a new .ipsw.

  • Hi there, can anyone please help? Download itunes and it says The Itunes library .itl file is locked, or on a locked disk or you do not have write permission for this file.

    Hi there, can anyone please help? Download itunes and it says The Itunes library .itl file is locked, or on a locked disk or you do not have write permission for this file.

    Holding down the shift key while iTunes is opening. That will bring up the 'choose iTunes library' dialog. Select 'Choose LIbrary' from the choices and navigate to your music folder and iTunes music folder.
    Or refer to this article:
    iTunes for Windows XP: "Disk is locked" or "iTunes folder cannot be found" when installing or opening iTunes
    http://support.apple.com/kb/HT1866

  • I have just updated my iphone 4 to the new ios 6.1, now I can not sync my music to my phone via my iTunes. Before I done the update I was able to put the songs on my phone via iTunes, can anyone please help as i really need to put the songs on my phone.

    Hi everyone, I need some help big time. I was currently running the IOS 6.0.1 on my iphone 4 and I could sync and transfer music to my phone via my iTunes account. But I updated my phone to the new IOS 6.1 and now I can not transfer music onto my iphone, all it does is tries to sync the songs but it doesn't. I have uninstalled and reinstalled iTunes back onto my laptop yet it still does not work. Can anyone please help me.

    Everything is Sorted!
    The release of iTunes 11.0.2 and iOS 6.1.2 for my iPhone 4, seems to have sorted everything. I can now sync music, films and photos between my MacBook and my phone.
    I was dubious about blindly doing the updates but decided they couldn't really mess up any further functionality so I went for it and it's sorted now.
    Look in to, and take the gamble, it's up to you.

  • Cd/dvd drive will not receive a disc, can anyone please help?

    cd/dvd drive will not receive a disc, can anyone please help?

     
    Apple Portables: Troubleshooting the slot load optical disc drive  
    Cures for an uncooperative CD/DVD drive

  • My Macbook aliminium unibody from late 2008 will not boot. I reach the grey screen with the apple icon and the spinning grey gear. I used disk utility to boot it but it said integrity test failed. I don't know what to do can anyone please help?

    My Macbook aliminium unibody from late 2008 will not boot. I reach the grey screen with the apple icon and the spinning grey gear. I used disk utility to boot it but it said integrity test failed. I don't know what to do can anyone please help?

    Sounds like you may have a harddrive issue.  You are probably going to need to get that changed out and then install the OS X again to get it going.

  • HT2953 i-tunes could not be used because the original file could not be found.could not locate.this error occurs on most of my songs in my library and will not play even though they are in my i-pod and play with no trouble.can  anyone please help?

    i-tunes could not be used because the original file could not be found.could not locate.this error occurs on most of my songs in my library and will not play even though they are in my i-pod and play with no trouble.can  anyone please help?

    I was not complete clear.
    Since you never changed the settings in the advanced section of iTunes preferecnes, you have to chech that your music is really in the location setted in the folders reported in the advanced section.  If not you have 2 ways: reset the position of this folders or in the actual disk organisation or in the pointing on the preferences.
    If you press the reset button you just give to itunes its default setting as for the position of the music files: probably this will be a good choice if you have never changed any default preference.
    But before I would check the folders and see if the songs are really there
    In my iTune I have this, and I believe it is the default.
    Users/YOURHOMEFOLDERNAME/Music/iTunes/iTunes Music

  • I have a MacBook running 10.5.8 Mac OSX, Im able to use Safari but I cannot get into itunes. I cannot update itunes, it tells me to check my internet connections. Can anyone please help me?

    When I try to connect to itunes the message say's error 11333. When i try to update itunes the computer say's it cannot connect and further tells me to check my connections. Once again I am able to use safari to get onto the internet fine. I went on trouble shooting at apple.com, but the thing's it told me to try failed. Can anyone please help?

    Hey, Buzz.
    You can download the latest version of iTunes supported on Leopard here:
    http://support.apple.com/kb/DL1575
    I hope that helps.

  • I upgraded to mountain lion a week ago and now on startup of my macbook pro, microsoft excel and word start up automatically and then crash? very strange can anyone please help? I have checked the login items under users and groups and there is nothing.

    I upgraded to mountain lion a week ago and now on startup of my macbook pro, microsoft excel and word start up automatically and then crash? very strange can anyone please help? I have checked the login items under users and groups and there is nothing.

    Are you using the Office for Mac 2011 version, as you need to do?  The Office for Mac 2004 is Not at all compatible with Mountain Lion, and the 2008 version has been noted to have some problems running with ML.
    Hope this helps

Maybe you are looking for

  • Problems between a Wireless Controller and a Switch.

    I have a Wireless Controller 4402 connected to one sw2960G. I configured the controller with LAG and the switch (sw2960G) with etherchanel. I connected the controller 2 distribution ports to the 2 ports of the switch (configured with etherchanel). It

  • Create buld user and modify attributes

    Hi  I just started with powershell and really could need some help regarding creating bulk users accounts. I need to create new users with the follwing attributes filled in. GidNumer                         65050 loginShell /bin/sh mssFU30name blblbl

  • Error while doing delivery of STO

    Hi All,          i am creating delivery of STO (Intra company) using T-code Vl10B. I am getting given below Error messages. 1. Shipping is not allowed for SO "ABCD" & DC "XY" from Plant "ABCD". 2. 00010  delievry from Plant "ABCD" for Material "ABC"

  • Older messages not found

    I have emails that I have received in February and March that I am unable to find in my email account. I have checked the settings and they say to keep everything-not delete. It seems as if anything over a month old is not visible in my Inbox. Also,

  • Can I use older actions in the CS6 Beta? Haven't tried yet--but want to

    I am loving CS6 Beta, and I hope to be able to load my favorite older actions without hassle. Any advice?