How to fix it , i have the code now, help. please

import java.awt.*;
import javax.swing.*;
public class JPanels extends JPanel {
String s;
  public JPanels()
    setBackground(Color.lightGray);
    JTextField jt = new JTextField(10);
    jt.setText(s);
    add(jt, BorderLayout.EAST);
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;
public class TextChange extends JFrame implements ActionListener
     JButton ok1,ok2;
     JPanel topPanel;
     JPanels newjp;
  public TextChange(JPanels jp)
      setTitle("test here");
      setSize(200,200);
     getContentPane().setLayout(new BorderLayout());
     setBackground( Color.gray );
     JPanel topPanel = new JPanel();
     topPanel.setLayout( new BorderLayout() );
     getContentPane().add( topPanel );
    setBackground(Color.lightGray);
    ok1 = new JButton("1");
    ok2 = new JButton("2");
    newjp = jp;
    ok1.addActionListener(this);
    ok2.addActionListener(this);
    topPanel.add(ok1, BorderLayout.WEST);
    topPanel.add(ok2, BorderLayout.EAST);
    topPanel.add(jp,BorderLayout.SOUTH);
  public  void actionPerformed(ActionEvent e)
     if(e.getSource()==ok1)
          System.out.println("hello");
          newjp.s="hello";
     if(e.getSource()==ok2)
          System.out.println("world");
          newjp.s="world";
  public static void main(String[] args)
     JPanels jp = new JPanels();
     TextChange tc = new TextChange(jp);
     tc.pack();
     tc.setVisible(true);
}when you click ok1 button , will set Text in textfileld "hello", if press ok2
then textfiled is "world", but this is not working ,any ideas????
Thanks

You should also be using.equals not == in your
actionPerformed method to check thee.getSource().
Not necessary. '==' is fine there.Yea I wasn't looking closely enough. A little too
quick on the trigger. Sorry about that.No trouble. ".equals" should work, too. JButton inherits 'equals' from Object, so it will do exactly the same thing.

