Java 在JComboBox中选择不同选项时是否覆盖JLabel?
我有一个JComboBox,可以从数据库(Ahmed、Mahmoud、Ali)检索数据 当我选择第一个选项时,它会显示我从数据库检索到的Ahmed信息,并在JFrame中显示为JLabels的文本 问题是,当我选择第二个选项时,它会用马哈茂德的信息覆盖艾哈迈德的信息,并显示在上面Java 在JComboBox中选择不同选项时是否覆盖JLabel?,java,swing,combobox,Java,Swing,Combobox,我有一个JComboBox,可以从数据库(Ahmed、Mahmoud、Ali)检索数据 当我选择第一个选项时,它会显示我从数据库检索到的Ahmed信息,并在JFrame中显示为JLabels的文本 问题是,当我选择第二个选项时,它会用马哈茂德的信息覆盖艾哈迈德的信息,并显示在上面 JPanel calendarPanel = new JPanel(); calendarPanel.setToolTipText(""); calendarPanel.setBorder(ne
JPanel calendarPanel = new JPanel();
calendarPanel.setToolTipText("");
calendarPanel.setBorder(new TitledBorder(null, "Calendar Panel", TitledBorder.LEADING, TitledBorder.TOP, null, null));
calendarPanel.setBounds(12, 13, 878, 254);
frameDetails.getContentPane().add(calendarPanel);
calendarPanel.setLayout(null);
JLabel lblSat = new JLabel("Saturday");
lblSat.setBounds(12, 70, 56, 16);
calendarPanel.add(lblSat);
JLabel lblSun = new JLabel("Sunday");
lblSun.setBounds(12, 99, 56, 16);
calendarPanel.add(lblSun);
JLabel lblMon = new JLabel("Monday");
lblMon.setBounds(12, 128, 56, 16);
calendarPanel.add(lblMon);
JLabel lblTus = new JLabel("Tuesday");
lblTus.setBounds(12, 157, 56, 16);
calendarPanel.add(lblTus);
JLabel lblWes = new JLabel("Wednesday");
lblWes.setBounds(12, 187, 77, 16);
calendarPanel.add(lblWes);
JLabel lblThur = new JLabel("Thursday");
lblThur.setBounds(12, 217, 56, 16);
calendarPanel.add(lblThur);
JPanel panel_12 = new JPanel();
String statment12 = "select f310t410 from calendar where days='saturday'";
panelColorChanger(panel_12, statment12);
panel_12.setForeground(Color.LIGHT_GRAY);
panel_12.setBounds(144, 64, 90, 21);
calendarPanel.add(panel_12);
JPanel panel_14 = new JPanel();
String statment14 = "select f420t520 from calendar where days='saturday'";
panelColorChanger(panel_14, statment14);
panel_14.setForeground(Color.LIGHT_GRAY);
panel_14.setBounds(300, 64, 90, 21);
calendarPanel.add(panel_14);
String statment16 = "select f530t630 from calendar where days='saturday'";
String statment18 = "select f640t740 from calendar where days='saturday'";
String statment110 = "select f750t850 from calendar where days='saturday'";
JPanel panel_22 = new JPanel();
panel_22.setForeground(Color.LIGHT_GRAY);
String statment22 = "select f310t410 from calendar where days='sunday'";
panelColorChanger(panel_22, statment22);
panel_22.setBounds(145, 92, 90, 24);
calendarPanel.add(panel_22);
JPanel panel_24 = new JPanel();
panel_24.setForeground(Color.LIGHT_GRAY);
String statment24 = "select f420t520 from calendar where days='sunday'";
panelColorChanger(panel_24, statment24);
panel_24.setBounds(301, 92, 90, 24);
calendarPanel.add(panel_24);
String statment26 = "select f530t630 from calendar where days='sunday'";
String statment28 = "select f640t740 from calendar where days='sunday'";
String statment210 = "select f750t850 from calendar where days='sunday'";
JPanel panel_32 = new JPanel();
panel_32.setForeground(Color.LIGHT_GRAY);
String statment32 = "select f310t410 from calendar where days='monday'";
panelColorChanger(panel_32, statment32);
panel_32.setBounds(145, 122, 90, 22);
calendarPanel.add(panel_32);
JPanel panel_34 = new JPanel();
panel_34.setForeground(Color.LIGHT_GRAY);
String statment34 = "select f420t520 from calendar where days='monday'";
panelColorChanger(panel_34, statment34);
panel_34.setBounds(301, 122, 90, 22);
calendarPanel.add(panel_34);
String statment36 = "select f530t630 from calendar where days='monday'";
String statment38 = "select f640t740 from calendar where days='monday'";
String statment310 = "select f750t850 from calendar where days='monday'";
JPanel panel_42 = new JPanel();
panel_42.setForeground(Color.LIGHT_GRAY);
String statment42 = "select f310t410 from calendar where days='tuesday'";
panelColorChanger(panel_42, statment42);
panel_42.setBounds(145, 149, 90, 23);
calendarPanel.add(panel_42);
JPanel panel_44 = new JPanel();
panel_44.setForeground(Color.LIGHT_GRAY);
String statment44 = "select f420t520 from calendar where days='tuesday'";
panelColorChanger(panel_44, statment44);
panel_44.setBounds(301, 149, 90, 23);
calendarPanel.add(panel_44);
String statment46 = "select f530t630 from calendar where days='tuesday'";
String statment48 = "select f640t740 from calendar where days='tuesday'";
String statment410 = "select f750t850 from calendar where days='tuesday'";
JPanel panel_52 = new JPanel();
panel_52.setForeground(Color.LIGHT_GRAY);
String statment52 = "select f310t410 from calendar where days='wednesday'";
panelColorChanger(panel_52, statment52);
panel_52.setBounds(145, 179, 90, 25);
calendarPanel.add(panel_52);
JPanel panel_54 = new JPanel();
panel_54.setForeground(Color.LIGHT_GRAY);
String statment54 = "select f420t520 from calendar where days='wednesday'";
panelColorChanger(panel_54, statment54);
panel_54.setBounds(301, 179, 90, 25);
calendarPanel.add(panel_54);
String statment56 = "select f530t630 from calendar where days='wednesday'";
String statment58 = "select f640t740 from calendar where days='wednesday'";
String statment510 = "select f750t850 from calendar where days='wednesday'";
JPanel panel_62 = new JPanel();
panel_62.setForeground(Color.LIGHT_GRAY);
String statment62 = "select f310t410 from calendar where days='thursday'";
panelColorChanger(panel_62, statment62);
panel_62.setBounds(145, 209, 90, 24);
calendarPanel.add(panel_62);
JPanel panel_64 = new JPanel();
panel_64.setForeground(Color.LIGHT_GRAY);
String statment64 = "select f420t520 from calendar where days='thursday'";
panelColorChanger(panel_64, statment64);
panel_64.setBounds(301, 209, 90, 24);
calendarPanel.add(panel_64);
String statment66 = "select f530t630 from calendar where days='thursday'";
String statment68 = "select f640t740 from calendar where days='thursday'";
String statment610 = "select f750t850 from calendar where days='thursday'";
////////////////////////////////////////////////////////////////////////////////Calendar Table
////////////////////////////////////////////////////////////////////////////////Add Patient
patientPanel = new JPanel();
patientPanel.setLayout(null);
patientPanel.setBorder(new TitledBorder(null, "Add New Patient", TitledBorder.LEADING, TitledBorder.TOP, null, null));
patientPanel.setBounds(12, 280, 1304, 163);
frameDetails.getContentPane().add(patientPanel);
lblName = new JLabel("Name");
lblName.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblName.setBounds(31, 24, 56, 16);
patientPanel.add(lblName);
txtName = new JTextField();
txtName.setBounds(120, 24, 240, 22);
patientPanel.add(txtName);
txtName.setColumns(10);
lblAge = new JLabel("Age");
lblAge.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblAge.setBounds(31, 59, 56, 23);
patientPanel.add(lblAge);
lblMobile = new JLabel("Mobile");
lblMobile.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblMobile.setBounds(31, 95, 56, 16);
patientPanel.add(lblMobile);
txtAge = new JTextField();
txtAge.setColumns(10);
txtAge.setBounds(120, 59, 240, 22);
patientPanel.add(txtAge);
txtMobile = new JTextField();
txtMobile.setColumns(10);
txtMobile.setBounds(120, 95, 240, 22);
patientPanel.add(txtMobile);
JComboBox comboBoxDays = new JComboBox();
List<String> arrDays = new ArrayList<String>();
//arrDays.add("44444444");
//comboBoxDays.setModel(new DefaultComboBoxModel(arrDays.toArray()));
comboBoxDays.setBounds(474, 24, 127, 22);
patientPanel.add(comboBoxDays);
JComboBox comboBoxTime = new JComboBox();
List<String> arrTime = new ArrayList<String>();
arrTime.add("");
comboBoxTime.setModel(new DefaultComboBoxModel(arrTime.toArray()));
// add time available to list of times when select a day
comboBoxDays.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
});
comboBoxTime.setBounds(474, 61, 127, 22);
patientPanel.add(comboBoxTime);
JLabel lblDay = new JLabel("Day");
lblDay.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblDay.setBounds(389, 27, 56, 16);
patientPanel.add(lblDay);
JLabel lblTime = new JLabel("Time");
lblTime.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblTime.setBounds(389, 64, 56, 16);
patientPanel.add(lblTime);
JLabel lblDescription = new JLabel("Description");
lblDescription.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblDescription.setBounds(31, 132, 77, 22);
patientPanel.add(lblDescription);
txtDescription = new JTextField();
txtDescription.setColumns(10);
txtDescription.setBounds(120, 132, 240, 22);
patientPanel.add(txtDescription);
JButton btnAddNewPatient = new JButton("Add New Patient");
btnAddNewPatient.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String radioText = "Not Confirmed";
try {
if (txtName.getText().isEmpty() || txtAge.getText().isEmpty() || txtMobile.getText().isEmpty() || txtDescription.getText().isEmpty() || comboBoxDays.getSelectedItem().toString().isEmpty() || comboBoxTime.getSelectedItem().toString().isEmpty())
{
JOptionPane.showMessageDialog(null, "Please fill empty fields!");
}
else {
//to insert the patient name with his time into table patientCalender
String statInsertPatient = "insert into patientCalendar values ('"+txtName.getText()+"','"+comboBoxDays.getSelectedItem().toString()+"','"+comboBoxTime.getSelectedItem().toString()+"')";
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnAddNewPatient.setBounds(630, 24, 194, 58);
patientPanel.add(btnAddNewPatient);
////////////////////////////////////////////////////////////////////////////////Add Patient
////////////////////////////////////////////////////////////////////////////////Details table
detailsPanel = new JPanel();
detailsPanel.setLayout(null);
detailsPanel.setToolTipText("");
detailsPanel.setBorder(new TitledBorder(null, "Details", TitledBorder.LEADING, TitledBorder.TOP, null, null));
detailsPanel.setBounds(12, 456, 1304, 252);
frameDetails.getContentPane().add(detailsPanel);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(12, 32, 940, 207);
detailsPanel.add(scrollPane);
detailsTable = new JTable();
scrollPane.setViewportView(detailsTable);
detailsTable.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
}
));
detailsTable.setBorder(new LineBorder(new Color(0, 0, 0)));
textFieldSearch = new JTextField();
textFieldSearch.setToolTipText("Enter Patient Name");
textFieldSearch.setBounds(1034, 45, 179, 29);
detailsPanel.add(textFieldSearch);
textFieldSearch.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent arg0) {
}
}
);
textFieldSearch.setColumns(10);
JButton btnDelete = new JButton("Delete");
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String query = "delete from patient where name='"+textFieldSearch.getText() +"' ";
PreparedStatement pst= connection.prepareStatement(query);
pst.execute();
JOptionPane.showMessageDialog(null , "Deleted ");
pst.close();
} catch(Exception e1) {
e1.printStackTrace();
}
}
}
);
btnDelete.setBounds(1065, 133, 116, 40);
detailsPanel.add(btnDelete);
JButton btnShow = new JButton("Show All");
btnShow.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
String query = "select * from patient ";
PreparedStatement pst= connection.prepareStatement(query);
ResultSet rs = pst.executeQuery();
detailsTable.setModel(DbUtils.resultSetToTableModel(rs));
} catch(Exception el) {
el.printStackTrace();
}
}
});
btnShow.setBounds(1065, 178, 116, 42);
detailsPanel.add(btnShow);
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
String query = "select * from patient where name=?";
PreparedStatement pst= connection.prepareStatement(query);
pst.setString(1, textFieldSearch.getText() );
ResultSet rs = pst.executeQuery();
detailsTable.setModel(DbUtils.resultSetToTableModel(rs));
pst.close();
} catch(Exception e1) {
e1.printStackTrace();
}
}
});
btnSearch.setBounds(1065, 87, 116, 40);
detailsPanel.add(btnSearch);
////////////////////////////////////////////////////////////////////////////////Details table
////////////////////////////////////////////////////////////////////////////////Set Calendar
JPanel setCalendarPanel = new JPanel();
setCalendarPanel.setBorder(new TitledBorder(null, "Set Calender Days", TitledBorder.LEADING, TitledBorder.TOP, null, null));
setCalendarPanel.setBounds(902, 24, 260, 243);
frameDetails.getContentPane().add(setCalendarPanel);
setCalendarPanel.setLayout(null);
chckbxSaturday = new JCheckBox("Saturday");
chckbxSaturday.setBounds(8, 54, 160, 25);
setCalendarPanel.add(chckbxSaturday);
chckbxSunday = new JCheckBox("Sunday");
chckbxSunday.setBounds(8, 84, 160, 25);
setCalendarPanel.add(chckbxSunday);
chckbxMonday = new JCheckBox("Monday");
chckbxMonday.setBounds(8, 116, 160, 25);
setCalendarPanel.add(chckbxMonday);
chckbxTuesday = new JCheckBox("Tuesday");
chckbxTuesday.setBounds(8, 146, 160, 25);
setCalendarPanel.add(chckbxTuesday);
chckbxWednesday = new JCheckBox("Wednesday");
chckbxWednesday.setBounds(8, 178, 160, 25);
setCalendarPanel.add(chckbxWednesday);
chckbxThursday = new JCheckBox("Thursday");
chckbxThursday.setBounds(8, 209, 87, 25);
setCalendarPanel.add(chckbxThursday);
JLabel lblPleaseSelectAvailable = new JLabel("Please select available days: ");
lblPleaseSelectAvailable.setFont(new Font("Tahoma", Font.BOLD, 16));
lblPleaseSelectAvailable.setBounds(8, 19, 239, 37);
setCalendarPanel.add(lblPleaseSelectAvailable);
//////////////////////////////////
//Set selected days on launch to add the selected days to comboBoxDays
String sqlquery11 = "select f310t410 from calendar WHERE calendar.days='saturday'";
String panelColor11= connect2databaseWithexecuteQuery(sqlquery11);
if (panelColor11.contentEquals("white") || panelColor11.contentEquals("green") || panelColor11.contentEquals("red")){
chckbxSaturday.setSelected(true);
}
String sqlquery22 = "select f310t410 from calendar WHERE calendar.days='sunday'";
String panelColor22= connect2databaseWithexecuteQuery(sqlquery22);
if (panelColor22.contentEquals("white") || panelColor22.contentEquals("green") || panelColor22.contentEquals("red"))
{
chckbxSunday.setSelected(true);
}
String sqlquery33 = "select f310t410 from calendar WHERE calendar.days='monday'";
String panelColor33= connect2databaseWithexecuteQuery(sqlquery33);
if (panelColor33.contentEquals("white") || panelColor33.contentEquals("green") || panelColor33.contentEquals("red"))
{
chckbxMonday.setSelected(true);
}
String sqlquery44 = "select f310t410 from calendar WHERE calendar.days='tuesday'";
String panelColor44= connect2databaseWithexecuteQuery(sqlquery44);
if (panelColor44.contentEquals("white") || panelColor44.contentEquals("green") || panelColor44.contentEquals("red"))
{
chckbxTuesday.setSelected(true);
}
String sqlquery55 = "select f310t410 from calendar WHERE calendar.days='wednesday'";
String panelColor55= connect2databaseWithexecuteQuery(sqlquery55);
if (panelColor55.contentEquals("white") || panelColor55.contentEquals("green") || panelColor55.contentEquals("red"))
{
chckbxWednesday.setSelected(true);
}
String sqlquery66 = "select f310t410 from calendar WHERE calendar.days='thursday'";
String panelColor66= connect2databaseWithexecuteQuery(sqlquery66);
if (panelColor66.contentEquals("white") || panelColor66.contentEquals("green") || panelColor66.contentEquals("red")){
chckbxThursday.setSelected(true);
}
///***************
//check if checkboxes selected to add their text to comboBoxDays
arrDays.add("");
if (chckbxSaturday.isSelected()){
arrDays.add("Saturday");
}
if (chckbxSunday.isSelected()){
arrDays.add("Sunday");
}
if (chckbxMonday.isSelected()){
arrDays.add("Monday");
}
if (chckbxTuesday.isSelected()){
arrDays.add("Tuesday");
}
if (chckbxWednesday.isSelected()){
arrDays.add("Wednesday");
}
if (chckbxThursday.isSelected()){
arrDays.add("Thursday");
}
comboBoxDays.setModel(new DefaultComboBoxModel(arrDays.toArray()));
JButton btnUpdatePatientStatus = new JButton("Update Patient Status");
btnUpdatePatientStatus.setBounds(843, 21, 194, 58);
patientPanel.add(btnUpdatePatientStatus);
////////////////////////////////
JButton btnSetCalender = new JButton("Set Calender"); // Button Set Calendar
btnSetCalender.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (chckbxSaturday.isSelected()){
//access database
//make colms of Saturday all white
if(arrDays.contains("Saturday") == false){
arrDays.add("Saturday");
}
}
else
{
//access database
//make colms of Saturday all gray
if(arrDays.contains("Saturday") == true){
arrDays.remove("Saturday");
}
}
if (chckbxSunday.isSelected()){
//access database
//make colms of Sunday all white
if(arrDays.contains("Sunday") == false){
arrDays.add("Sunday");
}
}
else
{
//access database
//make colms of Sunday all gray
if(arrDays.contains("Sunday") == true){
arrDays.remove("Sunday");
}
}
if (chckbxMonday.isSelected()){
//access database
//make colms of Monday all white
if(arrDays.contains("Monday") == false){
arrDays.add("Monday");
}
}
else
{
//access database
//make colms of Monday all gray
if(arrDays.contains("Monday") == true){
arrDays.remove("Monday");
}
}
if (chckbxTuesday.isSelected()){
//access database
//make colms of Tuesday all white
if(arrDays.contains("Tuesday") == false){
arrDays.add("Tuesday");
}
}
else
{
//access database
//make colms of Tuesday all gray
if(arrDays.contains("Tuesday") == true){
arrDays.remove("Tuesday");
}
}
if (chckbxWednesday.isSelected()){
//access database
//make colms of Wednesday all white
if(arrDays.contains("Wednesday") == false){
arrDays.add("Wednesday");
}
}
else
{
//access database
//make colms of Wednesday all gray
if(arrDays.contains("Wednesday") == true){
arrDays.remove("Wednesday");
}
}
if (chckbxThursday.isSelected()){
//access database
//make colms of Thursday all white
if(arrDays.contains("Thursday") == false){
arrDays.add("Thursday");
}
}
else
{
//access database
//make colms of Thursday all gray
if(arrDays.contains("Thursday") == true){
arrDays.remove("Thursday");
}
}
comboBoxDays.setModel(new DefaultComboBoxModel(arrDays.toArray())); //Days ComboBox
JOptionPane.showMessageDialog(null, "Calendar Set Successfully!","Calender Set",JOptionPane.DEFAULT_OPTION);
}
});
btnSetCalender.setBounds(104, 203, 146, 37);
setCalendarPanel.add(btnSetCalender);
///////////////////////////////////////////////////////////////////////////////////////////Add Doctor
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(null, "Add/Choose Doctor", TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel.setBounds(1174, 24, 162, 241);
frameDetails.getContentPane().add(panel);
panel.setLayout(null);
comboBoxDoctorsNames = new JComboBox();
arrDoctors = new ArrayList<String>();
arrDoctors.add("");
arrDoctors.addAll(getMultiDocsNames());
System.out.println(getMultiDocsNames());
comboBoxDoctorsNames.setModel(new DefaultComboBoxModel(arrDoctors.toArray()));
comboBoxDoctorsNames.setBounds(12, 49, 138, 22);
panel.add(comboBoxDoctorsNames);
comboBoxDoctorsNames.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String selectedDoctor = comboBoxDoctorsNames.getSelectedItem().toString();
String query = "select * from '"+selectedDoctor+"'";
List<String> arrColms = new ArrayList<String>();
List<JLabel> arrLbls = new ArrayList<JLabel>();
int boundTimelbl = 162;
try {
//access the table and get colms names
Connection con = DriverManager.getConnection("jdbc:sqlite:DoctorProject.db");
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
// The column count starts from 1
for (int i = 2; i <= columnCount; i++ ) {
String name = rsmd.getColumnName(i);
// Do stuff with name
if(arrColms.contains(name) == false){
arrColms.add(name);
}
}
for (String colm : arrColms) {
mTimelbl = new JLabel();
mTimelbl.setText(colm);
mTimelbl.setBounds(boundTimelbl, 35, 56, 16);
boundTimelbl = boundTimelbl + 156;
arrLbls.add(mTimelbl);
}
Component[] components = calendarPanel.getComponents();
for (Component component : components) {
if (component instanceof JLabel) {
jPanel1.remove(component);
}
}
for (JLabel mLbl : arrLbls) {
calendarPanel.add(mLbl);
}
calendarPanel.revalidate();
calendarPanel.repaint();
System.out.println(arrColms);
con.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
JPanel calendarPanel=newjpanel();
calendarPanel.setToolTipText(“”);
calendarPanel.setBorder(新标题边框(null,“日历面板”,标题边框.LEADING,标题边框.TOP,null,null));
日历面板.立根(12,13878254);
frameDetails.getContentPane().add(calendarPanel);
calendarPanel.setLayout(空);
JLabel lblSat=新JLabel(“星期六”);
lblSat.立根(12,70,56,16);
calendarPanel.add(lblSat);
JLabel lblSun=新JLabel(“星期日”);
lblSun.挫折(12,99,56,16);
calendarPanel.add(lblSun);
JLabel lblMon=新JLabel(“周一”);
lblMon.立根(12,128,56,16);
calendarPanel.add(lblMon);
JLabel lblTus=新JLabel(“星期二”);
立根数(12,157,56,16);
calendarPanel.add(lblTus);
JLabel lblWes=新JLabel(“星期三”);
lblWes.立根(12187,77,16);
calendarPanel.add(lblWes);
JLabel lblThur=新JLabel(“星期四”);
lblThur.挫折(12,217,56,16);
calendarPanel.add(lblThur);
JPanel panel_12=新的JPanel();
String station12=“从日历中选择f310t410,其中日期为“星期六”;
面板颜色变换器(面板12,状态12);
面板12.设置前景(颜色:浅灰色);
面板12.立根(144、64、90、21);
calendarPanel.add(面板12);
JPanel panel_14=新的JPanel();
String station14=“从日历中选择f420t520,其中日期为“星期六”;
面板颜色变换器(面板14,状态14);
面板14.设置前景(颜色:浅灰色);
面板14.立根(300、64、90、21);
calendarPanel.add(面板14);
String station16=“从日历中选择f530t630,其中日期为“星期六”;
String station18=“从日历中选择f640t740,其中日期为“星期六”;
String station110=“从日历中选择f750t850,其中天为=“星期六”;
JPanel panel_22=新的JPanel();
面板22.设置前景(颜色:浅灰色);
String station22=“从日历中选择f310t410,其中天为周日”;
面板颜色变换器(面板22,状态22);
专家组22.立根(145、92、90、24);
calendarPanel.add(面板22);
JPanel panel_24=新的JPanel();
面板24.设置前景(颜色:浅灰色);
String station24=“从日历中选择f420t520,其中天为周日”;
面板颜色变换器(面板24,状态24);
面板24.立根(301、92、90、24);
calendarPanel.add(面板24);
String station26=“从日历中选择f530t630,其中日期为“星期日”;
String station28=“从日历中选择f640t740,其中天为“星期日”;
String station210=“从日历中选择f750t850,其中天为周日”;
JPanel panel_32=新的JPanel();
面板32.设置前景(颜色:浅灰色);
String stat32=“从日历中选择f310t410,其中日期为“星期一”;
面板颜色变换器(面板32,状态32);
小组32.立根(145、122、90、22);
calendarPanel.add(面板32);
JPanel panel_34=新的JPanel();
面板34.设置前景(颜色:浅灰色);
String station34=“从日历中选择f420t520,其中日期为“星期一”;
面板颜色变换器(面板34,状态34);
34.立根(301、122、90、22);
calendarPanel.add(面板34);
String station36=“从日历中选择f530t630,其中日期为“星期一”;
String station38=“从日历中选择f640t740,其中日期为“星期一”;
String station310=“从日历中选择f750t850,其中天为“星期一”;
JPanel panel_42=新的JPanel();
面板42.设置前景(颜色:浅灰色);
String station42=“从日历中选择f310t410,其中日期为“星期二”;
面板颜色变换器(面板42,状态42);
小组42.立根(145、149、90、23);
calendarPanel.add(面板42);
JPanel panel_44=新的JPanel();
面板44.设置前景(颜色:浅灰色);
String station44=“从日历中选择f420t520,其中日期为“星期二”;
面板颜色变换器(面板44,状态44);
专家组44.立根(301、149、90、23);
calendarPanel.add(面板44);
String station46=“从日历中选择f530t630,其中日期为“星期二”;
String station48=“从日历中选择f640t740,其中日期为“星期二”;
String Station410=“从日历中选择f750t850,其中天为“星期二”;
JPanel panel_52=新的JPanel();
面板52.设置前景(颜色:浅灰色);
String station52=“从日历中选择f310t410,其中日期为“星期三”;
面板颜色变换器(面板52,状态52);
小组52.立根(145、179、90、25);
calendarPanel.add(面板52);
JPanel panel_54=新的JPanel();
面板54.设置前景(颜色:浅灰色);
String station54=“从日历中选择f420t520,其中日期为“星期三”;
面板颜色变换器(面板54,状态54);
专家组54.立根(301、179、90、25);
日历面板。添加(面板_54);
String station56=“从日历中选择f530t630,其中日期为“星期三”;
String station58=“从日历中选择f640t740,其中日期为“星期三”;
String station510=“从日历中选择f750t850,其中日期=”星期三“;
JPanel panel_62=新的JPanel();
面板62.设置前景(颜色:浅灰色);
String Station62=“从日历中选择f310t410,其中日期为“星期四”;
面板颜色变换器(面板U 62,状态62);
专家组62.立根(145、209、90、24);
calendarPanel.add(面板_62);
JPanel panel_64=新的JPanel();
面板64.设置前景(颜色:浅灰色);
String station64=“从日历中选择f420t520,其中日期为“星期四”;
面板颜色变换器(面板64,Station64);
小组64.立根(301、209、90、24);
卡尔
for (JLabel mLbl : arrLbls) {
calendarPanel.add(mLbl);
}
Component[] components = calendarPanel.getComponents();
for (Component component : components) {
if (component instanceof JLabel) {
calendarPanel.remove(component);
}
}
for (JLabel mLbl : arrLbls) {
calendarPanel.add(mLbl);
}
private final List<JLabel> myPreviousAddedLabels = new ArrayList<JLabel>();
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String selectedDoctor = comboBoxDoctorsNames.getSelectedItem().toString();
for (JLabel component : myPreviousAddedLabels) {
calendarPanel.remove(component);
}
myPreviousAddedLabels.clear();
for (JLabel mLbl : arrLbls) {
myPreviousAddedLabels.add(mLbl);
calendarPanel.add(mLbl);
}
calendarPanel.revalidate();
calendarPanel.repaint();