• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling swing functions

 
manu nas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
manu nas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic