• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Variable button

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I get "variable przycisk of type Object" in line 26, during compiling. Why?
 
Kacper Szmigiel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, bad button
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kacper Szmigiel wrote:
I get "variable przycisk of type Object" in line 26, during compiling. Why?



You get more than that. I'm going to take a guess that it's "undefined symbol." If so, then the error message is telling you exactly what's wrong, namely that you are trying to use a variable named przycisk but there is no such variable defined in that scope.

If that's not the rest of the error message, then please copy/paste the exact, complete message.

Also, note that line 26 of the code you posted is

which is unlikely to be giving that error.
 
Kacper Szmigiel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh yeah, my fault. It's about line 24, and the full text of error is:

error: cannot find symbol
przycisk.setText("Zostałem kliknięty");
symbol: variable przycisk
location: class ProstyGUI1



Also, I've compared example from Head First. Java. and my own code. And there's the diffrence:

In my code:



And in the example:



So does the way I will make JButton przycisk (as a component of class or as variable in method). It's all about the diffrence between local and global?
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic