How to declare a Combobox without using a string in its declaration?

How to declare a Combobox without using a string in its declaration?

What i mean to ask is how can i declare a combobox first and initialise the values later?

For example

JComboBox x= new JComboBox(); ... String s={"Alpha","Beta","Gamma"}; ... setSomething.JComboBox(s);

Is it even possible? From all the examples and tutorials so far i haven't found any which tells me how to do this.

Help will be very much appreciated!

View Answers

February 2, 2012 at 8:51 PM

Thanks a lot !!

February 2, 2012 at 4:19 PM

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

public class DynamicCombobox {

public static void main(final String args[])throws Exception {
JFrame frame = new JFrame();
JLabel lab=new JLabel("Course");
        final JComboBox combo=new JComboBox();
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           final Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee");






Related Tutorials/Questions & Answers:
How to declare a Combobox without using a string in its declaration?
how to reverse a string without changing its place
how to convert string to char array in java without using tochararray
How to declare String array in Java?
Java repeat string without using loops
Breaking a string into words without using StringTokenizer
String length without using length() method in java
Java reverse string without using inbuilt functions
Declare string array in Java (one and two dimensional)
How to insert data from a combobox and textbox values into DB using JSP?
How to make addition of two combobox values using jsp and javascript?
Jdbc Login Page Validation using Combobox
print reverse string without api
how to delete a row in sql without using delete command.
how to validate the telephone number without using jquery in html with javascript
how can i achieve multiple inheritance in java without using inheritance ?
How to declare array in Java?
how to access the object of one frame on clicking a button without using this keyword
How to split string in Java using comma?
how to count words in string using java
How to declare NSMatrix
how to build a colorful clock in JSP without using Flash.
without using built-in functions
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)
how to use an editable combobox
How to make a CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)
Without Using Form in Java Script
using tiles without struts
Array of String using Pointers
Pagination without using database in php
How ro convert char into string using recursive function in c#??