import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Tutorial extends JFrame
{
JPanel jp = new JPanel();
JLabel jl = new JLabel();
JTextField jt = new JTextField(30);
JButton jb = new JButton("Enter");
public Tutorial()
{
setTitle("Tutorial");
setVisible(true);
setSize(400, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
jp.add(jt);
jt.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String input = jt.getText();
jl.setText(input);
}
});
jp.add(jb);
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String input = jt.getText();
jl.setText(input);
}
});
jp.add(jl);
add(jp);
}
public static void main(String[] args)
{
Tutorial t = new Tutorial();
}
}
Thursday, December 20, 2012
Java Tutorial 36 Source Code
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Tutorial extends JFrame
{
JPanel jp = new JPanel();
JLabel jl = new JLabel();
public Tutorial()
{
setTitle("Tutorial");
setVisible(true);
setSize(400, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
jl.setIcon(new ImageIcon("C:\\Your image directory goes here"));
jp.add(jl);
add(jp);
validate();
}
public static void main(String[] args)
{
Tutorial t = new Tutorial();
}
}
Subscribe to:
Posts (Atom)