Results 1 to 2 of 2
Thread: How at save list in Jcombobox...
- 10-29-2009, 05:39 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 9
- Rep Power
- 0
How at save list in Jcombobox...
Hi.. everyone..i have used the following codes....the item is added to the current list but while compiling next time the item is not displayed in list of items... how to add item to combobox ...
Java Code:import java.awt.*; import java.sql.*; import java.awt.event.*; import javax.swing.*; public class Item extends Frame implements ActionListener{ JComboBox dep,type,supp; Button save,back,clr,exit; String s4,s1; TextField icode; Label l1; public Item() { super("ITEM"); setSize(450,500); setLayout(null); setBackground(new java.awt.Color(180, 180, 180)); l1=new Label("ITEMNAME"); icode=new TextField(); String su[]={"item1"," iem2","item3" }; supp=new JComboBox(su); save= new Button("SAVE"); back= new Button("BACK"); clr= new Button("CLEAR"); exit= new Button("EXIT"); l1.setBounds(20,60,100,60); icode.setBounds(150,70,120,30); supp.setBounds(20,130,210,30); save.setBounds(290,80,100,40); back.setBounds(290,140,100,40); clr.setBounds(290,200,100,40); exit.setBounds(290,260,100,40); save.addActionListener(this); back.addActionListener(this); clr.addActionListener(this); exit.addActionListener(this); add(l1); add(icode); add(supp); add(save); add(back); add(clr); add(exit); setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==save) { s1=icode.getText(); supp.insertItemAt(s1, 0); JOptionPane.showMessageDialog(this,new String("ITEM Saved")); } if(ae.getSource()==back) { this.hide(); Main st=new Main(); } if(ae.getSource()==clr) { } if(ae.getSource()==exit) { System.exit(0); } } public static void main(String args[]) { Item gi=new Item(); } }
- 10-29-2009, 05:57 AM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Well, the first think you need to do is determine if you want to create an AWT or Swing application. I would suggest using Swing since thats what is current. Swing components have "J" in the name (JButton, JFrame...). Next you read the Swing tutorial which has a section on "How to Use Combo Boxes" which contains a working example.
Similar Threads
-
How can i save the data Internally(auto save)
By Rama Koti Reddy in forum AWT / SwingReplies: 2Last Post: 11-01-2010, 08:31 PM -
Save PolygonLinked list in Notepad.txt
By cassysumandak in forum New To JavaReplies: 3Last Post: 10-01-2009, 09:15 AM -
how to save added items in jcombobox
By kwink in forum AWT / SwingReplies: 2Last Post: 03-22-2009, 06:03 PM -
Linked List integer list
By igniteflow in forum Advanced JavaReplies: 1Last Post: 12-10-2008, 08:53 PM -
JComboBox and drop-down list.....HELP!!!!!
By Anna in forum AWT / SwingReplies: 1Last Post: 06-18-2008, 05:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks