Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Thursday

JAVA PROGRAMMING TUTORIAL 23: GRAPHICAL USER INTERFACE - JLabel, JTextField & JButton

import java.awt.*;

import javax.swing.*;

public class HackDefence extends JFrame{

private JLabel x;

private JTextField y;

private JButton z;

public HackDefence(){

setLayout(new FlowLayout());

x = new JLabel("your first label");

add(x); //addition of x i.e "your first label" is done

y = new JTextField(20);

add(y);

z = new JButton("Click Here");

add(z); //addtion of z i.e button "Click Here" is done

}
public static void main(String[]args){

HackDefence GUI = new HackDefence();

GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

GUI.setSize(300,200);

GUI.setVisible(true);

GUI.setTitle("Introduction to GUI");
 
}

}

OUTPUT:


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...