java - I want a JLabel to appear after pressing a JButton -


I need help for this code, I'm trying to create a simple cookie clicker type game, I have mostly code, but for some reason, when I try to add jlabal to the frame, it creates an error, I expected that none of you can help me New enough, thanks for the help!

  // variable clicked constant intrate = 0; Private Flow layout layout; Private Container Container; Public Static Zero Main (String [] Args) {// Declaring buttons, panels etc ... Button button = New pocket ("click"); Zpean panel = new zpn (); Panel.add (button); Last Jeffrey Frame = New Jeffram ("button pressed"); Frame.setSize (400, 200); Frame.setVisible (true); Frame.setDefaultCloseOperation (EXIT_ON_CLOSE); Frame.add (panel); // Action Listener Code Button AddActionListener {New Zenith ActionPerfed (Action Event E) {// When the Click Button is clicked on the click ++; System.out.println ("Pressed button" + clicked + "bar!"); }}}    

You can add a JLabel and Then the Update button changes its text.

Note: Call JFrame.setVisible (true) Finally all components are added. / P>

Sample code:

  // Announce button, panel, etc. ... Button Button = new pocket ("click"); last jl label label = new jlab (); button .addActionListener (new excl.) {@ Override public zero action perfender (clicked ++; labels.sextext ("button Pressed "+ clicked +" bar "!)}}}); JPNL panel = new JPNL (); panel.add (button); panel.ed (label); last gefreem frame = new zeframe (pressed" button " Gone "); frame.Set default configuration (EXIT_ON_CLOSE); frame.ed (panel); frame.setVisible (true);   

search more examples and

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -