• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Need help with actionPerformed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks!
 
Marshal
Posts: 76825
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

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:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic