我得到了一个名为DoctorsCare的项目,其中你有一个登录窗口和一个带有3个标签的窗口(预订,医生屏幕,注册)这个程序的目的是让患者预约并让医生知道他们的名字,身份证和其他信息。问题是我无法弄清楚如何将类别BookingPage中的arraylist值移动到医生屏幕选项卡。
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class NextPage extends JFrame implements ActionListener{
NextPage()
{
JTabbedPane tabbedPane1 = new JTabbedPane();
JLabel label = new JLabel();
JTextArea txt = new JTextArea(10,20);
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
tabbedPane1.add("booking",panel1);
tabbedPane1.add("Doctors Screen",panel2);
tabbedPane1.add("Register",panel3);
JFrame frame = new JFrame();
frame.add(tabbedPane1);
frame.setSize(600, 500);
frame.setTitle("Welcome to DoctorsCare");
frame.setVisible(true);
JButton button = new JButton();
button.setLabel("Take Appointment");
button.setPreferredSize(new Dimension(160,40));
panel1.add(button);
JButton button2 = new JButton();
button2.setLabel("Cancel Appointment");
button2.setPreferredSize(new Dimension(160,40));
panel1.add(button2);
button.addActionListener(this);
panel2.add(txt);
DoctorsScreen dscrn = new DoctorsScreen();
}
public void actionPerformed(ActionEvent ae)
{
BookingPage page = new BookingPage();
}
}
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.Normalizer.Form;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.*;
public class BookingPage extends JFrame implements ActionListener{
//public static ArrayList<List<String>> model = new ArrayList<List<String>>();
JFrame frame1= new JFrame();
JTextField id;
JLabel label = new JLabel("Patient ID:");
JLabel label2 = new JLabel("Name:");
JLabel label3 = new JLabel("Gender:");
JLabel label4 = new JLabel("Date of Birth:");
JLabel label5 = new JLabel("Address:");
JLabel label7 = new JLabel("Phone:");
JLabel label6= new JLabel("brief patient history:");
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JTextArea phistry = new JTextArea(11,31);
JTextField text1 = new JTextField(20);
JTextField text2 = new JTextField(20);
JTextField text3 = new JTextField(20);
JTextField text4 = new JTextField(20);
JTextField text5 = new JTextField(20);
JTextField text6 = new JTextField(20);
JTextField text7 = new JTextField(20);
JButton button = new JButton("SUBMIT");
BookingPage()
{
frame1.setTitle("Booking Appointment");
frame1.setVisible(true);
frame1.setSize(600,400);
frame1.add(panel1);
panel1.add(label);
panel1.add(text1);
panel1.add(label2);
panel1.add(text2);
panel1.add(label3);
panel1.add(text3);
panel1.add(label4);
panel1.add(text4);
panel1.add(label5);
panel1.add(text5);
panel1.add(label7);
panel1.add(text7);
panel1.add(label6);
panel1.add(phistry);
panel1.add(button);
button.setPreferredSize(new Dimension(160,40));
button.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
PatientInfo info = new PatientInfo();
info.setPName(text2.getText());
info.setID(text1.getText());
info.setGender(text3.getText());
info.setDoB(text4.getText());
info.setAddress(text5.getText());
info.setphistry(text6.getText());
info.pRefList.add(info);
DoctorsScreen dscrn = new DoctorsScreen();
JOptionPane.showMessageDialog(null, new PatientInfo().pRefList.get(0).getPName());
JOptionPane.showMessageDialog(null, new PatientInfo().pRefList.get(0).getID());
JOptionPane.showMessageDialog(null, new PatientInfo().pRefList.get(0).getGender());
JOptionPane.showMessageDialog(null, new PatientInfo().pRefList.get(0).getDoB());
JOptionPane.showMessageDialog(null, new PatientInfo().pRefList.get(0).getAddress());
JOptionPane.showMessageDialog(null, new PatientInfo().pRefList.get(0).getphistry());
}
;}
import java.util.ArrayList;
public class PatientInfo {
private String ID ;
private String PName;
private String Gender;
private String DoB;
private String Address;
private String phistry;
public static ArrayList<PatientInfo> pRefList = new ArrayList<>();
public String getID()
{
return this.ID;
}
public String getPName()
{
return this.PName;
}
public String getGender()
{
return this.Gender;
}
public String getDoB()
{
return this.DoB;
}
public String getAddress()
{
return this.Address;
}
public String getphistry()
{
return this.phistry;
}
public void setID(String ID)
{
this.ID = ID;
}
public void setPName(String PName)
{
this.PName = PName;
}
public void setGender(String Gender)
{
this.Gender = Gender;
}
public void setDoB(String DoB)
{
this.DoB = DoB;
}
public void setAddress(String Address)
{
this.Address = Address;
}
public void setphistry(String phistry)
{
this.phistry = phistry;
}
public static int size(int size) {
// TODO Auto-generated method stub
size=7;
return 0;
}
}