2013-07-19 2 views
0
package interstateexpress; 

import java.awt.event.ActionEvent; 
import java.awt.event.ActionListener; 
import java.sql.*; 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.Statement; 
import java.text.DateFormat; 
import java.text.SimpleDateFormat; 
import javax.swing.ImageIcon; 
import javax.swing.JButton; 
import javax.swing.JFrame; 
import javax.swing.JLabel; 
import javax.swing.JOptionPane; 
import javax.swing.JTextField; 
import java.util.Date; 
import javax.swing.JComboBox; 
import javax.swing.JScrollBar; 
import javax.swing.JScrollPane; 

public class driverprofile implements ActionListener 
{ 

    private JFrame f; 
    private JLabel lb_name,lb_email,lb_address,lb_hourlyrate,lb_startdate,lb_homeph,lb_cellph,lb_image; 
    private JTextField tx_name,tx_email,tx_address,tx_hourlyrate,tx_startdate,tx_homeph,tx_cellph,tx_image; 
    private JButton bt_go,bt_date; 
    private JComboBox cb; 
    private JScrollBar pane; 
    String a[]={"1","2","3","4","5","6","7","8","9","10","11","12","13"}; 

    public driverprofile() 
    { 
     f=new JFrame(); 
     lb_name=new JLabel("Name"); 
     lb_email=new JLabel("E-mail"); 
     lb_address=new JLabel("Address"); 
     lb_hourlyrate=new JLabel("Hourly Rate"); 
     lb_startdate=new JLabel("Starting Date"); 
     lb_homeph=new JLabel("Home Phone"); 
     lb_cellph=new JLabel("Cell Phone"); 
     lb_image=new JLabel("Image Location"); 
     tx_name=new JTextField(); 
     tx_email=new JTextField(); 
     tx_address=new JTextField(); 
     tx_hourlyrate=new JTextField(); 
     tx_startdate=new JTextField(); 
     tx_homeph=new JTextField(); 
     tx_cellph=new JTextField(); 
     tx_image=new JTextField(); 
     bt_go=new JButton("Submit"); 
     cb=new JComboBox(a); 
     pane = new JScrollBar(); 
     cb.addItem(pane); 
     bt_go.addActionListener(this); 
    } 
    public void launch() 
    { 
     f.setLayout(null); 
     f.setSize(400,600); 
     f.add(lb_name); 
     f.add(lb_email); 
     f.add(lb_address); 
     f.add(lb_hourlyrate); 
     f.add(lb_startdate); 
     f.add(lb_homeph); 
     f.add(lb_cellph); 
     f.add(lb_image); 
     f.add(tx_name); 
     f.add(tx_email); 
     f.add(tx_address); 
     f.add(tx_hourlyrate); 
     f.add(tx_startdate); 
     f.add(tx_homeph); 
     f.add(tx_cellph); 
     f.add(tx_image); 
     f.add(bt_go); 
     f.add(cb); 
     lb_name.setBounds(20,80,60,20); 
     tx_name.setBounds(120,80,180,25); 
     lb_email.setBounds(20,120,60,20); 
     tx_email.setBounds(120,120,180,25); 
     lb_address.setBounds(20,160,60,20); 
     tx_address.setBounds(120,160,180,25); 
     lb_hourlyrate.setBounds(20,200,80,20); 
     tx_hourlyrate.setBounds(120,200,50,25); 
     lb_startdate.setBounds(20,240,80,20); 
     cb.setBounds(120,240,180,25); 
     lb_homeph.setBounds(20,280,80,20); 
     tx_homeph.setBounds(120,280,90,25); 
     lb_cellph.setBounds(20,320,80,20); 
     tx_cellph.setBounds(120,320,90,25); 
     lb_image.setBounds(20,360,90,20); 
     tx_image.setBounds(120,360,180,25); 
     bt_go.setBounds(250,400,80,30); 
     f.setVisible(true); 
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    } 


} 

dernière entrée de combobox est toujours Javax.Swings.JScrollBar [, 0,0] !!!!!! comment puis-je l'enlever? je n'ai pas ajouter cela dans la liste de tableau comme indiqué ci-dessus ..... plz m'aider à supprimer cela. j'ai fait un conbobox pour la date de début et l'entrée sont 1,2,3,4,5,6,7,8,9,10,11,12,13 ce sont juste pour la piste ne vous inquiétez pas à ce sujet.ScrollBar en montrant la dernière entrée combobox javax.swings.JScrollbar [, 0,0]

Répondre

3

Je dirais que cela est votre problème

pane = new JScrollBar(); 
cb.addItem(pane); 

Vous ajoutez un JScrollBar à la liste des éléments de zone de liste déroulante ...

+0

@ MadProgrammer-comment puis-je faire alors ..... ??? –

+0

Fais quoi? La fenêtre contextuelle utilisée par la zone de liste déroulante place automatiquement la liste dans un panneau de défilement – MadProgrammer

Questions connexes