Label update and numbers displaying, not only string

Hi all
i'v three classes, one which creates random information "generator" and another class which displays the information.
so my question is now, how can i update the information in the display class instantly? and why can i only show strings "text" an no numbers? for example i need to display numbers too for temperature purpose.
attached are the files.
the generator class:
public class Generator extends Thread {
     public long delay;
     public boolean stopped;
     Generator() {
          delay = 2000;
          stopped = false;
     public void run() {
          while (!stopped) {
               try {
                    Thread.sleep(delay);
                    MeteoDaten meteodaten1 = new MeteoDaten();
                    // Stadt Generator
                    int stadt = (int) (Math.random() * 5) + 1;
                         if (stadt == 1) {
                              meteodaten1.getOrt();
                              meteodaten1.setOrt("Zurich");
                         if (stadt == 2) {
                              meteodaten1.getOrt();
                              meteodaten1.setOrt("Basel");
                         if (stadt == 3) {
                              meteodaten1.getOrt();
                              meteodaten1.setOrt("Bern");
                         if (stadt == 4) {
                              meteodaten1.getOrt();
                              meteodaten1.setOrt("Lausanne");
                         if (stadt == 5) {
                              meteodaten1.getOrt();
                              meteodaten1.setOrt("Genf");
                         // Temperatur Generator
                         int temp = (int) (Math.random() * 35 - Math.random() * 20) + 1;
                         meteodaten1.getTemp();
                         meteodaten1.setTemp(temp);
                         // Beschreib Generator
                         int beschreib = (int) (Math.random() * 5) + 1;
                         if (beschreib == 1) {
                              meteodaten1.getBeschreib();
                              meteodaten1.setBeschreib("Bewoelkt");
                         if (beschreib == 2) {
                              meteodaten1.getBeschreib();
                              meteodaten1.setBeschreib("Sonnig");
                         if (beschreib == 3) {
                              meteodaten1.getBeschreib();
                              meteodaten1.setBeschreib("Gewitter");
                         if (beschreib == 4) {
                              meteodaten1.getBeschreib();
                              meteodaten1.setBeschreib("Stuermisch");
                         if (beschreib == 5) {
                              meteodaten1.getBeschreib();
                              meteodaten1.setBeschreib("Bedeckt");
               } catch (InterruptedException e) {
}the other class:
class MeteoDaten {
     // Initialisierung
     public String ort, beschreib;
     public int temp;
     // Getters Setters
     public String getBeschreib() {
          return beschreib;
     public void setBeschreib(String beschreib) {
          this.beschreib = beschreib;
     public String getOrt() {
          return ort;
     public void setOrt(String ort) {
          this.ort = ort;
     public int getTemp() {
          return temp;
     public void setTemp(int temp) {
          this.temp = temp;
}and finally the label class:
import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
public class LabelFrame extends Frame {
     private static final long serialVersionUID = 1L;
     public LabelFrame() {
          setTitle("MeteoDaten");
          setBackground(Color.white);
          addWindowListener(new TestWindowListener());
          MeteoDaten meteoDaten = new MeteoDaten();
          setLayout(new GridLayout(6, 2)); // GridLayout setzen
          // Initialisierung Buttons
          Button button1, button2;
          button1 = new Button("Get Data");
          button1.addActionListener(new Test1ActionListener());
          button2 = new Button("Stop");
          button2.addActionListener(new Test2ActionListener());
          // Initialisierung Labels
          Label labelOrtlinks, labelTemplinks, labelTemprechts, labelBeschreiblinks, labelBeschreibrechts, labelVisuell;
          // Initialisierung Font
          Font bigFont = new Font("Verdana", Font.BOLD, 14);
          // Label Text Setzung
          labelOrtlinks = new Label("Ort: ");
          labelOrtlinks.setFont(bigFont);
          labelTemplinks = new Label("Temperatur:");
          labelTemplinks.setFont(bigFont);
          labelTemprechts = new Label(meteoDaten.getTemp());
          labelTemprechts.setFont(bigFont);
          labelBeschreiblinks = new Label("Beschreib: ");
          labelBeschreiblinks.setFont(bigFont);
          labelBeschreibrechts = new Label(meteoDaten.getBeschreib());
          labelBeschreibrechts.setFont(bigFont);
          labelVisuell = new Label("Visuell:");
          labelVisuell.setFont(bigFont);
          // Add First Label
          add(labelOrtlinks);
          // Ort Auswahl
          Choice choice = new Choice();
          choice.add("Zurich");
          choice.add("Basel");
          choice.add("Bern");
          choice.add("Lausanne");
          choice.add("Genf");
          add(choice);
          // Add Labels
          add(labelTemplinks);
          add(labelTemprechts);
          add(labelBeschreiblinks);
          add(labelBeschreibrechts);
          add(labelVisuell);
          // Bild
          JLabel labelpic = new JLabel(new ImageIcon("thunders.png"));
          add(labelpic);
          // Abstand
          add(new Label(""));
          add(new Label(""));
          // Buttons
          add(button1);
          add(button2);
          pack();
          setVisible(true);
          //Gr��sse vom Fenster
          setSize(300, 250);
          setVisible(true);
     class TestWindowListener extends WindowAdapter {
          public void windowClosing(WindowEvent e) {
               e.getWindow().dispose();
               System.exit(0);
     class Test1ActionListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
               System.out.println("Getting Data...");
               //Generator starten
               Generator gen1 = new Generator();
               gen1.start();
     class Test2ActionListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
               System.out.println("Stop!");
               //Generator stoppen
     public static void main(String args[]) {
          new LabelFrame();
}thank you in advance for your help!

Hello,
you can declare the label as member under the class declaration,then use labelname.setText() , like this :
public class LabelFrame extends Frame {
private JLable labelTemprechts =new JLable();
public void changeLabelValue(int newValue){
this.labelTemprechts.setText(String.valueOf(newValue));
.

Similar Messages

  • HT4972 Why Pages and numbers are not updating.

    My pages and numbers are not updating for about a week now Why?

    Some one else had a similar problem last night...same as yours. He claimed that Pages had been stuck trying to update for about week. I posted this and he said that it worked - which part he did not say - but give these things a try.
    Make sure that you do not have a stalled download in iTunes - a song or podcast .... if you have a download in there that did not finish, complete that one first. Only one thing can download at a time on the iPad so that could be what is causing the problem.
    If that doesn't work - sign out of your account, restart the iPad and then sign in again.
    Settings>Store>Apple ID. Tap your ID and sign out. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Go back to Settings>Store>Sign in and then try to resume the download.
    If you have all of your Pages files backed up in iTunes or on your Mac, this might be the answer. Try deleting the waiting icon - tap and hold down on an icon until it wiggles - the tap the X on the icon to delete it. Then try to download again.
    I have deleted Pages a couple of times when I had issues with it and then reinstalled it. I even deleted a stalled Pages once and then tried the update successfully again after that. My files are always backed up in iTunes and on my Mac so I had no apprehension about deleting the waiting download.

  • Why Pages, keynotes, and Numbers are not free? I bought my mac Oct 14, 2013

    Why Pages, keynotes, and Numbers are not free? I bought my Mac at Oct 14, 2013. With the new OS X Mavericks relaeaed, Apple said that these three Apps are free to new buyers, I bought Macbook Air last week. Why I didn't see these three Apps free after I logged in the Mac App Store?
    Please, Help!

    ***For those that purchased iWork 09 not on the app store but as a retail disk copy you can get the update for iWork even though it may show $19.99 for all the apps:
    You can reupdate to iWork 9.3 by going here http://support.apple.com/kb/DL1563
    then after it is updated close the app store if opened then open it again and sign out then sign in and then all the iwork 2013 apps should show as update rather than $19.99 cost each. This worked for me. I bought iwork '09 on disk but it showed 19.99 each after I upgraded to Mavericks so  followed the above steps and it worked. I am now updating all my iWork suite I bought on disk, NOT on the Mac app store and now I have a Mac app store set!
    Apple sure has a problem that needs to be fixed otherwise iWork will eventually be free for everyone...
    Someone at Apple forgot all of us old retail people before the Mac App store existed!

  • HT2357 I accidently deleted all of my updates and they're not coming back. Is there any quick way to get these updates active again?

    I accidentally deleted all of my updates and they're not coming back. I haven't been able to make any updates since 2006. I have a log of my past updates but I cannot seem to get them active again. Is there any easy way to get these updates active again?
    This was a while ago back in 2006 but from what I can remember I actually deleted/permanently removed these updates from my list of updates. I tried keeping all the updates except for two that I did not need and somehow deleted all of the updates I wanted to keep. I've tried reseting my ignored updates but that does not bring back the updates. If i delete the two that I originally attempted to remove - it only brings those two back. I hope there is still some way to get these updates back. I appreciate any help that anyone is able to give me.
    Thanks!
    Plum<3

    10.4.11 is the latest version of 10.4.
    The security updates for 10.4 are listed here:
    http://support.apple.com/kb/HT5165
    If you are interested in updating to 10.5, see this tip.

  • Older versions of Apple Updater and Bonjour can not be deleted

    I sent back my 1st Gen. Nano on recall. I then tried to sync the new 6th Gen. Nano to my iTunes 9.0. iTunes said I had to upgrade to iTunes 10.... When I tried to upgrade I got a message saying older versions of Apple updater and Bonjour could not be deleted. Also said something about Apple Software msi.dll not found.
    Going through the online Apple support procedures I was told to delete iTunes, which I did. It is now gone although I think it is in "My Music" but I don't know how to get it back to where it was.
    I called support and talked to a Asian Lady who spoke poor English and talked VERY fast. As I am 76 and hard of hear, which I told her at the begining, it was hard to talk with her. She told me I had no warrantee service available to me. I told her that the replacement Nano had a 90 day warrantee, which it does. I told her I felt if Apple was providing me with a replacement that required software updates to function in iTunes then their software to download the latest iTunes should contain whatever it needs to do so. SHE HUNGUP on me!!!!!!
    Now my question to you folks, how do I retrieve iTunes from the "My Music" location?
    And how do I do/get whatever I need to upgrade iTunes?
    Please speck like you are talking to an idiot as I am pretty dense on this.
    I did follow Apples on line procedures and this is the mess I'm in.
    Many thanks, Bill

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up").
    In the list of programs that appears in CleanUp, select any Apple Software Update entries and click "Remove", as per the following screenshot:
    Next, select any Bonjour entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install using an iTunesSetup.exe (or iTunes64Setup.exe) downloaded from the Apple Website:
    http://www.apple.com/itunes/download/
    Does it go through properly this time?

  • Fire fox did an update, and now will not work at all.

    Firefox did an update, and now will not open, it tells me that it cannot access any site I try

    [[Firewalls]] can block a new version of Firefox. See [[Cannot connect after upgrading Firefox]]

  • HT204135 I update my Mac to version 10.9.2 and now my printer does not work anymore. I did all the software updates and I do not understand why my mac does not recognize the printer anymore?

    I update my Mac to version 10.9.2 and now my printer does not work anymore. I did all the software updates and I do not understand why my mac does not recognize the printer anymore?

    Go to the website of the manufacturer of your printer and check to see if they have released an updated driver for your particular model.

  • HT1420 Just tried to download and install latest Itunes update and it would not load correctly. Keep getting a warning that file MSVCR80.dll is missing. I have reinstalled Itunes but did not correct. I have a PC with Windows XP. Itunes ran great prior to

    Just tried to download and install latest ITunes update and it would not finish update. I aborted the update and then my ITunes will not open. I keep getting and error stating that file MSVCR80.dll not found. I reinstalled my original ITune file but this did not clear this error. Any ideas.

    Click here and follow the instructions. You may need to completely remove and reinstall iTunes and all related components, or run the process multiple times; this won't normally affect its library, but that should be backed up anyway.
    (99732)

  • Why Pages, keynotes, and Numbers are not free?

    Why Pages, keynotes, and Numbers are not free? I bought my Mac at Oct 14, 2013. With the new OS X Mavericks relaeaed, Apple said that these three Apps are free to new buyers, I bought Macbook Air last week. Why I didn't see these three Apps free after I logged in the Mac App Store?
    Please, Help!

    Don't keep reposting this over and over! Or you posts will be deleted.

  • HT201412 my device was updated and now is not working anymore, it is in recovery mode all the time

    my device was updated and now is not working anymore, it is in recovery mode all the time.
    what can i do???

    Delete the shortcut you have at the moment and then create a new one as follows:<br><br>
    #Use Windows Explorer to navigate to C:\Program Files\Mozilla Firefox.<br><br>
    #Right click '''firefox.exe''' and choose '''Send To''', then '''Desktop (Create shortcut)'''<br>
    Bear in mind that you're using an BETA version of Firefox and you're likely to encounter similar issues in the future.

  • Pages and Numbers will not open my iCloud files until I restart my Imac.

    Pages and Numbers will not open my iCloud files until I restart my Imac.

    Welcome to the Apple Community Lloyd.
    Please tell us the versions of everything you are using.

  • HT4623 My iPad does not have the automatic software update and I do not know how to download IOS if under settings there is no software update button available. Do I have to reset my iPad and lose data?

    My iPad does not have the automatic software update and I do not know how to get IOS 6 onto it. When I go into settings there is no software update button.

    If you are really on iOS 5 then look in Settings > General > Software update.
    Otherwise:
    If you are using iOS 4 (or earlier) there is no Software Update in Settings. That feature was first added in iOS 5.
    To update you will have to connect your iPad to iTunes on a computer (preferably the one you sync with and backup to).
    See here: http://support.apple.com/kb/HT4972

  • We updated our phones and now we are running out of memory.  Never happened before the update and we have not added anything new.  We have hardly anything on our phones.

    We updated our phones and now we are running out of memory.  Never happened before the update and we have not added anything new.  We have hardly anything on our phones.  Why am I having to remove stuff that has always been on my phone. 

    Thanks for the reply TJBUSMC1973. 
    I guess that means back to the shop.  Ridiculous to sell a phone that can't handle the new iOS more efficiently (or vice versa).  I can't imagine anyone going near a 5C now (I have a feeling mine had already been used and taken back once and sold as new at O2).
    Charlie

  • Hi, a dvd got stuck in my mac mini and after looking at solutions online and attempting some not only has the dvd not ejected but my mac wont turn on properly, there is simply a white blank screen, can anyone help me please? thanks

    Hi, a dvd got stuck in my mac mini and after looking at solutions online and attempting some not only has the dvd not ejected but my mac wont turn on properly, there is simply a white blank screen, can anyone help me please? thanks

    Hi Claire, sounds dire, but some things to try...
    Have you done a PRAM reset, CMD+Option+p+r...
    http://support.apple.com/kb/HT1379
    In fact, do 3 in a row, takes a bit of time.
    Intel-based Macs: Resetting the System Management Controller (SMC)...
    http://support.apple.com/kb/HT3964

  • Pages and numbers will not take dictation and iOS 8. Very frustrating screen goes blank no keypad. I have to close the document In order to get rid of the big blank space where the keyboard should ber

    Pages and Numbers will not take dictation in iOS 8 on my iPad 4 and iPad mini.
    Very frustrating -screen goes blank where keyboard should be when I touch the microphone- no keypad & dictation does not record. I have to close the document In order to get rid of the big blank space where the keyboard should be. When is this going to be fixed?it's making recordkeeping Pages and Numbers,  which I use heavily, almost impossible.
    also dictation in other locations such as Mail put capitals in the middle of sentences and sometimes don't capitalize first letter in a sentence (see first letter of this sentence!) and other instances like the months of the year or the days of the week. Is anyone else having these problems?

    Pages and Numbers will not take dictation in iOS 8 on my iPad 4 and iPad mini.
    Very frustrating -screen goes blank where keyboard should be when I touch the microphone- no keypad & dictation does not record. I have to close the document In order to get rid of the big blank space where the keyboard should be. When is this going to be fixed?it's making recordkeeping Pages and Numbers,  which I use heavily, almost impossible.
    also dictation in other locations such as Mail put capitals in the middle of sentences and sometimes don't capitalize first letter in a sentence (see first letter of this sentence!) and other instances like the months of the year or the days of the week. Is anyone else having these problems?

Maybe you are looking for

  • Re-Publishing an iWeb site with GoDaddy

    I am having a very frustrating issue when a attempt to re-upload my already made iWeb site onto a domain that I am paying for through GoDaddy. I started the site two years ago with a two year plan for hosting on GoDaddy. Everything was fine for those

  • Unable to add contacts to address book from Mail

    When I mouse over a phone number (or address) in an email message in Mail, an arrow appears that lets me add a new contact with that phone number directly to address book from mail. Unfortunately, when I fill in the information and click "add to addr

  • Extract first name from string

    Post Author: gronkette CA Forum: General If I have the followng list: SCHEELS, Julie CURTIS, Tobi JOHNSON, Dawn    etc.... How do I extract the First name following the comma?  I've been able to extract the Last name several ways. thanks!

  • SSIS - Script Task creates a DTS var and using Foreach loop, Execute SQL needs to INSERT into table from this DTS var.

    I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable. Each row in array represents a row is comma separated and is a row that must be inserted int

  • IWeb Help...page background not loading.

    This may not be a specific iWeb issue, but I'm hoping that someone here has experience with this... I just got a call telling me that a site I created is 'unreadable'. Based on further questioning, it seems like the the background color of the page (