This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Calling swing functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Calling swing functions" Watch "Calling swing functions" New topic
Author

Calling swing functions

manu nas
Greenhorn

Joined: Jun 15, 2013
Posts: 11
Hi guys, im trying to separate my swing in different classes, but what i get is a new window, i just want to add different jlabels, jbuttoms and other things from a new classes to my constructor class, i dont know if its possible or not, heres my resumed code.

My main class



here my constructor class:



And here my new class, where i want to add new JLabels to my constructor class:


How can i call this JLabel from my principal class?

I know i can use the dimension variable in all classes sharing it btw, but i was just trying some things ;/

Hope you guys can help me, im pretty confused right now
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Hi,

I don't really understand what you mean. But there are two suggestions you might consider:
- Pass your container instance (JFrame or JPanel) to your nuevo class, then add the labels to the container.
- Have a getter methods for the labels in your nuevo class, and use these getters from your container class to access the label objects.


PM Me If You Want to get Urgent Help on Java Programming
manu nas
Greenhorn

Joined: Jun 15, 2013
Posts: 11
oh well, thanks for your answer, i just want to modularize my program into classes, grouping them in functions, so, when i call those functions from my actionperformed button, they appear in the container.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling swing functions