Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to Add JComboBox on JPanel

Have Programming Question? Ask it here!
 
 
 


shweta
How to Add JComboBox on JPanel
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


How to Add JComboBox on JPanel
D:\java>javac ViewElements.java
ViewElements.java:181: <identifier> expected
jc.addItem("France");
^
ViewElements.java:182: <identifier> expected
jc.addItem("Germany");
^
2 errors

Advertisement
View Answers

April 8, 2010 at 3:39 PM


Hi Friend,

Try the following code:

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

public class SwingFrame{
public static void main(String[] args) throws Exception{
SwingFrame sf=new SwingFrame();
}
public SwingFrame(){
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1 = new JLabel("Name");
JTextField jt1=new JTextField(15);
JLabel lbl4=new JLabel("Branch");
final JComboBox jc=new JComboBox();
jc.addItem("Select");
jc.addItem("MCA");
jc.addItem("MBA");
jc.addItem("BE");
jc.addItem("BTech");
jc.addItem("Others");
lbl1.setBounds(100,120,70,20);
lbl4.setBounds(100,150,70,20);
jt1.setBounds(170,120,100,20);
jc.setBounds(170,150,100,20);
f.add(lbl1);
f.add(lbl4);
f.add(jt1);
f.add(jc);
f.setSize(1000,1000);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

Thanks


Related Tutorials/Questions & Answers:
How to Add JComboBox on JPanel - Java Beginners
How to Add JComboBox on JPanel  How to Add JComboBox on JPanel D:\java>javac ViewElements.java ViewElements.java:181: expected...); JLabel lbl4=new JLabel("Branch"); final JComboBox jc=new JComboBox(); jc.addItem
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
Advertisements
JComboBox on JRadioButton - Java Beginners
JComboBox on JRadioButton  How to add JComboBox on Jpanel ,Give Me Sample Code
Add Items in JComboBox from Access Database - Java Beginners
Add Items in JComboBox from Access Database  Heelo Sir I want To add ittem in JComboBox which is stored in Access Database. plz Help Me Sir... JComboBox(); JFrame f=new JFrame(); JPanel p=new JPanel(); try
How to store JComboBox item into database
How to store JComboBox item into database   import... DefaultComboBoxModel(labels); final JPanel TypeTF = new JPanel(); JComboBox...(javax.swing.SwingConstants.CENTER); jLabel1.setText("ADD NEW ITEMS"); getContentPane
How to draw in jPanel? swing/graphics Java
How to draw in jPanel? swing/graphics Java  How to draw in jPanel? (swing/graphics Java
How to save JPanel as gif or jpeg file
How to save JPanel as gif or jpeg file  i draw polygons , rectangles, lines on jpanel using draw line method drawpolygon methods etc, now i want save the data of jpanel which is drawn by me(lines,polygons) as a gif or jpeg file
How to save JPanel as gif or jpeg file
How to save JPanel as gif or jpeg file  i draw polygons , rectangles, lines on jpanel using draw line method drawpolygon methods etc, now i want save the data of jpanel which is drawn by me(lines,polygons) as a gif or jpeg file
JComboBox
JComboBox  I want to change the index of one jComboBox according to the selected index of another jComboBox. I can do it.Also the user should have the ability to select or change the index of the second combobox according
jComboBox
jComboBox  I want to change the index of one jComboBox according to the selected index of another jComboBox. I can do it.Also the user should have the ability to select or change the index of the second combobox according
JComboBox
JComboBox  I have jcombobox. In which tha values are loaded from MySql Database. My problem is that i want to load content of the jtable whenever i change the selected item. Please some one help me to do this. Thank you
jcombobox
jcombobox  hi i have developed a form and i have jcombobox in which data is retrieved from ms access but the problem is that if we pressed the down key the last 5 data are not showed only the other data can be pressed
JComboBox
have jcombobox on Jframe form of IDE. In which the values are to be loaded from... change the selected item in JComboBox. Thank you.   import java.sql....); JLabel lab=new JLabel("Select"); final JComboBox combo=new JComboBox
How to Set Transperent Background Image to Jpanel - Java Beginners
How to Set Transperent Background Image to Jpanel  Sir ,How to set Background Image to Jpanel.  Hi Friend, Try the following code... = new JScrollPane( area ); frame.getContentPane().add( sp
How to add
How to add   Hi, I want to make a website which will recommend users books according to the genre selected by them. I am using PHP, JavaScript and mySQL. The problem is that there will me almost more than 100 books
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
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to store JComboBox selected Item into Ms Access Database  How to store JComboBox selected Item into Ms Access Database.  Hi Friend..."); f.getContentPane().setLayout(null); JLabel lbl1=new JLabel("Branch"); final JComboBox jc
How to save JCombobox Selected Item in to Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database  How to save JCombobox Selected Item in to Access Database  Hi Friend, Try...().setLayout(null); JLabel lbl1=new JLabel("Branch"); final JComboBox jc=new
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
scrollbar in JPanel
f = new Frame ("Demo");JPanel p = new JPanel();JButton b1 = new...) { Frame f = new Frame ("Demo"); JPanel p = new JPanel(); JButton b1 = new JButton
Scroll in JPanel
static void main(String[] args) { Frame f = new Frame ("Demo"); JPanel p = new JPanel(); JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button 2
Jpanel allignment
Jpanel allignment  i have two panels added one below anotehr. and i have a one button. when i clicked button. the first panel ara should be overlapped with second panel. i mean second panel size should cover both paenls size
how to add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
how to add mulitiple projections
how to add mulitiple projections  how to add mulitiple projections and return them
issue on jcombobox
issue on jcombobox  i have JTextfield and JComboBox. there are several values in combobox.when i select a value from combobox how to make textfiled as a combobox.only few values in the combobox need this functionality. need
how to add a file in GZIP
how to add a file in GZIP  Hi, how to add a file in GZIP using Java.   Hi, I have found a good referral site for How to Add a file in GZIP file format using Java. http://www.roseindia.net/java/examples/io
how to add plugins into eclipse
how to add plugins into eclipse  Hello, I have installed eclipse sdk 4.2M5 separately and tomcat server separately now i have to connect both for that i don't have server option in my eclipse and i m trying to add plugins but m
How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java   import java.awt.*; import java.sql.*; import java.util.*; import... Vector(); Vector data = new Vector(); JPanel p=new JPanel(); try { Class.forName
Database values in JComboBox
Database values in JComboBox In this section, you will learn how to display values in JComboBox from database. For this, we have allowed the user to enter... JFrame(); f.getContentPane().setLayout(null); final JComboBox combo = new
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to add database in Java Applet below this code is my applet source code . thank
How to add a bean in spring application?
How to add a bean in spring application?  Hi, How to add a bean in spring application? Thanks
how to add fields at runtime in j2me
how to add fields at runtime in j2me  How can I add fields at runtime in my form? How can I switch screens and can add fields at runtime? Thanks Dhruv
binding jComboBox to mysql database - Swing AWT
binding jComboBox to mysql database  I am using netbeans 6.5 How to populate jComboBox with data of specific column of mysql database table? I... java.util.*; public class JComboBoxExample extends JPanel { JLabel jlbPicture
JComboBox Insert Edited Value Into Table
JComboBox Insert Edited Value Into Table In this section we will read about how to make JComboBox an editable and then how to insert the new edited value... in to insert an editable value of JComboBox into a table. We will use an Java editor
how to add framework in xcode 4
how to add framework in xcode 4  how to add framework in xcode 4 iPhone?   In the project navigator, Select Project Select the 'Build Phases' tab Open 'Link Binaries With Libraries' expander Click the '+' button
How to add nofollow in website link?
How to add nofollow in website link?  Hi, I want to add nofollow in my outgoing links. What is the code? Thanks   Hi, Here is the code: <a rel="nofollow" href="http://">Click Here to visit</a>
Java JComboBox Get Selected Item Value
Java JComboBox Get Selected Item Value In this section we will discuss about how to get the selected item value form JComboBox. javax.swing.JComboBox.... In this tutorial we are discussing about how to store the selected item value
jComboBox with database
jComboBox with database  Hello friends, I have created three JComboBoxes. first two of them get list from string. However I select these two comboboxes, the third combobox automatically retrieve data of a particular column from
how to add panel inside frame?
how to add panel inside frame?  I prepared a Frame with two labels and text fields and one button.when ever user clicks on the button two text fields... to add panel after those components.but while compilation its showing errors.how
About jcombobox - Swing AWT
suggest jcombobox in swing? If yes is there any jar file for that or any code... javax.swing.*; public class AutoSuggest extends JPanel{ private final JTextField tf; private final JComboBox combo = new JComboBox(); private
How to add a column in a table
How to add a column in a table   ... should know how you can modify the structure of the table. The problem is that we have to add a new column to our database by using the java program
Draw bufferimage in jpanel using netbeans
Draw bufferimage in jpanel using netbeans  please i need urgent help. i have form which contains some fields generated in netbeans. how can i draw bufferimage in Jpanel that is inside the form. thanks
Help on database and JComboBox
Help on database and JComboBox  I want to select from the JComboBox and when click onto the "search" button, the selected category (example "new york") all the each new york picture and detail will be seen. But how to grab
How to add or create instant messaging in website?
How to add or create instant messaging in website?  How to add or create instant messaging in website
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
How to add or create instant messaging in website?
How to add or create instant messaging in website?  How to add or create instant messaging in website
 

 

 

DMCA.com