Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import javax.swing.Box;
- import javax.swing.BoxLayout;
- import javax.swing.JButton;
- import javax.swing.JDialog;
- import javax.swing.JFrame;
- import javax.swing.JTextField;
- class AboutDialog extends JDialog {
- private JTextField text;
- public AboutDialog() {
- initUI();
- }
- public final void initUI() {
- setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
- add(Box.createRigidArea(new Dimension(0, 10)));
- text = new JTextField("user enter text");
- add(text);
- add(Box.createRigidArea(new Dimension(0, 50)));
- JButton close = new JButton("Close");
- close.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- SimpleCustomDialog.data.setPatientNameOList(text.getText());
- dispose();
- }
- });
- close.setAlignmentX(0.5f);
- add(close);
- setModalityType(ModalityType.APPLICATION_MODAL);
- setTitle("About Notes");
- setLocationRelativeTo(null);
- setSize(300, 200);
- }
- }
- public class SimpleCustomDialog extends JFrame implements ActionListener {
- JButton dialog;
- private static final long serialVersionUID = 1L;
- public static SearchData data;
- public SimpleCustomDialog() {
- data = new SearchData();
- initUI();
- }
- public final void initUI() {
- dialog = new JButton("Open dialog");
- dialog.addActionListener(this);
- add(Box.createRigidArea(new Dimension(0, 50)));
- this.add(dialog);
- setTitle("Simple Dialog");
- setSize(300, 200);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- }
- public static void main(String[] args) {
- SimpleCustomDialog sd = new SimpleCustomDialog();
- sd.setVisible(true);
- }
- public void actionPerformed(ActionEvent e) {
- AboutDialog ad = new AboutDialog();
- ad.addWindowListener(new WindowAdapter() {
- public void windowClosed(WindowEvent e) {
- dialog.setText("Name of user : "+SimpleCustomDialog.data.getPatientNameOList());
- }
- });
- ad.setVisible(true);
- }
- }
- class SearchData{
- private String patientNameOList;
- private String raceOList;
- public String getPatientNameOList(){
- return patientNameOList;
- }
- public void setPatientNameOList(String patientNameOList){
- this.patientNameOList = patientNameOList;
- }
- public String getRaceOList(){
- return raceOList;
- }
- public void setRaceOList(String raceOList){
- this.raceOList = raceOList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement