Helps with combo box and frame

Helps with combo box and frame

Hi i have a combobox and when i click on add button another frame pop up with text field(name ,address etc..) ,confirm button and cancel button at bottom of the frame. When i put something on the second window and click confirm i would have the information on the combo box. i don't really know how to doing it.

View Answers

March 21, 2012 at 11:17 PM

Sorry i forget to put my code i got two class. this is the first class print("import javax.swing.*; import java.awt.event.*; import java.util.*;

public class AddressList{ JComboBox combo; JTextField txtBox; private String PersonViewing; private String TelephoneNumber; private String Address; private JFrame Addressframe; Address Alist;

/**
 * Return the name of person that are viewing the property
 */
public String getName()
{
    return PersonViewing;
}    
  /**
 * Return the address of person that are viewing the property
 */
public String getAddress()
{
    return PersonViewing;
}    

/**
 * Return the telephone number of person that are viewing the property
 */
public String getTelephoneNumberOfPerson()
{
    return TelephoneNumber;
}    



public AddressList(){
    JFrame frame = new JFrame("Add-Remove item to  list");
    String items[] = {"", "", "", "", ""};
    combo = new JComboBox(items);
    JButton button1 = new JButton("Add new item");
    txtBox = new JTextField(35);

    button1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){

                Address Alist = new  Address();
            }
        }); 
    JButton button2 = new JButton("Remove");
    button2.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                if (combo.getItemCount() > 0)
                    combo.removeItemAt(0);
                else
                    JOptionPane.showMessageDialog(null,"the viewing list is empty ");
            }
        });
    JPanel panel = new JPanel();
    JPanel panel1 = new JPanel();
    panel.add(txtBox);
    panel.add(combo);
    panel.add(button1);
    panel.add(button2);
    frame.add(panel);
    //  frame.add(panel1);
    frame.setSize(320, 350);
    frame.setVisible(true);
    frame.setResizable(false);
    boolean resizable = frame.isResizable();
}

}"); abd this is the second class `print("import javax.swing.*; import java.awt.event.*; import java.util.*; import java.awt.*;

public class Address { public Address() { JFrame frame3 = new JFrame("Adding the new propert"); JPanel panel = new JPanel(new GridLayout(4,2,20,30)); panel.add(new JLabel("Name" )); panel.add(new JTextField(5)); panel.add(new JLabel("Telphone")); panel.add(new JTextField(3)); panel.add(new JLabel("Address")); panel.add(new JTextField(3)); panel.add(new JButton("Confirm")); panel.add(new JButton("Cancel"));

frame3.add(panel); frame3.setSize(350,350); frame3.setVisible(true); } }e");`

thanks


March 21, 2012 at 11:21 PM

Sorry for the previous message

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

public class AddressList{
    JComboBox combo;
    JTextField txtBox;
    private String PersonViewing;
    private String TelephoneNumber;
    private String Address;
    private JFrame Addressframe;
    Address Alist;

    /**
     * Return the name of person that are viewing the property
     */
    public String getName()
    {
        return PersonViewing;
    }    
      /**
     * Return the address of person that are viewing the property
     */
    public String getAddress()
    {
        return PersonViewing;
    }    

    /**
     * Return the telephone number of person that are viewing the property
     */
    public String getTelephoneNumberOfPerson()
    {
        return TelephoneNumber;
    }    



    public AddressList(){
        JFrame frame = new JFrame("Add-Remove item to  list");
        String items[] = {"", "", "", "", ""};
        combo = new JComboBox(items);
        JButton button1 = new JButton("Add new item");
        txtBox = new JTextField(35);

        button1.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){

                    Address Alist = new  Address();
                }
            }); 
        JButton button2 = new JButton("Remove");
        button2.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    if (combo.getItemCount() > 0)
                        combo.removeItemAt(0);
                    else
                        JOptionPane.showMessageDialog(null,"the viewing list is empty ");
                }
            });
        JPanel panel = new JPanel();
        JPanel panel1 = new JPanel();
        panel.add(txtBox);
        panel.add(combo);
        panel.add(button1);
        panel.add(button2);
        frame.add(panel);
        //  frame.add(panel1);
        frame.setSize(320, 350);
        frame.setVisible(true);
        frame.setResizable(false);
        boolean resizable = frame.isResizable();
    }
}

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


public class  Address
{
public  Address()
{
  JFrame frame3 = new JFrame("Adding the new propert");
  JPanel panel = new JPanel(new GridLayout(4,2,20,30));
  panel.add(new JLabel("Name"  ));
  panel.add(new JTextField(5));
  panel.add(new JLabel("Telphone"));
  panel.add(new JTextField(3));
  panel.add(new JLabel("Address"));
  panel.add(new JTextField(3));
  panel.add(new JButton("Confirm"));
  panel.add(new JButton("Cancel"));


  frame3.add(panel);
  frame3.setSize(350,350);
  frame3.setVisible(true);
  }
}

March 22, 2012 at 3:42 PM

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

public class AddRemoveItemFromCombo{
  JComboBox combo;
  public static void main(String[] args){
  AddRemoveItemFromCombo ar = new AddRemoveItemFromCombo();
  }

  public AddRemoveItemFromCombo(){
  final JFrame frame = new JFrame("Add-Remove Item of a Combo Box");
  combo = new JComboBox();
  JButton button1 = new JButton("Add");
  button1.addActionListener(new ActionListener(){
  public void actionPerformed(ActionEvent e){
  final JFrame frame3 = new JFrame("Adding the new propert");
  JPanel panel = new JPanel(new GridLayout(4,2,20,30));
  JButton b1=new JButton("Confirm");
  JButton b2=new JButton("Cancel");
  final JTextField text1=new JTextField(3);
  final JTextField text2=new JTextField(3);
  final JTextField text3=new JTextField(3);
  panel.add(new JLabel("Name"));
  panel.add(text1);
  panel.add(new JLabel("Telphone"));
  panel.add(text2);
  panel.add(new JLabel("Address"));
  panel.add(text3);
  panel.add(b1);
  panel.add(b2);
  frame3.add(panel);
  frame3.setSize(350,350);
  frame3.setVisible(true);

  b1.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
        frame.setFocusable(true);
        StringBuffer buffer=new StringBuffer();
         buffer.append(text1.getText()).append(", ").append(text2.getText()).append(", ").append(text3.getText());
         String text=buffer.toString();
         System.out.println(text);
         if (!text.equals("")){
            int a = 0;
            for(int i = 0; i < combo.getItemCount(); i++){
               if(combo.getItemAt(i).equals(text)){
               a = 1;
               break;
               }
            }
            if (a == 1)
               JOptionPane.showMessageDialog(null,"Combo has already this item.");
            else
               combo.addItem(text);
         }
         else{
               JOptionPane.showMessageDialog(null,"Please enter text in Text Box");
         }
         frame3.setVisible(false);
         }
       });
     }
  });
  JButton button2 = new JButton("Remove");
  button2.addActionListener(new ActionListener(){
  public void actionPerformed(ActionEvent e){
  if (combo.getItemCount() > 0)
  combo.removeItemAt(0);
  else
  JOptionPane.showMessageDialog(null,"Item not available");
  }
  });
  JPanel panel = new JPanel();
  JPanel panel1 = new JPanel();
  panel.add(combo);
  panel.add(button1);
  panel.add(button2);
  frame.add(panel);
  frame.setSize(400, 400);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

March 22, 2012 at 10:49 PM

thanks you i would like ask another question i would like to make a non GUI class of list of address and put on the combox box how i could to do that ?









Related Tutorials/Questions & Answers:
Helps with combo box and frame
Helps with combo box and frame  Hi i have a combobox and when i click on add button another frame pop up with text field(name ,address etc... on the second window and click confirm i would have the information on the combo box. i
combo box
combo box  Hi, [_|] dropdown box [ ] [INCLUDE... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get
Advertisements
combo box - JSP-Servlet
combo box  how to get a combo box in jsp page which allows editing as well as list box
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
date in combo box
date in combo box  strong texthello, how can i desplay the current year and next year in combo box???!!! it must be uppdate atumaticaly every year>>>
assigning arraylist to combo box
assigning arraylist to combo box  Hi I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help
combo box connection
combo box connection  how to provide connection between three combo boxes,if my 1st combo box is course and 2nd combo box is semester and 3rd combo box is my subjects.what's the coding to provide the connection between this three
Combo Box - Struts
Combo Box  I hava acombo box cnnected to my database via html collections. When selecting an option, i want to display specific parts (sectons) on my web page....am trying to use logic:present and logic:empty but its not working
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
Loading combo box from oracle
Loading combo box from oracle  how can i load values into a combobox from oracle database when a value is selected in another combo box
populating the combo box - Struts
populating the combo box  Hi I am having problem populating the combo box with a table in MS SQL Server 2005 Management Studio Express. Belo is the extract from the Struct?jsp application. Sector
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import="java.sql.*"%> <html> <head>
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import="java.sql.*"%> <html> <head> <script language
java combo box
java combo box  how to display messagedialogbox when the combobox is null, Thanks in advance
combo box - JSP-Servlet
combo box  I am using a JSP form in which a combobox is given and I want to populate data in it from database and on the basis of yhe selected item I want to display related data in a textbox  Hi Friend, Create
combo box code problem
combo box code problem  in this my problem related to : when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
Dojo Combo Box
Dojo Combo Box          In this section, you will learn what is combo box and how to create a combo box in dojo. For creating the Combo box  you need "
JavaScript Dynamic Combo Box
JavaScript Dynamic Combo Box Here we are going to create dynamic combo box. For this, we have created two combo boxes where combo1 represents countries... in respective arrays. As the user selects a country from the first combo box, the cities
Combo box value Error - WebSevices
Combo box value Error   if($_SERVER['REQUEST_METHOD'] == 'POST' ) { $visa =trim($_POST['hdVisa']); } document.frmProposal.hdVisa.value = document.getElementById('cmbVisa').value; Error
how to create a combo box in html
how to create a combo box in html  <tr> <td>Number<span class=mandatory>*</span></td> <td> <select name="number" id="course" style="width:158px;"> <option value="none">----Select
Retrieving Data from Database to fill Combo Box
Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting a particular image in combo box it should be displayed on the label. My combo box is only
How to create Combo Box in SWT
How to create Combo Box in SWT       This section illustrates you how to create a combo box... an action on the second combo box. The items tea , coffee and cold drink
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
Combo Box operation in Java Swing
Combo Box operation in Java Swing   ... the Combo Box component, you will learn how to add items to the combo box, remove items from the combo box. This program shows a text field, a combo box
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically... box with constituency corresponding to district..... all three combo box
how to get combo box value - JSP-Servlet
how to get combo box value  i have created 1 servlet & 1 jsp page. in servlet page i have fired query & fetched name & its id & that i have shown in combo box in jsp page: (small part of my code) "> now i want
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box...... i already stored combo box values from database. pl
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... combo box which will then load the next combo box values, now i know how... to the client using ajax, and then populate the combo box, I must'nt reload
JavaScript Combo Box Validation
JavaScript Combo Box Validation       This application illustrates how to validate the combo box using JavaScript validation. In this example we create a combo box of different
Sub combo box problem - Development process
Sub combo box problem  Hi, In this code Sub-Combo box is not working. plz solve the problem Search Page var arr = new Array(); arr["Select"] = new Array("-select-"); arr["Dkn/Tmz"] = new Array
Store combo box value - Development process
Store combo box value  Hi , this is my code. Here wen i click submit button combo values are stored like 1,2,3... but i want to store value . plz... = request.getParameter("Combo"); String Issue = request.getParameter("IssueName"); String
Need to push the combo box to flash movie - Java Beginners
Need to push the combo box to flash movie   Hi, I need to push the combo box values to the flash movie. I am succusfull in pushing the textfield... in pushing the combo box values to the flash movie
how can retrive value from combo box in servlet?
how can retrive value from combo box in servlet?  i have a jsp page with combobox. And i want to get value from combox to servlet
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
com.vaadin - vaadin-combo-box-flow version 2.1.3 Maven dependency. How to use vaadin-combo-box-flow version 2.1.3 in pom.xml?
com.vaadin  - Version 2.1.3 of vaadin-combo-box-flow Maven dependency? How to use  com.vaadin  - Version 2.1.3 of vaadin-combo-box-flow in pom.xml? How to use vaadin-combo-box-flow version 2.1.3 in pom.xml? Learn to use
com.vaadin - vaadin-combo-box-flow version 3.0.2 Maven dependency. How to use vaadin-combo-box-flow version 3.0.2 in pom.xml?
com.vaadin  - Version 3.0.2 of vaadin-combo-box-flow Maven dependency? How to use  com.vaadin  - Version 3.0.2 of vaadin-combo-box-flow in pom.xml? How to use vaadin-combo-box-flow version 3.0.2 in pom.xml? Learn to use
com.vaadin - vaadin-combo-box-flow version 1.0.7 Maven dependency. How to use vaadin-combo-box-flow version 1.0.7 in pom.xml?
com.vaadin  - Version 1.0.7 of vaadin-combo-box-flow Maven dependency? How to use  com.vaadin  - Version 1.0.7 of vaadin-combo-box-flow in pom.xml? How to use vaadin-combo-box-flow version 1.0.7 in pom.xml? Learn to use
com.vaadin - vaadin-combo-box-flow version 1.1.0 Maven dependency. How to use vaadin-combo-box-flow version 1.1.0 in pom.xml?
com.vaadin  - Version 1.1.0 of vaadin-combo-box-flow Maven dependency? How to use  com.vaadin  - Version 1.1.0 of vaadin-combo-box-flow in pom.xml? How to use vaadin-combo-box-flow version 1.1.0 in pom.xml? Learn to use
Acees data from database using combo box - JSP-Servlet
the data from database when i select combo box combo2 having values Arts, Commerce, Science. this combo box will appear when first combo box class_name having value 11 or 12, otherwise combo box combo2 remain hide. Here is JSP's files
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  Hello friend , i am using only one form. U are using html form and jsp form. So get... I can print combo box values
How to get the values from the Combo Box - JSP-Servlet
, Actually i am getting the values in the combo box from table.I want what ever the value i select in combo box its corresponding records will display in their respective text box. e.g suppose i select ram values from the combo box and its
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all are satisfaction in this form.. What will i do. My code is following
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me.... All actions in the same page.......  Hi Friend, Please visit
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends...... For Example, in Student.jsp... when i click student id in combo box... in combo box from database.. by using select*from studentinformation; But when i

Ads