/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
/**
*
* @author class
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JavaApplication3 extends JFrame implements ActionListener {
JTextField text = new JTextField(15);
JButton butt = new JButton("Press");
private int numClicks = 0;
Font firstFont = new Font("Times Roman", Font.ITALIC, 22);
JLabel TitleLabel=new JLabel("Reasons that a customer might not buy item...");
JLabel firstLabel=new JLabel("I need to talk to my spouce");
JLabel secondLabel=new JLabel("Too Complicated");
JLabel thirdLabel=new JLabel("Quality is not so good");
JLabel fourthLabel=new JLabel("No Time");
JLabel fifthLabel=new JLabel("Too expensive");
public static void main(String[] args){
JFrame myWindow = new JavaApplication3("Resistance") ;
myWindow.setSize(500,300);
myWindow.setVisible(true);
}
public JavaApplication3(String title){
super(title);
setLayout(null);
TitleLabel.setBounds(10,10, 300,20); ///setting the boundaries
butt.setBounds(320,10,80,20);
firstLabel.setBounds(100,40, 100,20);
secondLabel.setBounds(100,70, 100,20);
thirdLabel.setBounds(100,100, 150,20);
fourthLabel.setBounds(100,130, 100,20);
fifthLabel.setBounds(100,160, 100,20);
add(butt);
add(TitleLabel);
add(firstLabel);
add(secondLabel);
add(thirdLabel);
add(fourthLabel);
add(fifthLabel);
butt.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
numClicks++;
if(numClicks == 1){
firstLabel.setVisible(false);
secondLabel.setBounds(100,40, 100,20);
thirdLabel.setBounds(100,70, 100,20);
fourthLabel.setBounds(100,100, 150,20);
fifthLabel.setBounds(100,130, 100,20);
}
if(numClicks == 2){
secondLabel.setVisible(false);
thirdLabel.setBounds(100,40, 100,20);
fourthLabel.setBounds(100,70, 150,20);
fifthLabel.setBounds(100,100, 100,20);
}
if(numClicks == 3){
thirdLabel.setVisible(false);
fourthLabel.setBounds(100,40, 150,20);
fifthLabel.setBounds(100,70, 100,20);
}
if(numClicks == 4){
fourthLabel.setVisible(false);
fifthLabel.setBounds(100,40, 100,20);
}
if(numClicks == 5) {
fifthLabel.setVisible(false);
}
}
}
No comments:
Post a Comment