outputting from menu in swing applet, saving to file...
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Use ActionListener with a menu click. Inside the ActionListener, use FileWriter
ppanyam
yeah i got the menu options working, but my problemo now is how do i do user input in them? and.. with the FileWriter, it was saying something about the throws java.io.IOException, where do i put that?
Surround the filewriter operation in a try-catch to handle the exception.
okay thanks!
would you happen to know how i can do the user input, like i ask a question...the input and then it saves, because my menu options open in seperate message windows, if you know what i mean.
To do something like that you would need to write an actionListener method for you button and when it's pressed the program should store the value by
String value=textfield.getText();
To do something like that you would need to write an actionListener method for you button and when it's pressed the program should store the value by
String value=textfield.getText();
with the try/catch, can you tell me if this is right? lol
That code is fine except for the FileWriter parameter. You should make it a directory like "C:/testpage.html" so that you know where your file is saving.
That code is fine except for the FileWriter parameter. You should make it a directory like "C:/testpage.html" so that you know where your file is saving.
That code is fine except for the FileWriter parameter. You should make it a directory like "C:/testpage.html" so that you know where your file is saving.
Code:
JPanel row1 = new JPanel ();
row1.setLayout (new BorderLayout ());
row1.add (new JLabel ("What's your name?: "), BorderLayout.CENTER);
row1.add (nameTxtFld, BorderLayout.EAST);
row1.add (submitBtn, BorderLayout.SOUTH);
fw.write (nameTxtFld + "C:/textpage.html");
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.