mohd fuad
asked on
i want too move arraylist values from 1 tab( bookingpage) to another tab( doctorsScreen).
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Frame;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListe ner;
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(ne w Dimension(160,40));
panel1.add(button);
JButton button2 = new JButton();
button2.setLabel("Cancel Appointment");
button2.setPreferredSize(n ew Dimension(160,40));
panel1.add(button2);
button.addActionListener(t his);
panel2.add(txt);
DoctorsScreen dscrn = new DoctorsScreen();
}
public void actionPerformed(ActionEven t ae)
{
BookingPage page = new BookingPage();
}
}
import java.awt.Dimension;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListe ner;
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(ne w Dimension(160,40));
button.addActionListener(t his);
}
public void actionPerformed(ActionEven t e) {
PatientInfo info = new PatientInfo();
info.setPName(text2.getTex t());
info.setID(text1.getText() );
info.setGender(text3.getTe xt());
info.setDoB(text4.getText( ));
info.setAddress(text5.getT ext());
info.setphistry(text6.getT ext());
info.pRefList.add(info);
DoctorsScreen dscrn = new DoctorsScreen();
JOptionPane.showMessageDia log(null, new PatientInfo().pRefList.get (0).getPNa me());
JOptionPane.showMessageDia log(null, new PatientInfo().pRefList.get (0).getID( ));
JOptionPane.showMessageDia log(null, new PatientInfo().pRefList.get (0).getGen der());
JOptionPane.showMessageDia log(null, new PatientInfo().pRefList.get (0).getDoB ());
JOptionPane.showMessageDia log(null, new PatientInfo().pRefList.get (0).getAdd ress());
JOptionPane.showMessageDia log(null, new PatientInfo().pRefList.get (0).getphi stry());
}
;}
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;
}
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Frame;
import java.awt.event.ActionEvent
import java.awt.event.ActionListe
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",
tabbedPane1.add("Doctors Screen",panel2);
tabbedPane1.add("Register"
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(ne
panel1.add(button);
JButton button2 = new JButton();
button2.setLabel("Cancel Appointment");
button2.setPreferredSize(n
panel1.add(button2);
button.addActionListener(t
panel2.add(txt);
DoctorsScreen dscrn = new DoctorsScreen();
}
public void actionPerformed(ActionEven
{
BookingPage page = new BookingPage();
}
}
import java.awt.Dimension;
import java.awt.event.ActionEvent
import java.awt.event.ActionListe
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(ne
button.addActionListener(t
}
public void actionPerformed(ActionEven
PatientInfo info = new PatientInfo();
info.setPName(text2.getTex
info.setID(text1.getText()
info.setGender(text3.getTe
info.setDoB(text4.getText(
info.setAddress(text5.getT
info.setphistry(text6.getT
info.pRefList.add(info);
DoctorsScreen dscrn = new DoctorsScreen();
JOptionPane.showMessageDia
JOptionPane.showMessageDia
JOptionPane.showMessageDia
JOptionPane.showMessageDia
JOptionPane.showMessageDia
JOptionPane.showMessageDia
}
;}
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;
}
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Your code should go into code tags on this site.