I have been recently trying to figure out what I should use to get user input in a GUI. I want the user to input text into the GUI and have the program save the text so I can use it later. I already have a basic understanding of programming GUI's. Any help is much appreciated!
You can use JTextField or JOptionPane.showInputDialog. Is your question is how can you get the input value from this Swing? Or just asking what you can use?
I suggest you work your way through the Swing tutorial, specifically the section on text widgets.
Related
I am working on a project. I want a user string (no trouble with that) to be typed out by java. Is that possible and if yes, then how?
Thank you!
I don't blame for the down votes
You can't just blindly make the program type it out on the keyboard as it is not getting displayed anywhere. You have to either use some third-party module that I have no idea about that presses keys for you, or you should actually store the string somewhere, some sort of text box. If you are using a java swing to make a GUI app, then simply create a JTextBox and set the text to your string like this:
JTextbox textbox = new JTextbox();
textbox.setText("your string goes here");
I'm (a beginner) creating a sign up form in netbeans. What I really want to happen is, a JOptionPane will appear when the textfield loses focus if a users input is wrong . I've been searching for the answer on the internet for the whole day but the answers I find don't satisfy me.
You need to implement a FocusListener, add it to your textField and in your focusLost implementation of the FocusListener you need to do whatever you want it to do when focus is lost.
http://docs.oracle.com/javase/tutorial/uiswing/events/focuslistener.html
I'm not experienced with NetBeans but I'm assuming you use the graphical tool to create your form. I think you will need to start coding to implement the listener.
You should be using an InputVerifier for this type of validation.
I have a calculator application in java swing, which is working properly with mouse click input. Now I want it to read input using keyboard button stroke. I had heard about the glass pane in java tutorial, but i need to know any other simple method to meet the requirement.
KeyPadPanel is an example that uses Action and Key Bindings for numeric entry.
I am trying to create a small Java program that has a simple command line like widget not so different from that of idle. I was originally planning to use a JTextArea and try to detect when someone presses enter, but I was wondering if there would be a better way of doing this?
I think, it is more stylish way to have ENTER to terminate. If you want to have along with some button that will not easy as idle one. I suggestion you have JTEXTAREA, you user can have wide area to see the things that they have keyed. I do not have much idea on this :) thanks
I am trying to get my options straight with some inputs that I want to enter in an application I am developing.
I want the user to input a list(of Strings) of which the size will be his decision.
I have thought of some crude solutions, like going with JOptionPane until user enters a specific input, but I would like a solution where the user can see his previous entries before he submits them all (unlike the JOptionPane solution). So I guess my question is, if there's any fast/easy way to do this - similar to JOptionPane's easiness and speed, instead of making a whole JPane design for it.
Thanks
I don't know of a fast and easy solution like JOptionPane. I think your best bet is to create a one-column JTable inside a scroll pane. There's a fairly straight-forward JTable tutorial that should get you started.