Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

query related to some event handling and gui concepts  RSS feed

 
shweta sahib
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i am new to java and jst was practicing some concepts of gui and event handling and wrote a code but there was error in the code so please anyone can tell me whats d problem in my code-



and in this error comes ta symbol is not found in class BHandler .
please some one do reply .how to fix this???
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch It is a good thing to use the code button, but you got it wrong; you should have the [/code] bit after the code. I have corrected it, but unfortunately your code was not indented; it is really difficult to read. Please copy your post with the button, and go back and correct the indentation. Then you can see where the different parts of the code belong, which class is where, and work out the scope of ta.

By the way: ta is a poor name for a component. Your listener class should be called XYZListener.
 
shweta sahib
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for telling my mistakes in writing style of java code but could you shed some more light on how can i improve my indentation by either through my code or through any example it will be quite helpful....
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try here for formatting suggestions (they are only suggestions not requirements) and here.
 
shweta sahib
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obliged to you for having got such a prompt reply inspite of your busy schedule.

I will better go through the snippets of "As to how to post questions", the next time i bug you!.

posted Today 11:46:46 AM
i am new to java so i have lots of doubts coming up while i am reading and coding some basic programs in java .
my doubt is in the following code
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped



here error comes cannot find symbol x in class BHandler and also 1 more question why do we need to do put static in line numbering from 5 -8 if we dont do so then there is error at various lines that non static variable cannot be referenced from static context .
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not sure whether to write static the answer is no.
And x is no better an identifier.
I was suspicious about the design of that listener class earlier; I am now sure it is very poorly designed. One class per action would be far better.

That indentation is hardly better than it was before. If you had got that code indented correctly, you would see the cause of the compiler error.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!