Jlabel not updating who is idris elba dating now

Visible(true); public main(){ //JLabel // Make the lable final..we can access from witin // the listener...

final JLabel cookies = new JLabel(); Text("Cookies:" num Cookies); //JButton JButton click = new JButton("Click"); Action Listener(new Action Listener()); import

programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums Hi Everyone, i am developing a new Hangman game for school assignment. If user clicks on the Button Try Again , to try one more time, computer randomly picks up another String. public class Hangman3 extends JFrame { private JLabel welcome; private JLabel dash; private String[] str = ; private Random generator; private String guess Word; private JLabel jlabel Dashes; private int i; private JPanel j Panel Alphabet; private String alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; private char[] chr = Char Array(); private char[] chr Guess Word; private JButton [] j Button Alphabet; private Button Handler handler; private Font font; private int x=10; private int y=50; private int width=50; private int height=50; private String populate Dashes = ""; private JButton button Pressed; private JLabel win Loose Message; private int error Count = 0; private boolean flag; private JPanel drawing Panel; private JButton jbutton Try Again; private JLabel jlabel Try Again; public Hangman3() //populate the dashes for( int i=0;i You are not restarting the game you are creating a new Hangman3 object but you aren't displaying it (or closing the original one) so what you can see is the original Hangman3 GUI.

When i try to update the JLabel with the New String. There is a string in my code "private String populate Dashes = "";" populate Dashes String is used to print Dashes in JPanel something like in this (-----). This works fine for first time, however when the User try to play agai, the Label is not getting updated with the new String. BTW this is not the way to handle a play again request.

i set the label to public and i tried to invoke set Text() on it from the other class, but it doesnt change it in the GUI.

A common task it is to update a label to display some new information depending on the state of the application.

The label has its text property bound to a Simple String Property.

The application then spawns a new thread which simply formats the current time and sets the value of the property.

You need to separate your GUI initialisation code (creation of GUI components) from your game code (populating of values) so you can restart the existing Hangman3 game by selecting a new word and calling the game code again.

i've spent about an hour trying to get my label to update from another class.

Leave a Reply