Similar Messages

  • I want to receive and send data in ASCII how can I do? (Have the code)

    I use my program connect to server (the server is .exe file) after I connect in ms-dos mode I want to send the command from client to server but nothing is happen such as I want to send MOVE 50 it means move 50cm nothing is back(may be because I haven't convert it to ASCII first) How can I change mycode to read and wrtie ASCII code?
    public class proxy_server {
        /** Creates a new instance of proxy_server */
        public static void main(String args[]) throws IOException {
                Socket sock=null;
                PrintWriter out=null;
                BufferedReader in=null;
                sock = new Socket("localhost", 3000);
                out=new PrintWriter(sock.getOutputStream(),true);
                in=new BufferedReader(new InputStreamReader(sock.getInputStream()));
                BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
                String userInput;
                while(( stdIn.readLine()!=null)){
                    userInput=stdIn.readLine();
                    out.println(userInput);
                    System.out.println("echo"+in.readLine());
                out.close();
                in.close();
                stdIn.close();
                sock.close();
    }

    we usually should use a blank-line-check as an exit condition.Certainy not 'usually'. See below.
    I was just talking about a primitive stdin input on
    console.But nobody else was, especially the OP.
    Simple null check on readLine while loop often causes
    confusion among Java newbies becuase they can't exit
    the program.
    If and only if you define your operating instructions so that pressing ENTER is the way to exit the program, you would include the blank line check. Not otherwise, and certainly not 'usually'.
    Otherwise they can always type Ctrl/Z or Ctrl/D to exit the program. And that's the correct way to clear up the confusion. Terminating the loop on a blank line just adds to the confusion

  • Just got an ipad air and while creating my apple ID with credit card, I got to itunes gift card/ itunes gift section and was asked to supply a CODE to proceed with the form but I don't have the code. please how how can i get the code?

    Just got an ipad air and why creating my apple ID with credit card, a CODE was requested in the itunes gift card/ itunes gift in order to preceed with the form but I don't have the code. Please how can I find the code so as to enable me complete the form successfully. Thanks alot

    The iTunes gift card field is optional, you don't have to fill it in - leave it blank if you don't have a gift card.
    iTunes gift cards are country-specific (they can only be used in their country of issue), and they are not available in all countries - so you might not be able to dill it anyway.

  • Why would you allow firefox to update computer web-browsers if you have an idea that it will no longer work after the update? And why would you not include instructions for, how to fix the problem? Help Please! Can I go back to the old one?

    Why would you allow firefox to update computer web-browsers if you have an idea that it will no longer work after the update? And why would you not include instructions for, how to fix the problem? Help Please! Can I go back to the old one?
    Ron Bell
    [email protected]

    Mozilla, like many other software companies, thoroughly test their software before releasing it to the public and I'm sure that no problem you are having is intentional.
    I do not work for Mozilla but I do have experience of releasing software for public usage.
    Firefox has no way of knowing what other software is already on your computer and with millions of combinations it isn't always possible to test for every scenario.
    You can go back to the old version of Firefox but that won't always solve your problem.
    The web site below tells you how:
    https://support.mozilla.com/en-US/kb/Installing%20a%20previous%20version%20of%20Firefox

  • How can i open my external locked macbook pro when i have the code

    how can i open my external locked macbook pro when i have the code
    for fun i have external locked my mac, and now i dont know how to open it again :-(
    do someone know where i can write the code so it will work again?
    thankes

    www.itunes.com type that on your internet browser and download the newest version of itunes.

  • How to fix Adobe App Manager error code -60 Download appears corrupt but only for Photoshop CS6 app

    How to fix Adobe App Manager error code -60 Download appears corrupt but only for Photoshop CS6 Creative Suite Cloud App. Many attempts were made to install Photoshop CS6 with Adobe Application Manager without success. Every other Creative Suite Application was successfully downloaded. I keep getting Installation Failed when attempting the Photoshop install. How does one correct this?

    Thanks Jeff! So, it totally appears as if it was a network issue. The corporate network where I work is quite likely the culprit. Where I was thrown off is that since I have admin rights on my computer, I can install software. But using Adobe Application Manager to install Adobe software wasn't working. And to make matters worse, there didn't appear to be any way to install Acrobat Pro for Mac without using AAM. The workaround that I used previously was to install the trial versions of Adobe software, and then just register them using my username and password. But the workaround for being able to install everything using AAM was to bring my computer home and download from my home network.

  • HT1926 I get a message stating MSVCR80.dll is missing. How to fix? I have removed and re-installed multiple times.

    I get a message stating MSVCR80.dll is missing. How to fix? I have removed and re-installed multiple times.

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (if this won't uninstall move on to the next item)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
    Please note:
    Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
    HT1925: Removing and Reinstalling iTunes for Windows XP
    HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    tt2

  • TS1292 I have a $50 credit in my account. I don't have the code. What do I do?

    I have a credit in my iTunes account. I don't have the code. How do I redeem my credit ?

    Are these movies that were purchased thru iTunes?  If not that is why. The following is from this Apple document: iCloud: Backup and restore overview.
    iCloud automatically backs up the most important data on your device using iOS 5 or later. Once you have enabled Backup on your iPhone, iPad, or iPod touch .....
    What is backed up
    You get unlimited free storage for:
    Purchased music, movies, TV shows, apps, and books
    Notes: Backup of purchased music is not available in all countries. Backups of purchased movies and TV shows are U.S. only. Previous purchases may not be restored if they are no longer in the iTunes Store, App Store, or iBookstore.
    Some previously purchased movies may not be available in iTunes in the Cloud. These movies will indicate that they are not available in iTunes in the Cloud on their product details page in the iTunes Store. Previous purchases may be unavailable if they have been refunded or are no longer available in the iTunes Store, App Store, or iBookstore.
    You get 5 GB of free iCloud storage for:
    Photos and videos in the Camera Roll
    Device settings (for example: Phone Favorites, Wallpaper, and Mail, Contacts, Calendar accounts)
    App data
    Home screen and app organization
    Messages (iMessage, SMS, and MMS)
    Ringtones
    Visual Voicemails
    OT

  • Help! How to fix "Acrobat quit unexpectedly (error code: 0x00000004)"?

    Help! How to fix "Acrobat quit unexpectedly (error code: 0x00000004)"?
    Customer service ask me uninstall - restart PC - CC cleaner tool - restart PC again - reinstall, but still useless.
    Who also facing this problem?

    I already check the permission, but still can't run.

  • How to fix my Nano within the Warrenty period without a receipt

    How can I fix my Nano 6 in China, I bought it at Covent Garden in the UK in Oct of 2010, I got my receipt lost now. One of Apple Supported Repair Center told me today that I need to provide the receipt to get it renewed for free of charge, but I do not have the receipt now, I only could provide my Visa record and a serial  number.
    Thanks

    Call Apple tech support in China.  Ask politely yet firmly to be transferred over to Customer Relations. 
    International Support Phone #s 

  • I recently got my ipod replaced and i have its serial number. now i used to play a game on it which requires me to have its UDID for account transfer so how do i get its UDID when i dont have the ipod now. i have a new one now.

    i recently got my ipod replaced and i have its serial number. now i used to play a game on it which requires me to have its UDID for account transfer so how do i get its UDID when i dont have the ipod now. i have a new one now.

    I would try contacting Apple.
    http://www.apple.com/support/ipodtouch/contact/

  • How to fix this error message The backup disk image "/Volumes/AirPort Disk/FARES DEL VALLE's iMac.sparsebundle" could not be accessed (error -1).

    how to fix this error message The backup disk image “/Volumes/AirPort Disk/FARES DEL VALLE’s iMac.sparsebundle” could not be accessed (error -1).

    The troubleshooting C17 is the specific article.
    http://pondini.org/TM/Troubleshooting.html
    This is generally a Lion error.. and you will need 5.6 utility to get access to the disk area.
    So download the real utility. Run it instead of v6 toy version.
    http://support.apple.com/kb/DL1482
    Go to the manual setup, disk page and click on disconnect all users.. that will unmount all users connected to the disk and allow it to start working. But there are a number of other issues that are possible cause. Pondini lists some of them.

  • My Ipad wont retrieve my new emails and if I try to check passwords in Settings, the settings window only stays open open for a second or two and the automatically closes. Any help on how to fix. I tried the turn off and on trick and that didn'

    My Ipad wont retrieve my new emails and if I try to check passwords in Settings, the settings window only stays open open for a second or two and the automatically closes. Any help on how to fix. I tried the turn off and on trick and that didn't work either. Thanks for any help.

    Try reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • I have a lot of HD video on my hard drive that I eventually want to edit in iMovie, but just don't have the time now.  It is clogging up the computer, though.  How do I take the Hd clips off Mac for later editing?

    I have a lot of HD video on my hard drive that I eventually want to edit in iMovie, but just don't have the time now.  It is clogging up the computer, though.  How do I take the Hd clips off Mac for later editing?

    See "Storage drive" here
    Most commonly used backup methods
    Th problem with HD video is it needs a fast external interface, so you should pick a external drive that uses the fastest interface your computer has to offer.
    Performance rank fastest to slowest is
    Thunderbolt, USB3, (newer Mac's)
    Firewire 800, USB 2, Firewire 400, USB 1 (older Mac's)
    Newer Windows PC's have USB3, older one's USB 2,1.
    You need to format the drive if it comes FAT which a lot do, as FAT has a 4GB file size limit, so this won't work with large HD video files.
    So if your  going to use the drive only with a Mac, then head to Utlities > Disk Utility and format it Options: GUID Format: OS X Extended Journaled. (select the drive makers name and click Partition tab)
    If your going to use the external drive with a PC, take it to the oldest PC you have and right click and format exFAT.
    If you have a Windows XP machine and there is no exFAT, it can be downloaded for free from Microsoft.
    Drives, partitions, formatting w/Mac's + PC's

  • A friend gifted me a copy of The Amazing Spider-man, I redeemed the code, now it tells me I can't download it onto my Ipad (1st Gen) because it does not have a gyroscope. Is there a way for my friend to get his money back, or a way for me to download it?

    A friend gifted me a copy of The Amazing Spider-man, I redeemed the code, now it tells me I can't download it onto my Ipad (1st Gen) because it does not have a gyroscope. Is there a way for my friend to get his money back, or a way for me to download it?
    As a second option I can play on my 1st gen Ipod Touch. Does that have a gyroscope?

    Contact iTunes Store support staff through the report a problem links in your account history or,
    iTunes Customer Service Contact - http://www.apple.com/support/itunes/contact.html > Get iTunes support via Express Lane > iTunes > iTunes Store - Apple states all sales are final, but you can always ask nicely.  Your friend should have checked the specifications of your ipad before making the gift.

Maybe you are looking for

  • Exporting from InDesign to PDF, and the updated PDF is larger than a month ago and not printing easily on letter paper, it is PDF presets?

    Hello, I am exporting from InDesign to a PDF and the page is larger in the PDF then others I have exported. Is this because of the PDF presents? One of the project managers is not able to print it out on 8.5 x 11 paper, but the document presets for I

  • Why does my music not show up for my wife with family share?

    With all new devices (MBP retina using Yosemite/iPhone 6's iOS8.1): I've create my family share list with my wife.  None of my music shows on her phone, iPad, or computer.  Under Family Share on the Apple site, it suggests the ability to share and do

  • Please Help with text parsing problem

    Hello, I have the following text in a file (cut and pasted from VI) 12 15 03 12 15 03 81 5 80053 1 1,2,3 $23.00 1 ^M 12 15 03 12 15 03 81 5 84550 1 1,2,3 $15.00 1 ^M 12 15 03 12 15 03 81 5 84100 1 1,2,3 $15.00 1 ^M 12 15 03 12 15 03 81 5 83615 1 1,2,

  • BPM Not found

    Installed Oracle VMBox - no problem. Then installed SOA & BPM Development VM in the VMBox - no problem. Have run JDev, built simple SOA composite, deployed, tested - no problem. All, to this point works as expected. However, when enter the URL http:/

  • 174 degrees F too hot?

    So...I'm assuming that this is what's causing my computer to shut down. i'm using temperture monitor and it says my CPU board is 174F which is well above the upper limit of 148F. Any ideas on what I can do? My computer has been shutting down randomly