|
||||||
| Java Tutorials Tutorials and Code for Java |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
This is the second of six tutorials that will show you how to create graphical user interfaces using java.
Prerequisites You should have JDK installed and an editing environment you are comfortable with. http://forum.codecall.net/java-tutorials/1703-java-tutorial-getting-started.html You should also have read my previous tutorials: INDEX The Idea In order for your program to be attractive, the user must be able to easily navigate through your program. By creating a GUI the user is presented with all the features of the program in a clear and coherent manner. Adding buttons to your interface allow for user interaction which is the reason for a GUI. Solution Since you already know how to create a window we are going to start off where we left off last time with the window code. Code:
package cctuts;
import javax.swing.*;
public class InterfaceTwo extends JFrame{
public InterfaceTwo(){
setSize(400,400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args){
new InterfaceTwo();
}
}
Code:
JButton startButton = new JButton("Start");
Code:
add(startButton); Code:
package cctuts;
import javax.swing.*;
public class InterfaceTwo extends JFrame{
public InterfaceTwo(){
setSize(400,400);
JButton startButton = new JButton("Start");
add(startButton);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args){
new InterfaceTwo();
}
}
![]() Last edited by John; 01-11-2007 at 03:08 PM. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java:Tutorial - Tic-Tac-Toe | John | Java Tutorials | 25 | 02-27-2008 06:41 PM |
| Java:Tutorial - Making multiple objects work differently | John | Java Tutorials | 0 | 01-11-2007 02:10 PM |
| Java:Tutorial - Adding more objects to your window | John | Java Tutorials | 0 | 01-11-2007 02:09 PM |
| Java:Tutorial - A better looking GUI | John | Java Tutorials | 0 | 01-11-2007 02:07 PM |
| Java:Tutorial - Make Your Button Work | John | Java Tutorials | 0 | 01-11-2007 02:04 PM |
Goal: 100,000 Posts
Complete: 68%