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



Home Answers Viewqa Java-Beginners How to store JComboBox item into database

Have Programming Question? Ask it here!
 
 
 


sunil singh
How to store JComboBox item into database
0 Answer(s)      2 years and a month ago
Posted in : Java Beginners


import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JOptionPane; import javax.swing.JPanel;

/* import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.JOptionPane;*/

@SuppressWarnings("serial") public class ItemDetails extends javax.swing.JFrame {

String ID;

// Variables declaration - do not modify//GEN-BEGIN:variables

private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JButton SaveBTN;
private javax.swing.JButton BackBTN;
private javax.swing.JTextField ItemcodeTF;
private javax.swing.JTextField TypeTF;
private javax.swing.JTextField ItemnameTF;
private javax.swing.JTextField DescriptionTF;
private javax.swing.JTextField ManufaturerTF;
private javax.swing.JTextField CostTF;

// End of variables declaration//GEN-END:variables /* public ItemDetails() { initComponents(); }*/

public ItemDetails(String id) {

    ID= id;
    initComponents();


    // TODO Auto-generated constructor stub
}

private void initComponents(){

    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    ItemcodeTF = new javax.swing.JTextField();
    TypeTF = new javax.swing.JTextField();
    ItemnameTF = new javax.swing.JTextField();
    DescriptionTF = new javax.swing.JTextField();
    ManufaturerTF = new javax.swing.JTextField();
    CostTF = new javax.swing.JTextField();
    SaveBTN = new javax.swing.JButton();
    BackBTN = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("DETAIL FORM");

    setResizable(false);
    getContentPane().setLayout(new AbsoluteLayout());

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36));
    jLabel1.setForeground(new java.awt.Color(153, 0, 153));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("ADD NEW ITEMS");
    getContentPane().add(jLabel1,new AbsoluteConstraints(100, 20, -1, -1));

    jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
    jLabel2.setForeground(new java.awt.Color(153, 0, 153));
    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel2.setText("Item Code");
    getContentPane().add(jLabel2,new AbsoluteConstraints(27, 140, 100, 20));

    jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14));
    jLabel3.setForeground(new java.awt.Color(153, 0, 153));
    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("Item Name");
    getContentPane().add(jLabel3,new AbsoluteConstraints(27, 180, 100, 30));


    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));
    jLabel4.setForeground(new java.awt.Color(153, 0, 153));
    jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel4.setText("Description");
    getContentPane().add(jLabel4,new AbsoluteConstraints(35, 220, 80, 20));

    jLabel7.setFont(new java.awt.Font("Tahoma", 1, 16));
    jLabel7.setForeground(new java.awt.Color(153, 0, 153));
    jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel7.setText("Type");
    getContentPane().add(jLabel7,new AbsoluteConstraints(360, 260, 80, 20));

    jLabel5.setBackground(new java.awt.Color(249, 239, 242));
    jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14));
    jLabel5.setForeground(new java.awt.Color(153, 0, 153));
    jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel5.setText("Manufacturer");
    getContentPane().add(jLabel5, new AbsoluteConstraints(30,260, 100, 20));

    jLabel6.setBackground(new java.awt.Color(249, 239, 242));
    jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
    jLabel6.setForeground(new java.awt.Color(153, 0, 153));
    jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel6.setText("Cost(RS.)");
    jLabel6.setOpaque(true);
    getContentPane().add(jLabel6, new AbsoluteConstraints(30, 300, 100, -1));

    ItemcodeTF.setFont(new java.awt.Font("Tahoma", 0, 12));
    ItemcodeTF.setForeground(new java.awt.Color(153, 0, 153));
    getContentPane().add(ItemcodeTF, new AbsoluteConstraints(150, 140, 180, -1));

    ItemnameTF.setFont(new java.awt.Font("Tahoma", 0, 12));
    ItemnameTF.setForeground(new java.awt.Color(153, 0, 153));
    getContentPane().add(ItemnameTF,new AbsoluteConstraints(150, 180, 180, -1));

    DescriptionTF.setFont(new java.awt.Font("Tahoma", 0, 12));
    DescriptionTF.setForeground(new java.awt.Color(153, 0, 153));
    getContentPane().add(DescriptionTF, new AbsoluteConstraints(150, 220, 390, -1));

    ManufaturerTF.setFont(new java.awt.Font("Tahoma", 0, 12));
    ManufaturerTF.setForeground(new java.awt.Color(153, 0, 153));
    getContentPane().add(ManufaturerTF, new AbsoluteConstraints(150,260, 180, -1));

    CostTF.setFont(new java.awt.Font("Tahoma", 0, 12));
    CostTF.setForeground(new java.awt.Color(153, 0, 153));
    getContentPane().add(CostTF,new AbsoluteConstraints(150, 300, 180, -1));

    TypeTF.setFont(new java.awt.Font("Tahoma", 0, 12));
    TypeTF.setForeground(new java.awt.Color(153, 0, 153));
    final String labels[] = { "Tablets", "Capsules", "Syrup" };
    final DefaultComboBoxModel model = new DefaultComboBoxModel(labels);
    final JPanel TypeTF = new JPanel();
    JComboBox comboBox1 = new JComboBox(model);
    comboBox1.setEditable(false);
    TypeTF.add(comboBox1);
    getContentPane().add(TypeTF,new AbsoluteConstraints(430, 255, 180, -1));        

    SaveBTN.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.highlight"));
    SaveBTN.setFont(new java.awt.Font("Times New Roman", 1, 16));
    SaveBTN.setForeground(new java.awt.Color(102, 0, 102));
    SaveBTN.setText("SUBMIT");
    SaveBTN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 255), new java.awt.Color(255, 204, 255), new java.awt.Color(153, 0, 153), new java.awt.Color(153, 0, 153)));
    SaveBTN.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            SaveBTNActionPerformed(evt);
        }
    });


    getContentPane().add(SaveBTN, new AbsoluteConstraints(110, 380, 90, 40));

    BackBTN.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.highlight"));
    BackBTN.setFont(new java.awt.Font("Times New Roman", 1, 16));
    BackBTN.setForeground(new java.awt.Color(102, 0, 102));
    BackBTN.setText("BACK");
    BackBTN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 255), new java.awt.Color(255, 204, 255), new java.awt.Color(153, 0, 153), new java.awt.Color(153, 0, 153)));
    BackBTN.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
          BackBTNActionPerformed(evt);
        }
    });


    getContentPane().add(BackBTN, new AbsoluteConstraints(260, 380, 90, 40));





   this.setSize(600, 600); 
 //pack();   
}

private void SaveBTNActionPerformed(java.awt.event.ActionEvent evt){

      try{

         Class.forName("com.mysql.jdbc.Driver");
         String database = "jdbc:mysql://localhost:3306/medicalstore";
         Connection conn = DriverManager.getConnection(database, "root", "sunil");
         Statement stmt = conn.createStatement(); 



         String sql = "insert into addnewitem values ( '" + ItemcodeTF.getText() + "','" + ItemnameTF.getText() + "' ,'" + DescriptionTF.getText() + "' , '" + ManufaturerTF.getText() + "' , '" + TypeTF.getText() + "' , '" + CostTF.getText() + "' )" ;
         stmt.executeUpdate(sql);

         stmt.close();
         conn.close();



    }

      catch( Exception e)
      {
           JOptionPane.showMessageDialog(null,"" + e);

      }
}

private void BackBTNActionPerformed(java.awt.event.ActionEvent evt){

    add m = new add(ID);
    this.setVisible(false);
    m.setVisible(true);
}
/*
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new ItemDetails().setVisible(true);
        }
    });
}*/

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
How to store JComboBox item into database
How to store JComboBox item into database   import...(javax.swing.SwingConstants.CENTER); jLabel2.setText("Item Code"); getContentPane().add(jLabel2,new...); jLabel3.setText("Item Name"); getContentPane().add(jLabel3,new AbsoluteConstraints(27
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
Advertisements
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 store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database... through the following link How To Store Image Into MySQL Using Java
Java JComboBox Get Selected Item Value
. In this tutorial we are discussing about how to store the selected item value of JComboBox into the database table. To store the selected item value of JComboBox... how to get the selected item value form JComboBox. javax.swing.JComboBox
jComboBox with database
my database. But in my code its only get data from first item which...jComboBox with database  Hello friends, I have created three JComboBoxes. first two of them get list from string. However I select these two
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
Help on database and JComboBox
Help on database and JComboBox  I want to select from the JComboBox...") all the each new york picture and detail will be seen. But how to grab the things from database
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
delete an item from database
delete an item from database  how to delete an item from the database using jsp
how to store and then immediately retrieve when store the image into database?
how to store and then immediately retrieve when store the image into database?  how to store and then immediately retrieve when store the image into database?   Here is a jsp code that insert and retrieve image from
navigation between panels when item is selected from jcombobox - Swing AWT
navigation between panels when item is selected from jcombobox  hi...(2nd panel).the combo box is in main panel. when a item is selected from combobox the 2nd panel should navigate to other panel. for now i have 4 item in the combo
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using... database. <%@page import="java.sql.*,java.io.*"%> <% try{ InputStream
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
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database?  I want to store extracted xml values in a database... How can i store extacted xml values in a database... give me a example
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database?  I want to store extracted xml values in a database... How can i store extacted xml values in a database... give me a example
how to make drop down list in JSF & fetch data Item from database
how to make drop down list in JSF & fetch data Item from database  how to make drop down list in JSF & fetch data Item from database
How to change object item to integer item
How to change object item to integer item  How to change objectitem to integer item?thankyou
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.
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
How to store values in a database using JSTL? - JSP-Servlet
How to store values in a database using JSTL?  I want to store values in a database... How can i store in database? Here is my code... This wil... in a database...How can i do? Airport
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
how to store and retrieve images int and from the database using php
how to store and retrieve images int and from the database using php  please anyone can help me in storing the images and retrieve it back from the Mysql database using php
how to store JTree data hierarchically in mysql database from netbeans
how to store JTree data hierarchically in mysql database from netbeans  how to store JTree data hierarchically in mysql database from netbeans. I am new to this topics so I need a program and tables you are using in database
How I Upload File and Store that file name in Database using JSP
How I Upload File and Store that file name in Database using JSP  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail
How to Store Float Value into Access Database - Java Beginners
How to Store Float Value into Access Database  Hello sir,I want to Store Student Marks Percentage into Access Database in Float Value how i can Store.... To store the double value in Access database, you need to set the datatype
how to store the data in a array retrived from the database - JSP-Servlet
how to store the data in a array retrived from the database  hi... in database,and i need to disply all the employees record in a single jsp. pls can any one tell me how to do it this using jsp. thankyou,  Hi nagaraj
How to read excel data and store it in database - Java Beginners
How to read excel data and store it in database  Hi, I want a java code to read data from excel and store it in Ms Access database.I tried the code but but its printing the output in console.I dont know how to store the excel
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
image store in database - JDBC
to store image into database. Check at http://www.roseindia.net/servlets/insert...image store in database  Dear Deepak Sir, If I want to store image into the database what is the process to do that? Please explain
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 store image file and videofile in ms access database using java? - JDBC
how to store image file and videofile in ms access database using java?  how to store image file and video file in ms access database using java
how to store image in folder and stored image path in mysql database using JSP
how to store image in folder and stored image path in mysql database using JSP  how to store image in folder and stored image path in mysql database using JSP
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
Unable to store the image into database
); }   Hi, Please check the thread How to Insert image into database...Unable to store the image into database  Hello, I have created below program and program is throwing FileNotFound exception when I pressed the submit
store and retrive image from the database
store and retrive image from the database  please provide me with the code and the explanation of what each line does for the below query. -how to store and retreive images from sql database using sql commands -how to store
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
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
How to get the text from textarea in HTML and store it in database using javascript and jsp
How to get the text from textarea in HTML and store it in database using javascript and jsp  How to get the text from textarea in HTML and store it in database using javascript and jsp <script> function str() { <
store dropdown box values in database server
store dropdown box values in database server  how to store dropdown box values in database server in jsp
Load Coursenames from MS Acess Database to JComboBox - Java Beginners
Load Coursenames from MS Acess Database to JComboBox  Hello sir, I want to Load/add Course names which stored in Ms Acess 2007 Database, plz help..."); final JComboBox jc=new JComboBox(); try{ Class.forName
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java struts 1.3  hii, i am coding a form where i need a keyskills attribute where i have to select multiple keyskills. but it is taking only one valuee.. i
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
 

 

 

DMCA.com