JFrame

JFrame

write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons.

View Answers

August 24, 2011 at 5:41 PM

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class JFrameExample extends JFrame implements ActionListener {   

    JTextField text = new JTextField(15);
    JButton b = new JButton("Click");
    private int numClicks = 0;
    JLabel lab=new JLabel("Reasons that a customer might not buy item...");
    JLabel lab1=new JLabel("Too small");
    JLabel lab2=new JLabel("Too large");
    JLabel lab3=new JLabel("Quality is not so good");
    JLabel lab4=new JLabel("No warranty");
    JLabel lab5=new JLabel("Too expensive");
    public static void main(String[] args){
        JFrame myWindow = new JFrameExample("Reasons Not to purchase");
        myWindow.setSize(500,300);
        myWindow.setVisible(true);
    }
    public JFrameExample(String title){
        super(title);
        setLayout(null);
        lab.setBounds(10,10,300,20);
        b.setBounds(320,10,80,20);
        lab1.setBounds(100,40,100,20);
        lab2.setBounds(100,70,100,20);
        lab3.setBounds(100,100,150,20);
        lab4.setBounds(100,130,100,20);
        lab5.setBounds(100,160,100,20);

        add(b);
        add(lab);
        add(lab1);
        add(lab2);
        add(lab3);
        add(lab4);
        add(lab5);
        b.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
    numClicks++;
        if(numClicks == 1){
            lab1.setVisible(false);
            lab2.setBounds(100,40,100,20);
            lab3.setBounds(100,70,100,20);
            lab4.setBounds(100,100,150,20);
            lab5.setBounds(100,130,100,20);
        }
        if(numClicks == 2){
            lab2.setVisible(false);
            lab3.setBounds(100,40,100,20);
            lab4.setBounds(100,70,150,20);
            lab5.setBounds(100,100,100,20);
        }
        if(numClicks == 3){
        lab3.setVisible(false);
        lab4.setBounds(100,40,150,20);
        lab5.setBounds(100,70,100,20);
        }
        if(numClicks == 4){
        lab4.setVisible(false);
        lab5.setBounds(100,40,100,20);
        }
        if(numClicks == 5) {
        lab5.setVisible(false);
        }
    }
}









Related Tutorials/Questions & Answers:
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframe
jframe  Create a JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
Advertisements
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
jframe
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
how to reset JFrame
how to reset JFrame  how to reset JFrame
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
jframe background color not showing
jframe background color not showing  jframe background color is not showing. please suggest.   Just add the background color to JPanel and then add it to JFrame. For example .. JFrame myFrame = new JFrame(); JPanel
jumping frame jFrame to jInternalframe
jumping frame jFrame to jInternalframe  Afternoon sir, I want to ask... and sub menu(employee). in Form Login(jFrame) have username(textfield1) and password(passwordfield1), in Menu(jframe) have Menu employee(jMenu),creaby(jlabel1
Removing the Title Bar of a JFrame
Removing the Title Bar of a JFrame  How to remove the Title Bar of a JFrame in Swing Application?   Please check the tutorial Removing the Title Bar of a Frame for the source code and example description. Thanks
JFRAME - Java Beginners
javax.swing.*; import java.awt.event.*; public class MenuExample extends JFrame
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
how to move label in jframe in java?
how to move label in jframe in java?  please any one can give me code for moving a java label in Jframe
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir i am doing a project so i am working in netbeans i have to print a JFrame it contains Labels and few textboxfields so i want to take the whole JFrame contents for printing so would you
setbackground image to JFrame - Java Beginners
setbackground image to JFrame   how to setbackground image to JFrame... TransparentBackgroundImage { public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener( new WindowAdapter() { public
insert image in JFrame - Development process
); } static public void main(String args[]) throws Exception { JFrame frame = new JFrame("Display image"); Panel panel = new ShowImage
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir thanks a lot for your reply... but i go through the link that you have specified http://www.roseindia.net/java... this public class PrintExample extends JFrame implements ActionListener { public
JFrame components printing - Swing AWT
JFrame components printing  hi sir thanks a lot for your reply... but i go through the link that you have specified http://www.roseindia.net/java... PrintExample extends JFrame implements ActionListener { public static void main
JFrame components printing - Swing AWT
JFrame components printing  hi sir thanks a lot for your reply... but i go through the link that you have specified http://www.roseindia.net/java... PrintExample extends JFrame implements ActionListener { public static void main
display multiple images from postgres database in jframe
display multiple images from postgres database in jframe  i just want to display multiple images on jframe by firing a query on postgres database
Java Image On JFrame Title
How to set Image On JFrame In this section, you will learn how to set an image on JFrame title using Java program. For this, we have created an object of JFrame class. Then, we have used Toolkit.getDefaultToolkit().getImage
How to create file from input values in Jframe ?
How to create file from input values in Jframe ?  hi i m doing my... an object for it.my java code is public class submit { JFrame frame; JTextArea text1; void form() { frame=new JFrame("details you have entered are"); JPanel
passing data from one jframe to another
passing data from one jframe to another  I have two JFrame,built... in the first Jframe to another JLabel in the other JFrame.Can you please help me,how...*; import java.awt.event.*; class PassData extends JFrame { JTextField text
how to draw a table on jframe in java - Java Beginners
how to draw a table on jframe in java  how to draw a table on jframe in java?  Hi friend, import java.awt.*; import... scrollPane = new JScrollPane(table); JFrame frame = new JFrame
Java Spring Desktop application with multiple classes and jframe
and classes...How to close one Jframe from another..Please tell... First jframe...;This is not disposing Jframe2** t.dispo(); } Second Jframe package... extends JFrame { /** Creates new form Touchscreen */ public Touchscreen
Program to read the text from a file and display it on a JFrame.
Program to read the text from a file and display it on a JFrame.  ...*; class MegaViewer1 extends JFrame { JTabbedPane jtp1=new JTabbedPane... java.lang.*; import java.awt.*; class MegaViewer1 extends JFrame { JTabbedPane jtp1
Exception when opening a excel file in JFrame
Exception when opening a excel file in JFrame  Hello, I have a problem when trying to display a Excel file in a Jframe. The exception is like...() throws ExcelException{ JFrame frame= new JFrame("Test application
Adding text in to text area of jframe at new line with different background colour
Adding text in to text area of jframe at new line with different background colour  Hi, I am reading text from text file and i want to write... colour. it is possible in text area of jframe
how to use a JInternalFrame in a JFrame to create a chat window in a client/server app?
how to use a JInternalFrame in a JFrame to create a chat window in a client/server app?  how to use a JInternalFrame within a JFrame? i want to create a client/server app. i know that JIternalFrame should be used
how to open one Jframe from main method call
how to open one Jframe from main method call  I have downloaded...(is a JFrame) Rules.java(is a JFrame) PlayGame.java have three buttons Play - i... Rules.java Jframe should be opened Exit - exits the application Now what i want
java program to read multiple files from a directory and display them on a jframe
java program to read multiple files from a directory and display them on a jframe  hi guys i want to write a java program that will read all files in a directory and display them one by on on a jframe on jpanel with specific key
Displaying search results in same panel of gridview in same jframe window.
Displaying search results in same panel of gridview in same jframe window... search and see the results in the same panel of the Jframe in Gridview Jtable... in the Jtable gridview format in the sam epanel of jframe window .But when i execute
Displaying search results in same panel of gridview in same jframe window.
Displaying search results in same panel of gridview in same jframe window... search and see the results in the same panel of the Jframe in Gridview Jtable... in the Jtable gridview format in the sam epanel of jframe window .But when i execute
Problem in setting IP address for a JFrame Class Desktop Application
Problem in setting IP address for a JFrame Class Desktop Application  I have designed a browser for our final year project, it is working well. But when we put it in a system which has a proxy setting for internet connection
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  hello... JFrame .... Can anyone plz tell me how we can do this...can anybody give me... java.awt.event.*; public class NavigateTextField extends JFrame{ JLabel
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  Hello first of all thankyou very very much for your reply.. the code which you gave... JFrame{ JLabel label1,label2; JTextField text1,text2; JPanel panel; JButton
how to handle action events in case of more than one JFrame
how to handle action events in case of more than one JFrame   I have downloaded a snake game project from the internet, initially this project contains three java files namely 1. Engine.java 2. Snake.java 3. Gameoard.java when i
how to show search results in the same panel of jframe to where search field and button is present..
how to show search results in the same panel of jframe to where search field... ,In the given code search results is being displayed in the other jframe. But in my application i need to show search results in the same panel of jframe to where
How to open textfields in the the same panel of the jframe by selcting from dropdown menu option ...
How to open textfields in the the same panel of the jframe by selcting from... the textfields and submit button in the same panel of the jframe window . Below is my code which is displaying textfields in the other jframe. KIndly help me sir
How can I Define a JFrame subclass that has four vertically positioned buttons. - Java Beginners
How can I Define a JFrame subclass that has four vertically positioned buttons.  How can I Define a JFrame subclass that has four vertically...*; public class DisplayButtons extends JFrame { int i=0; static JPanel panel

Ads