Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help on scope and default constructors  RSS feed

 
David Thompson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have a relatively simple problem, but I've been banging my head against the wall for days.
I have a main class that calls other classes from it's constructor to build a GUI. One of the classes is a set of JButtons and another class is a JScrollPane. The ActionEventHandler class that I have attached to the buttons needs to refresh the JScrollPane, but I can't figure out how to do this...
Should I recall the default constructor of the JScrollPane class to refresh the screen, and how would I do that?? I tried putting a static method (so my ActionEventHandler class can see it)in my main class to do this, but I don't know how to refresh the JScrollPane object. Not to mention it seems like the methods in my main class can't call methods from the classes it called in its constructor.
I am relativly new to Java and I hope this question makes sense. Thanks in advance for any suggestions.
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, your question doesn't make complete sense to me, and you add an unnecessary apostrophe to "its". I can say definitely that you don't want to call the default constructor of the scroll pane every time you need it refreshed. A constructor is called only once: when you create the object. I'm not sure what you mean by refreshing the scroll pane. Do you intend it to scroll when a button is pressed? If so, you may have to deal with the JViewPort object. You'd probably get better answers in the Swing forum.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing forum.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!