Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple files?

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a notepad like project and we have a single file that we are wanting to split up into multiple files. The problem I am having is that I cannot get parts of the program that display information into textboxes to work after I place them into a separate file. How do I get classes to reference parts of the GUI from another class?
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or is that even possible?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't really a GUI problem - it's an OO design problem. You just have to pass references to revelant component objects to the new class.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like:---This is a rough sketch and some syntax is probably wrong, I dont have the code in front of me.

[ November 28, 2007: Message edited by: James Hambrick ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unsure if this is correct because the code sample was short - but something like this:



For this specific example - it might make more sense to use a CaretListener - though I'm still unsure how finding the caret position in the textArea can give you the columns...
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to that is on another post where I was shown how to do this on antoher post. I will try that idea on the code when I get a chance to get back to my home computer. With Christmas getting close Ive been running around alot.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how is that code going to work with a caret listener?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the comment inside the LineColumnCount.getColumnCount() was


I thought it might make more sense to use a CaretListener.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is the relevant code that I have, I was wanting to make a class that calculates the line number and column number.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic