• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

simple program but not able to get the required output

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i wrote a simple code that changes the color of the frame when the button is clicked ,the thing is when i run the program i am getting the output of the previous program (a frame that just displays a button) which i wrote .I am using eclipse indigo .Eclipse says there is an error in the project but where the error is it is not showing.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think your code must be something like that:
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vamsi naki wrote:when the button is clicked



How you are getting Button in frame without adding it to container ?
 
Marshal
Posts: 76060
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse should always show you where the error is, with a little red icon with a cross in. Hover your mouse over that and you get more details. What it cannot tell you is whether you are using object‑oriented design or not, and that isn’t even close! In my opinion addActionListener(this) is an abomination against object‑oriented programming, and all the people who write books using it ought to be strung up and beaten with several megabytes of C code

Start here. You will want some sort of class. How about this?There are obviously bits you will have to fill in for yourself. Search for my posts on this forum with “ColourListener” as a keyword, and you will find more. But I don’t think you will find a complete class.
 
Campbell Ritchie
Marshal
Posts: 76060
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Shtilmark Pollo.

If you are using the action command without setting it, won’t you suffer a null pointer exception?
 
Shtilmark Pollo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch Shtilmark Pollo.


Gracias:)

Campbell Ritchie wrote:
If you are using the action command without setting it, won’t you suffer a null pointer exception?


I dont think so. If action command not set then getActionCommand return button text.
From javax.swing.AbstractButton
 
vamsi naki
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hitesh P Patel wrote:

vamsi naki wrote:when the button is clicked



How you are getting Button in frame without adding it to container ?




i should have checked i forgot to add the buttons to the container


Thanks Campbell Ritchie ,Shtilmark Pollo and Hitesh P Patel .I have to go through a lot of topics in GUI i guess,cause i dont know anything about ColourListener.I will refer to your posts Campbell Ritchie.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic