
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class StandFord {
public static void main(String[] args)
{
new obj();
}
}
class obj extends JFrame{
public obj()
{
JFrame fr = new JFrame("Welcome"); fr.setLocation(400,300); fr.setSize(300, 300);
Container cont =fr.getLayeredPane();
cont.setLayout(new BorderLayout());
// UP PANEL
JPanel UpPanel =new JPanel();
UpPanel.setLayout(new GridLayout(1,1));
final JLabel answer = new JLabel();
UpPanel.add(answer);
cont.add(UpPanel, BorderLayout.NORTH);
// DOWN PANEL
JPanel downPanel =new JPanel();
downPanel.setLayout(new GridLayout(1,1));
final JButton but1 = new JButton("Click It");
downPanel.add(but1);
cont.add(downPanel, BorderLayout.SOUTH);
ActionListener l = new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
if(e.getSource()==but1)
{
answer.setText("hi");
}
}
};
but1.addActionListener(l);
fr.setVisible(true);
}
}
Question 1)
Now I want to change something.
when I click , my program writes:
hi
Then If I click again, I want to write:
hi
hi2
then...
hi
hi2
hi3
Question 2)
could I see what happens each line in my code, step-by-step? For example like FireBug or Visual Studio has, when I Debug it step by step..


Sign In
Create Account


Back to top









