Java Quick Tutorial
Java Quick Tutorial
formname().setVisible(true);
-------------------------------------------------------------------------------------------------------------------------
Create window
import javax.swing.*;
public class Create_window()
{
public static void main(String args[])
{
JFrame frame = new JFrame(The title );
frame.setSize(640,480);
frame.setVisible(true);
frame.setDefaultcloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
panel.add(button1);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
}
}
--------------------------------------------------------------------------------------------------------------
Action Listner
JButton button1 = new JButton(submit);
button1.addActionListener(new ActionListener())
{
public void actionPerformed(ActionEvent e)
{
//do action
}
public Yourframe()
{
JLabel label2 = new JLabel("Name:");
getContentPane().add(label2);
label2.setBounds(20,50,75,25);
icon = new ImageIcon("e:/ashick1.jpg");
//creates label
//adds to the frame
//sets position of label
//store the image in icon