Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sample App Java source code
#1

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SampleApp extends Frame
{

public static int width = 250;
public static int height= 130;
public SampleApp(String lab)

{

super(lab);
setLayout(new GridLayout(3,1));
JButton top = new JButton("Top");
top.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent e)
{
System.out.println("Top");
}
});

JButton bottom = new JButton("Bottom");
bottom.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent e)
{
System.out.println("Bottom");
}
});
add(new JLabel("Swing Components are like awt"));
add(top);
add(bottom);
}
public static void main(String args[])
{
SampleApp f1=new SampleApp("First Swing Application");
f1.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
f1.setSize(width,height);
f1.show();
}
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.