about java swing

about java swing

How to send date in data base if i use the combobox like as dd,mm,yyyy.
plz reply
thanx a lot
View Answers

March 12, 2010 at 12:35 PM

Hi Friend,

Try the following code:

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

public class GetDOB{
public static void main(String args[]){
GetDOB get=new GetDOB();
}
public GetDOB(){
JFrame f = new JFrame();
f.getContentPane().setLayout(null);
final JComboBox day=new JComboBox();
final JComboBox month=new JComboBox();
final JComboBox year=new JComboBox();
JButton button= new JButton("Submit");
for(int i=1;i<=31;i++){
day.addItem(i);
}
day.setBounds(10,10,10,10);
for(int j=1;j<=12;j++){
month.addItem(j);
}
for(int k=1900;k<=2010;k++){
year.addItem(k);
}
day.setBounds(50,50,40,20);
month.setBounds(100,50,40,20);
year.setBounds(150,50,60,20);
button.setBounds(50,80,100,20);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Object ob1=day.getSelectedItem();
Object ob2=month.getSelectedItem();
Object ob3=year.getSelectedItem();
int d=Integer.parseInt(ob1.toString());
int m=Integer.parseInt(ob2.toString());
int y=Integer.parseInt(ob3.toString());

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");
PreparedStatement pstmt = conn.prepareStatement("insert into d(myDate) values(?)");
java.sql.Date sqlDate = new java.sql.Date(y-1900,m-1,d);
pstmt.setDate(1, sqlDate);
pstmt.executeUpdate();
JOptionPane.showMessageDialog(null,"Date in inserted successfully");
}
catch(Exception ex){}
}
});
f.add(day);
f.add(month);
f.add(year);
f.add(button);
f.setVisible(true);
f.setSize(300,200);
}
}

Thanks









Related Tutorials/Questions & Answers:
about swing - Java Beginners
about swing  how implement a program of adding two numbers by entering two numbers separately by other user on the input dialog box and after that also show the result of the addition in other dialog box... your regardly
about java swing - Java Beginners
about java swing   How to upload the pictures and photo on the panel in java swing ,plz help thank a lot.  Hi Friend, Try the following code: import java.awt.*; import java.io.*; import javax.swing.*; import
Advertisements
about java swing - Java Beginners
about java swing   How to send date in data base if i use the combobox like as dd,mm,yyyy. plz reply thanx a lot  Hi Friend, Try the following code: import java.sql.*; import java.awt.*; import javax.swing.
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 if you have. Thanks in advance.   Hi Friend, Try the following code
Swing In Java
Swing In Java In this tutorial we will read about the various aspects of Swing... will demonstrate you about how to use the Swing components in Java applications... technologies. Later, the JFC was renamed to Swing. Before, the Java version 1.2
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
Java swing
Java swing  what are the root classes of all classes in swing
Java swing
Java swing  Does Swing contains any heavy weight component
java swing
java swing  view the book details using swing
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image....: http://www.roseindia.net/java/example/java/swing/ Thanks
java swing - Swing AWT
java swing   how i can insert in JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class FormDemo extends JFrame { JButton ADD; JPanel
java swing - Swing AWT
java swing   Iam developing a java web browser.Actually my code works fine ie. i can load a web page without proxy.But in my place i have only proxy... a proxy or how to make my java web browser to listen to proxy setting??? please help
java swing
java swing  what is java swing   Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java
java swing
java swing  how to connect database with in grid view in java swing   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Grid view in java swing Thanks
java swing
java swing  add two integer variables and display the sum of them using java swing
Java swing
Java swing  Write a java swing program to calculate the age from given date of birth
java swing.
java swing.  Hi How SetBounds is used in java programs.The values in the setBounds refer to what? ie for example setBounds(30,30,30,30) and in that the four 30's refer to what
JAVA SWING
JAVA SWING  Hi.... Iam doing project in java...and my front end in swing ..our project is like billing software... then what are the topics i want cover? then how to design? pls help me
java swing - Swing AWT
java swing  how to save data in sql 2005 while insert in textfield  Hi Friend, Try the following code: import java.sql.*; import javax.swing.*; import javax.swing.border.*; import java.awt.*; import
Java swing
are displayed in the table..I need the source code in java swing...Java swing  If i am login to open my account the textfield,textarea and button are displayed. if i am entering the time of the textfield
Java swing
to the database using java swing...Java swing  I create one table. That table contains task ID and Task Name. When I click the task ID one more table will be open and that table
java - Swing AWT
What is Java Swing AWT  What is Java Swing AWT
swing - Java Beginners
Swing application testing  What are the conventions for testing a Java swing application
What is Java Swing?
What is Java Swing?       Here, you will know about the Java swing. The Java Swing provides... and GUIs components. All Java Swing classes imports form the import
Java swing
Java swing  how to create simple addition program using java swing?   import java.awt.*; import javax.swing.*; import java.awt.event.*; class SumOfNumbers extends JFrame { SumOfNumbers(){ JLabel lab1=new
AutoSuggestion Box in Java Swing
Auto Suggestion Box in Java Swing In this section, you will learn how to create autosuggestion/autocomplete box in java swing. For this, we have created... will be displayed as: In this tutorial we have learned to create AutoSuggestion Box in Java
Java swing
Java swing  when i enter the time into the textbox and activities into the textarea the datas saved into the database.the java swing code for the above item   import java.sql.*; import java.awt.*; import javax.swing.
About Java
About Java  Hi, Can anyone tell me the About Java programming language? How a c programmer can learn Java development techniques? Thanks   Hi, Read about java at http://www.roseindia.net/java. Thanks
java swing
java swing  what is code for diplay on java swing internal frame form MYSQL DB pls send   Here is a code of creating form on jinternalframe and connect to mysql. import java.io.*; import java.sql.*; import java.awt.
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
Java swing in NetBeans - Swing AWT
Java swing in NetBeans   thanks a lot sir for everything you answered for my last questions now sir i just have another 3 questions that is Q 1. i will specify a swing code for JTable using NETBEANS so would you tell me
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
java swing and CSS
java swing and CSS  can css be used in java swing desktop application in different forms for better styles?plzz help
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing
Java swing  How to combine two java files
java swing
java swing  meaning of out.flush
Java swing
Java swing  What method is used to specify a container's layout
Sitemap Java Swing Tutorial
Parameter | JPA One-to-One Relationship | JPA-QL Queries Java Swing Tutorial Section Java Swing Introduction | Java 2D API | Data Transfer in Java Swing | Internationalization in Java Swing | Localization | What
Java swing
Java swing  What methods are used to get and set the text label displayed by a Button object
Java Swing
Java Swing  I want scroll bar in a frame is it possible? if it is possible means i want coding for that please send me a reply
Java Swing
Java Swing   i have a Label more than that of a frame .... how to extend the frame to view the label which are hidden.. please send me the answer sir/madam
Java Swing
Java Swing  i have a Label more than that of a frame .... how to extend the frame to view the label which are hidden.. please send me the coding sir/madam
Java Swing
Java Swing  i have a Label more than that of a frame .... how to extend the frame to view the label which are hidden.. please send me the coding sir/madam
java swing
java swing  iam using my project text box, label , combobox and that the same time i want menubar and popmenu. plz give me code for this. i want immediately plz send me that code
java swing
java swing  iam using my project text box, label , combobox and that the same time i want menubar and popmenu. plz give me code for this. i want immediately plz send me that code
Java Swing
Java Swing  i have a Label more than that of a frame .... how to extend the frame to view the label which are hidden.. please send me the coding sir/madam

Ads