I'm making a program where the user types a filename into a text field and clicks a button, once the button is clicked the data from the file is displayed in a JTextArea, to try and make the program look better I wanted to open a new JFrame to display the data in, but obviously as it's void I can't access the data outside of the button, is there any way around this?
Don't use actionPerformed any more; write a λI would avoid trying to show a new frame because that will make the display look very peculiar. Try putting your text component inside a scroll pane.
You probably want a separate object to do all the file reading, record the text, etc. You would probably do well to divide that method in to several smaller methods, otherwise it will become too long. You may need the text components as fields rather than local variables so you can gain access to them.
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad: