Results 1 to 5 of 5

Thread: combo box

  1. #1
    zealman is offline Member
    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    Default combo box

    hi...i'm newbie about java programming..i try to make a form that contain data.
    In the " textPerintah4=new JTextField(15); " i want change with combo box that show database from my sql (database : newFabric table: product). How can i make the combo box automatically update data from my database...
    This is my code...
    thanks before...
    Java Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
    
    public class spare extends JFrame implements ActionListener
    {
        JButton tombol;
        JLabel teks,teks1,teks2,teks3,teks4,teks5,teks6,teks7,teks8,teks9;
        JTextField textPerintah,textPerintah1,textPerintah2,textPerintah3,textPerintah4,textPerintah5,
        textPerintah6,textPerintah7,textPerintah8,textPerintah9;
        Container contentArea;
    
        public spare()
        {
            setTitle("SparePart");
            setSize(200,550);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            teks=new JLabel("Mobil");
            textPerintah=new JTextField(15);
            teks1=new JLabel("Nopol");
            textPerintah1=new JTextField(15);  
            teks2=new JLabel("Konsumen");
            textPerintah2=new JTextField(15);
            teks3=new JLabel("Tgl Beli(Ex:YYYY-MM-DD)");
            textPerintah3=new JTextField(15);
            teks4=new JLabel("Nama Barang");
            textPerintah4=new JTextField(15);
            teks5=new JLabel("Jumlah");
            textPerintah5=new JTextField(15);
            teks6=new JLabel("Kredit");
            textPerintah6=new JTextField(15);       
            teks7=new JLabel("Total");
            textPerintah7=new JTextField(15);
            tombol=new JButton("Masukkan Data");
            tombol.addActionListener(this);
    
            contentArea=getContentPane();
            contentArea.setLayout(new GridLayout(10,1));
            JPanel panel1,panel2,panel3,panel4,panel5,panel6,panel7,panel8,panel9,
            panel10,panel11,panelmenu;
            panel1=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel1.add(teks);
            panel1.add(textPerintah);
            panel2=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel2.add(teks1);
            panel2.add(textPerintah1);
            panel3=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel3.add(teks2);
            panel3.add(textPerintah2);
            panel4=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel4.add(teks3);
            panel4.add(textPerintah3);
            panel5=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel5.add(teks4);
            panel5.add(textPerintah4);
            panel6=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel6.add(teks5);
            panel6.add(textPerintah5);
            panel7=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel7.add(teks6);
            panel7.add(textPerintah6);
            panel8=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel8.add(teks7);
            panel8.add(textPerintah7);
            panel9=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel9.add(tombol);
            contentArea.add(panel1);
            contentArea.add(panel2);
            contentArea.add(panel3);
            contentArea.add(panel4);
            contentArea.add(panel5);
            contentArea.add(panel6);
            contentArea.add(panel7);
            contentArea.add(panel8);
            contentArea.add(panel9);
       }
    
           public static void main(String[]args)
        {
            spare sparecso=new spare();
            sparecso.setVisible(true);
        }
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: combo box

    Moved from Advanced Java.

    The thread can be moved again once it is clear whether this is a JDBC or a Swing question.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: combo box

    I think you just need to programmatically set the value of the combo box - probably based on an event (like a user click, or a timer or whatever you're doing).

  4. #4
    zealman is offline Member
    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    Default Help My Combo Box

    hi...i'm newbie about java programming..i try to make a form that contain data.
    In the " textPerintah4=new JTextField(15); " i want change with combo box that show database from my sql (database : newFabric table: product). How can i make the combo box automatically update data from my database...
    This is my code...
    thanks before...

    Java Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
     
    public class spare extends JFrame implements ActionListener
    {
        JButton tombol;
        JLabel teks,teks1,teks2,teks3,teks4,teks5,teks6,teks7,teks8,teks9;
        JTextField textPerintah,textPerintah1,textPerintah2,textPerintah3,textPerintah4,
        textPerintah5,textPerintah6,textPerintah7,textPerintah8,textPerintah9;
        Container contentArea;
     
        public spare()
        {
            setTitle("SparePart");
            setSize(200,550);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            teks=new JLabel("Mobil");
            textPerintah=new JTextField(15);
            teks1=new JLabel("Nopol");
            textPerintah1=new JTextField(15); 
            teks2=new JLabel("Konsumen");
            textPerintah2=new JTextField(15);
            teks3=new JLabel("Tgl Beli(Ex:YYYY-MM-DD)");
            textPerintah3=new JTextField(15);
            teks4=new JLabel("Nama Barang");
            textPerintah4=new JTextField(15);
            teks5=new JLabel("Jumlah");
            textPerintah5=new JTextField(15);
            teks6=new JLabel("Kredit");
            textPerintah6=new JTextField(15);      
            teks7=new JLabel("Total");
            textPerintah7=new JTextField(15);
            tombol=new JButton("Masukkan Data");
            tombol.addActionListener(this);
     
            contentArea=getContentPane();
            contentArea.setLayout(new GridLayout(10,1));
            JPanel panel1,panel2,panel3,panel4,panel5,panel6,panel7,panel8,panel9,
            panel10,panel11,panelmenu;
            panel1=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel1.add(teks);
            panel1.add(textPerintah);
            panel2=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel2.add(teks1);
            panel2.add(textPerintah1);
            panel3=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel3.add(teks2);
            panel3.add(textPerintah2);
            panel4=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel4.add(teks3);
            panel4.add(textPerintah3);
            panel5=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel5.add(teks4);
            panel5.add(textPerintah4);
            panel6=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel6.add(teks5);
            panel6.add(textPerintah5);
            panel7=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel7.add(teks6);
            panel7.add(textPerintah6);
            panel8=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel8.add(teks7);
            panel8.add(textPerintah7);
            panel9=new JPanel(new FlowLayout(FlowLayout.LEFT));
            panel9.add(tombol);
            contentArea.add(panel1);
            contentArea.add(panel2);
            contentArea.add(panel3);
            contentArea.add(panel4);
            contentArea.add(panel5);
            contentArea.add(panel6);
            contentArea.add(panel7);
            contentArea.add(panel8);
            contentArea.add(panel9);
       }
     
           public static void main(String[]args)
        {
            spare sparecso=new spare();
            sparecso.setVisible(true);
        }
     
    }

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: combo box

    Please go through the Forum Rules, particularly the second paragraph. I've merged the second thread you started in the AWT/Swing section here.

    Additionally, it's extremely rude to start a new thread for the same question without bothering to supply the clarification sought here, and after totally ignoring the responses.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. dynamically populate the city combo box based on the values of state combo +ajax+jsp
    By sandy1000 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-29-2010, 10:00 AM
  2. Combo Box
    By efozdel in forum New To Java
    Replies: 1
    Last Post: 07-07-2010, 03:29 PM
  3. help get the value from the combo box
    By archcavalier in forum Enterprise JavaBeans (EJB)
    Replies: 7
    Last Post: 05-23-2010, 06:03 PM
  4. creation of one combo box form another combo box
    By er.tyagigaurav in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-09-2008, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •