Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Jbutton and Jspinner

 
Prabhudatta Choudhury
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a problem with JSpinner. I created a panel to add month and year. Here is the code.

It is compiling correctly. But when I tried to view that UI page, its throwing some exception

"Screenutilities can not be cast to Jbutton". Plea

Please suggest what/where to modify..
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Can you post the stack trace? It will show the line number which causes the exception?

PS. I have edited out your post to UseCodeTags
As you can see it makes your post easy to read and understand. In future, while posting code, please UseCodeTags
 
Prabhudatta Choudhury
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Welcome to the Ranch.
Can you post the stack trace? It will show the line number which causes the exception?

PS. I have edited out your post to UseCodeTags
As you can see it makes your post easy to read and understand. In future, while posting code, please UseCodeTags



Hi,

I need your help maneesh. When I try to remove the for pannel that exception goes away. I removed that pannel and got rid of that exception. But one thing I'm not able to understand that why its coming when I add that pannel. And one more thing is there any special way to implement year spinner in swing?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. Since you have opted to not post the stack trace, it is impossible to help you figure out whats going wrong.
 
Rob Camick
Ranch Hand
Posts: 2703
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any special way to implement year spinner in swing?


Have you read the JSpinner API. The API contains a link to the section of the Swing tutorial on "How to Use Spinners" which has a working example.

Start by reading the API and tutorials when you have a question.
 
Prabhudatta Choudhury
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:
is there any special way to implement year spinner in swing?


Have you read the JSpinner API. The API contains a link to the section of the Swing tutorial on "How to Use Spinners" which has a working example.

Start by reading the API and tutorials when you have a question.


Hi Rob,

I checked that API, but that did't help me. My problem with the spinner is an exception type. Its not showing any error. I'm not able to understand why the exception "Screenutilities can't be cast to Jbutton" is coming where I never used Jbutton in this. Is there any default/hidden Jbutton is getting created?
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hoe do you expect us to know, without the stack trace?
 
Prabhudatta Choudhury
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Hoe do you expect us to know, without the stack trace?


Darryl,

Could you please let me know what is this stack trace all about? I will post that too.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like this:
The "at" parts is what we are mostly interested in.
 
Rob Camick
Ranch Hand
Posts: 2703
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the stack trace without a SSCCE doesn't help much, since we won't know what line of code the trace is referring to.

I'm not able to understand why the exception "Screenutilities can't be cast to Jbutton"


Does the tutorial code use ScreenUtilities..? What does that code do?

The real question is "how is your code different from the example code in the tutorial"?

Download the example code and compare the code to see what you are doing differently.
 
Prabhudatta Choudhury
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Actually the stack trace without a SSCCE doesn't help much, since we won't know what line of code the trace is referring to.

I'm not able to understand why the exception "Screenutilities can't be cast to Jbutton"


Does the tutorial code use ScreenUtilities..? What does that code do?

The real question is "how is your code different from the example code in the tutorial"?

Download the example code and compare the code to see what you are doing differently.


Rob,

The trace was like this "screenutilities can't be cast to Jbutton". When I removed the ispinner variable part, it was working fine with all rest. Actually in my code i used init method instead of main methos. Inside that init method only i defined all this Jlabel and Jframe, Jspinner.
 
Rob Camick
Ranch Hand
Posts: 2703
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You comments make no sense to me and you didn't post your SSCCE, so I can't help.
 
Prabhudatta Choudhury
Greenhorn
Posts: 20
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:You comments make no sense to me and you didn't post your SSCCE, so I can't help.


Rob.

The code i gace before was the right SSCCE for it. The exception is coming for line # 35-40. If i disabled the same lines, then there will be no year spinner and no exception. Please check give me some suggesstion.
 
Stephan van Hulst
Bartender
Posts: 6587
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you gave is not an SSCCE. It's not self contained. Post a short example that we can copy into our editor, and compile straight away.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!