Link To Database with JComboBox 1 Answer(s) 3 years and a month ago
Posted in : Java Beginners
sir As ur Source Code i have Load course names from Access Database in to JComboBox but now I want to do ,when i select Course name from Jcombobox i want to display appropriate records relate with taht course on combobox item changed event. eg when i select MCA the fees ,course type will automaticall displayed in the JTextField. plz Help Me Sir.
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("Branch"); final JComboBox jc=new JComboBox(); JLabel lbl2 = new JLabel("Duration"); final JTextField jt1=new JTextField(15); JLabel lbl3 = new JLabel("Fees"); final JTextField jt2=new JTextField(15); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =DriverManager.getConnection("jdbc:odbc:access","",""); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select name from course");
jc.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ItemSelectable is = (ItemSelectable)e.getSource(); String st= selectedString(is); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =DriverManager.getConnection("jdbc:odbc:access","",""); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from course where name='"+st+"'"); int duration=0; int fees=0; while(rs.next()){ duration=rs.getInt("duration"); fees=rs.getInt("fees"); } jt1.setText(Integer.toString(duration)); jt2.setText(Integer.toString(fees)); } catch(Exception ex){} } }); } static private String selectedString(ItemSelectable is) { Object selected[] = is.getSelectedObjects(); return ((selected.length == 0) ? "null" : (String)selected[0]); } }
Thanks
Related Pages:
Link To Database with JComboBox - Java Beginners Link To Database with JComboBox sir As ur Source Code i have Load course names from Access Database in to JComboBox but now I want to do ,when i select Course name from Jcombobox i want to display appropriate records relate
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
have jcombobox on Jframe form of IDE. In which the values are to be loaded from MySql Database. My problem is that i want to load content of the jtable whenever i change the selected item in JComboBox.
Thank you.
import java.sql.
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... my database. But in my code its only get data from first item which
link
link how can we give hyperlinks on data retrieved from the database and when a particular option is clicked it should be saved in another database and details related to that link should be diaplay and stored in the database
link
link Hi Shruti
Step1 :First thing you need to do is fetch the value from database and save it in a variable for ex. temp and put it in between a href tag as :
Step2 : Use a id to select this using JavaScript or jQuery
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... the things from database
How to store JComboBox item into database
How to store JComboBox item into database import... DefaultComboBoxModel(labels);
final JPanel TypeTF = new JPanel();
JComboBox comboBox1 = new JComboBox(model);
comboBox1.setEditable(false
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... the database will get
displayed on the ComboBox. If there will be no data
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...){
e.printStackTrace();
}
JComboBox comboTypesList = new
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 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
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
Database Column name -Course
Items -MBA,MCA,MBA IT,MBA FINANCE
I want Load Database
Retrieve data by clicking a link
Retrieve data by clicking a link In a page there are 5 links.Every link has a hidden value. According to that hidden value data should be retrieved from the database and data should be displayed in a new page.How to do it?Please
link
the link the table is displayed and other links were hidden if i want to click the next link i have to refresh the page instead i want to do is when i click the link the table should display and again when i click the link the table should
LINK
LINK Thank you friend.cant we use single click instead of double click and also for four link u has given the example but i have 14 links in that case wat i should do
LINK
LINK I have four links which link to a table,if i click one link... i want to ask is when i click the link the table is displayed and other links were hidden if i want to click the next link i have to refresh the page instead i
Java JComboBox Get Selected Item Value
of JComboBox into the database table. To store the
selected item value of JComboBox...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
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
Database
Database How to represent data from database in a tree?
Please visit the following link:
Retrieve data from database in tree using Java Swing
PHP Link Rotator, PHP Link Rotator Script
PHP Link Rotator
In this tutorial I'm going to learn you own to create... page. You don't need to
have database access, it is just one php file... for each link.
But with some cool modifications (writing the number of views
JComboBox with AccessDatabase - Java Beginners JComboBox with AccessDatabase Hello Sir I have Created Course... on Student Admission Form
when I select Course Name from JComboBox on Student...");
JComboBox combo1=new JComboBox();
JComboBox combo2=new JComboBox
About jcombobox - Swing AWT
About jcombobox Hi all,
I am new to this forum.
Can we do auto suggest jcombobox in swing? If yes is there any jar file for that or any code... JTextField tf;
private final JComboBox combo = new JComboBox();
private
Hypertext link
Hypertext link hii,
What is a Hypertext link?
hello,
A Hypertext link is a special tag that links one page to another page or resource. If you click the link, the browser jumps to the link's destination
JComboBox Event Handling - Java Beginners JComboBox Event Handling Hi,
I have problem with event handling here.There are Two JComboBox and a JTextField.When I select an item in first... Compare extends JFrame implements ItemListener
{
JComboBox combo,lcombo
Link to a website Link to a website I have created a mobile application.Now I want to insert a link to a website so that when mobile user selects that link he is directed to that website
Hypertext link
Hypertext link hello,,
What is a Hypertext link?
hii,
A hypertext link is a special text that perform the linkage between two web page.
<a href="www.roseindia.net">roseindia site</a>
HTML Link
HTML Link How do I create a link that opens a new window
position of a link
position of a link the table appears at the bottom i want it to be display at the top pls help me.Each link if i click it should display in the same position
attaching a link
attaching a link I want the program code for , creating an application form and it is attached to our code, by clicking on this link, the form should be open
Link on Image Link on Image HTML link question mark Image
can anyone please suggest how can i link the question mark image in HTML?
<p>
<a class="mainLinks" href="#">Currency Converter <img src
mfmailComposeViewController link
mfmailComposeViewController link Is there any way to get a hyperlink on email text using mfmailComposeViewController in my iPhone application?
To get link on the text, you need to make it HTML enable
JComboBox Display Problem - Java Beginners JComboBox Display Problem I am create one program that contain two...,ItemListener
{
Container c;
JLabel lblstart,lblend;
JComboBox cmbstart...");
lblend=new JLabel("End Date");
cmbstart=new JComboBox();
cmbend=new
can modify this application connection with database
can modify this application connection with database hi i'm want... modify connection with database ?
import javax.swing.*;
import java.applet.... b1,b2;
JComboBox combo;
DecimalFormat df = new DecimalFormat