How to make things happen on a frame in java?
-
ok so i am very new to java, and know almost nothing about GUI or making windows and all that. what i have now is a frame, and what i want to tdo is to make it so i can enter in a password or something once the window opens up, and have commands be executed but the results output on the screen, like how you do in eclipse and the program executes in the box at the bottom, but instead on the window i make. here is my code : import java.awt.Dimension; import javax.swing.*; // Create a simple GUI window public class InterfaceOne{ public static void createWindow() { //Create and set up the window. JFrame frame = new JFrame("GAME"); frame.setDefaultCloseOperation(JFrame.E XIT_ON_CLOSE); frame.setPreferredSize(new Dimension (500, 500)); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { createWindow(); } } so how do i add things like textfields that i can write in and have like a password thing with an if statement and what not. and also how do i make buttons, that when clicked will lead to more options and such please help ! :( i hope to make a video game and want to start making the window to get in and click to get into the game and stuff. also if possible, can you give me links to tutorials to make a game like minecraft and to teach me what to actually do and not just what to type.
-
Answer:
go to youtube, and search for: thenewboston java Bucky is pretty good at providing the information that you need to learn the objects and methods, but I'm not going to sit here and type out examples when it's clearly on the web.
John Walge at Yahoo! Answers Visit the source
Other answers
import java.awt.*; public class InterfaceOne{ Container c = getContentPane(); JLabel username = new JLabel("Username:"); JTextField utxt= new JtextField(); JLabel password= new JLabel("Password:"); JTextField ptxt = new JtextField(); JButton login = new JButton("Login"); c.add(username); c.add(utxt); c.add(password); c.add(ptxt); c.add(login);
Haris
Java JPanel (or JScrollPane) and add JPasswordField, JTextField to it. Then add JPanel to frame.
James Bond
Related Q & A:
- How to add buttons and panels in frame in java?Best solution by Stack Overflow
- How to make parentheses bold in a string?Best solution by Stack Overflow
- How to make collapsible columns for a table?Best solution by Stack Overflow
- How to make reverse proxy and a check page?Best solution by Stack Overflow
- How to make an image have a different color?Best solution by superuser.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.