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);
    }


}

组合框的最后一项始终是 Javax.Swings.JScrollBar[,0,0]!!!!!!我怎样才能删除它?如上所示,我没有在数组列表中添加它.....请帮我删除它。我为开始日期制作了一个组合框,输入为 1、2、3、4、5、6、7、8、9、10、11、12、13,这些只是为了跟踪,不用担心。

4

1 回答 1

3

我建议这是你的问题

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

您正在向JScrollBar组合框项目列表中添加一个...

于 2013-07-19T07:52:39.450 回答