Results 1 to 10 of 10
  1. #1
    dem125 is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default Passing a date value from one JPanel to another

    Hi guys.. I'm kinda new to Java. I need some help with this..

    I have to JPanel applications - a main application and a interactive calendar. both are done using SWING and JPanel. I need to select a date from the calendar and place it in the main app.

    JCalendar Class
    JButton selectedOKButton = new JButton("OK");
    selectedOKButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    OKActionPerformed(evt);
    }
    });

    void OKActionPerformed(ActionEvent evt)
    {
    DCard24Main dc24m = new DCard24Main();
    dc24m.getDOADate(outputTextArea.getText());
    }

    Main class
    void getDOADate(String string) {
    doa.setText(string);
    }

    thank you!

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    I can't tell what you are doing from the bit of code you posted, but I can give you some general advice.
    The Model-View-Controller paradigm (MVC) says that your code should be broken into three groups.
    1. The model contains the "business logic" of the application.
    2. The controller contains the process flow logic of the application.
    3. The view contains the GUI logic of the application. Each major piece of the GUI should be in its own class.

    Your application consists of two major view pieces, the main screen and the calendar. Put them in separate classes.
    Create a separate controller class. The controller class should contain the main() method and create the view and model classes. Then, the controller logic should handle populating the data of the view classes and the events generated by the GUI classes.
    Specifically, the controller should move the date from the calendar JPanel to the main JPanel.
    If the calendar is a separate utility application, create a model, view, and controller just for it.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Your basically trying to pass information between two objects, and it's done in GUIs the same ways that it's done in non-GUI code. I'd give the class that shows the calendar a public method called getDate that returns the date that it is currently holding. I'd then have the main class call this method when it needs the date from the first class. When it calls the method will depend. If the first class's JPanel is placed in a modal JDialog, then the main class will call the method after the dialog returns. If a non-modal dialog or if displayed on the main JPanel, then consider using listeners such as a ChangeListener.

    If you decide to go the listener route, and are confused, we can help, but you'll need to post more code. Don't forget that When posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
    [code]
      // your code goes here
      // notice how the top and bottom tags are different
    [/code]

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Edit: Steve's recommendations are more robust than mine. I'd go with his suggestions.

  5. #5
    dem125 is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default

    thank you for your comments.. here's the code.

    Java Code:
    public class DCard24Main extends javax.swing.JFrame {
        
          public DCard24Main() {
            initComponents();
        }                    
        private void initComponents() {
            ward24 = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("DIAGNOSIS CARD - MAIN CARD - WARD 24");
            setBackground(new java.awt.Color(0, 153, 153));
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowOpened(java.awt.event.WindowEvent evt) {
                    formWindowOpened(evt);
                }
            });
    
            ward24.setBackground(new java.awt.Color(0, 0, 0));
            ward24.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(204, 204, 0), new java.awt.Color(0, 204, 153)));
            ward24.setForeground(new java.awt.Color(204, 204, 0));
            ward24.setAutoscrolls(true);
            jLabel1.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel1.setForeground(new java.awt.Color(255, 255, 255));
            jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel1.setText("DIAGNOSIS CARD - MAIN CARD - WARD 24");
    
            jLabel2.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel2.setForeground(new java.awt.Color(255, 255, 255));
            jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel2.setText("PATIENT DETAILS");
    
            jLabel3.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel3.setForeground(new java.awt.Color(0, 255, 153));
            jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel3.setText("PATIENT NAME:");
    
            jLabel4.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel4.setForeground(new java.awt.Color(0, 255, 153));
            jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel4.setText("AGE:");
    
            jLabel5.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel5.setForeground(new java.awt.Color(0, 255, 153));
            jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel5.setText("SEX:");
    
            jLabel6.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel6.setForeground(new java.awt.Color(0, 255, 153));
            jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel6.setText("BHT NO:");
    
            jLabel7.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel7.setForeground(new java.awt.Color(0, 255, 153));
            jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel7.setText("DOA:");
    
            jLabel8.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel8.setForeground(new java.awt.Color(0, 255, 153));
            jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel8.setText("DOD:");
    
            sex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "F", "M" }));
    
            dod.setText("YYYY-MM-DD");
    
            jLabel9.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel9.setForeground(new java.awt.Color(255, 255, 255));
            jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel9.setText("DIAGNOSIS DETAILS");
    
            jLabel10.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel10.setForeground(new java.awt.Color(0, 255, 153));
            jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel10.setText("SELECT A DIAGNOSIS");
    
            diagarea.setColumns(20);
            diagarea.setLineWrap(true);
            diagarea.setRows(5);
            diagarea.setWrapStyleWord(true);
            jScrollPane1.setViewportView(diagarea);
    
            diagok.setText("OK");
            diagok.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    diagokActionPerformed(evt);
                }
            });
    
            diagadd.setText("ADD DIAGNOSIS");
            diagadd.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    diagaddActionPerformed(evt);
                }
            });
    
            jLabel11.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel11.setForeground(new java.awt.Color(255, 255, 255));
            jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel11.setText("HISTORY AND EXAMINATION");
    
            hisexam.setColumns(20);
            hisexam.setLineWrap(true);
            hisexam.setRows(5);
            hisexam.setWrapStyleWord(true);
            jScrollPane2.setViewportView(hisexam);
    
            jLabel12.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel12.setForeground(new java.awt.Color(255, 255, 255));
            jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel12.setText("INVESTIGATIONS");
    
            invs.setColumns(20);
            invs.setLineWrap(true);
            invs.setRows(5);
            invs.setWrapStyleWord(true);
            jScrollPane3.setViewportView(invs);
    
            jLabel13.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel13.setForeground(new java.awt.Color(255, 255, 255));
            jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel13.setText("DISCHARGE PLAN");
    
            jLabel14.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel14.setForeground(new java.awt.Color(0, 255, 153));
            jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel14.setText("CLINICAL REVIEW:");
    
            jLabel15.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel15.setForeground(new java.awt.Color(0, 255, 153));
            jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel15.setText("HISTOLOGY:");
    
            jLabel16.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel16.setForeground(new java.awt.Color(0, 255, 153));
            jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel16.setText("SUTURE REMOVAL:");
    
            cr.setText("YYYY-MM-DD");
    
            histology.setText("YYYY-MM-DD");
    
            sr.setText("YYYY-MM-DD");
    
            dp.setColumns(20);
            dp.setRows(5);
            jScrollPane4.setViewportView(dp);
    
            jLabel17.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel17.setForeground(new java.awt.Color(0, 255, 153));
            jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel17.setText("CONSULTANT:");
    
            ok.setText("OK");
            ok.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    okActionPerformed(evt);
                }
            });
    
            summary.setText("SUMMARY DIAG. CARD");
            summary.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    summaryActionPerformed(evt);
                }
            });
    
            exit.setText("EXIT");
            exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    exitActionPerformed(evt);
                }
            });
    
            jLabel18.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel18.setForeground(new java.awt.Color(255, 255, 255));
            jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel18.setText("COMMORDITIES AND ALLERGYS");
    
            addcom.setText("ADD COMMORDITIE");
            addcom.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    addcomActionPerformed(evt);
                }
            });
    
            comok.setText("OK");
            comok.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    comokActionPerformed(evt);
                }
            });
    
            ca.setColumns(20);
            ca.setLineWrap(true);
            ca.setRows(5);
            ca.setWrapStyleWord(true);
            jScrollPane5.setViewportView(ca);
    
            jLabel19.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel19.setForeground(new java.awt.Color(0, 255, 153));
            jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel19.setText("SELECT COMMORDITIE(S)");
    
            jLabel20.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel20.setForeground(new java.awt.Color(0, 255, 153));
            jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            jLabel20.setText("SELECT SURGERY(S)");
    
            jLabel21.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel21.setForeground(new java.awt.Color(255, 255, 255));
            jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel21.setText("MANAGEMENT AND SURGERY");
    
            sok.setText("OK");
            sok.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    sokActionPerformed(evt);
                }
            });
    
            addsur.setText("ADD SURGERY");
            addsur.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    addsurActionPerformed(evt);
                }
            });
    
            ms.setColumns(20);
            ms.setLineWrap(true);
            ms.setRows(5);
            ms.setWrapStyleWord(true);
            jScrollPane6.setViewportView(ms);
    
            jLabel22.setFont(new java.awt.Font("Verdana", 1, 12));
            jLabel22.setForeground(new java.awt.Color(255, 255, 255));
            jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel22.setText("POST OPERATIVE PERIOD");
    
            poperiod.setColumns(20);
            poperiod.setLineWrap(true);
            poperiod.setRows(5);
            poperiod.setWrapStyleWord(true);
            jScrollPane7.setViewportView(poperiod);
    
            consultant.setEditable(true);
    
            jButton1.setText("Date");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
    
            jButton2.setText("Date");
    
            jButton3.setText("Date");
    
            jButton4.setText("Date");
    
            org.jdesktop.layout.GroupLayout ward24Layout = new org.jdesktop.layout.GroupLayout(ward24);
            ward24.setLayout(ward24Layout);
            ward24Layout.setHorizontalGroup(
                ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(ward24Layout.createSequentialGroup()
                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(ward24Layout.createSequentialGroup()
                            .addContainerGap()
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(ward24Layout.createSequentialGroup()
                                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(ward24Layout.createSequentialGroup()
                                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, ward24Layout.createSequentialGroup()
                                                    .add(jLabel3)
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(patname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 355, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                                .add(ward24Layout.createSequentialGroup()
                                                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                        .add(jLabel13, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(ward24Layout.createSequentialGroup()
                                                            .add(jLabel6)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(bhtno, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(jLabel7)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(doa, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 81, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 7, Short.MAX_VALUE)
                                                            .add(jButton1))
                                                        .add(jLabel11, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(jLabel9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(diagcb, 0, 358, Short.MAX_VALUE)
                                                        .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(ward24Layout.createSequentialGroup()
                                                            .add(diagok)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(diagadd))
                                                        .add(jLabel10)
                                                        .add(jLabel12, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
                                                        .add(ward24Layout.createSequentialGroup()
                                                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                                .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                                    .add(ward24Layout.createSequentialGroup()
                                                                        .add(jLabel16)
                                                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, ward24Layout.createSequentialGroup()
                                                                        .add(jLabel15)
                                                                        .add(40, 40, 40)))
                                                                .add(jLabel14))
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                                                .add(org.jdesktop.layout.GroupLayout.LEADING, ward24Layout.createSequentialGroup()
                                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                                    .add(cr, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                                    .add(jButton2))
                                                                .add(org.jdesktop.layout.GroupLayout.LEADING, ward24Layout.createSequentialGroup()
                                                                    .add(histology, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                                    .add(jButton3))
                                                                .add(org.jdesktop.layout.GroupLayout.LEADING, ward24Layout.createSequentialGroup()
                                                                    .add(sr, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 123, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                                    .add(jButton4)))))
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                        .add(jLabel22, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                                                        .add(jLabel21, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                                                        .add(ward24Layout.createSequentialGroup()
                                                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                                                .add(org.jdesktop.layout.GroupLayout.LEADING, surgery, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                                .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel20))
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(sok)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(addsur))
                                                        .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                                            .add(ward24Layout.createSequentialGroup()
                                                                .add(com, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 127, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                                .add(comok)
                                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                                .add(addcom))
                                                            .add(jScrollPane5)
                                                            .add(jLabel19))
                                                        .add(ward24Layout.createSequentialGroup()
                                                            .add(jLabel8)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(dod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                            .add(28, 28, 28)
                                                            .add(jLabel4)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(age, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                            .add(22, 22, 22)
                                                            .add(jLabel5)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(sex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 92, Short.MAX_VALUE))
                                                        .add(jLabel18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 345, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                        .add(jScrollPane6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 402, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                                            .add(35, 35, 35))
                                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 777, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 814, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                                .add(ward24Layout.createSequentialGroup()
                                    .add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
                                    .add(475, 475, 475))
                                .add(ward24Layout.createSequentialGroup()
                                    .add(jLabel17)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(consultant, 0, 238, Short.MAX_VALUE)
                                    .add(475, 475, 475)))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 397, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(ward24Layout.createSequentialGroup()
                            .add(196, 196, 196)
                            .add(ok)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(summary)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(exit)))
                    .addContainerGap())
            );
    
            ward24Layout.linkSize(new java.awt.Component[] {addsur, sok}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
    
            ward24Layout.linkSize(new java.awt.Component[] {exit, ok, summary}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
    
            ward24Layout.linkSize(new java.awt.Component[] {diagadd, diagok}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
    
            ward24Layout.linkSize(new java.awt.Component[] {addcom, comok}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
    
            ward24Layout.setVerticalGroup(
                ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(ward24Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jLabel1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jLabel2)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel3)
                        .add(patname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel6)
                        .add(bhtno, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel8)
                        .add(dod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel4)
                        .add(age, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel5)
                        .add(sex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel7)
                        .add(doa, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jButton1))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel9)
                        .add(jLabel18))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(ward24Layout.createSequentialGroup()
                            .add(jLabel10)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(diagcb, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(diagok)
                                .add(diagadd))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jLabel11)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jLabel12)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jLabel13)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(cr, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel14)
                                .add(jButton2))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jLabel15)
                                .add(histology, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jButton3))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jLabel16)
                                .add(sr, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jButton4))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(consultant, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel17)))
                        .add(ward24Layout.createSequentialGroup()
                            .add(jLabel19)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(com, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(comok)
                                .add(addcom))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(14, 14, 14)
                            .add(jLabel21)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jLabel20)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(surgery, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(sok)
                                .add(addsur))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(15, 15, 15)
                            .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jScrollPane7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel22))))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(ward24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(ok)
                        .add(summary)
                        .add(exit))
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
    
            ward24Layout.linkSize(new java.awt.Component[] {jScrollPane1, jScrollPane2, jScrollPane3}, org.jdesktop.layout.GroupLayout.VERTICAL);
    
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(ward24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 796, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(ward24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            );
            pack();
        }// </editor-fold>                        
    
        private void okActionPerformed(java.awt.event.ActionEvent evt) {                                   
    // TODO add your handling code here:
            String pn=patname.getText();
            String bhtn=""+bhtno.getText();
            java.sql.Date dodv=java.sql.Date.valueOf(dod.getText());
            java.sql.Date doav=java.sql.Date.valueOf(doa.getText());
            int agev=Integer.parseInt(age.getText());
            String sexv=""+sex.getSelectedItem();
            String diagnosis=diagarea.getText();
            String hande=hisexam.getText();
            String iv=invs.getText();
            String cav=ca.getText();
            String msv=ms.getText();
            String pop=poperiod.getText();
            String dpv=dp.getText();
            java.sql.Date crdate=java.sql.Date.valueOf(cr.getText());
            java.sql.Date hv=java.sql.Date.valueOf(histology.getText());
            java.sql.Date srv=java.sql.Date.valueOf(sr.getText());
            String cv=""+consultant.getSelectedItem();
            Calendar c=Calendar.getInstance();
            int year=c.get(Calendar.YEAR);
            String idv=year+"_"+bhtn;
            DBConnection dbc=new DBConnection();
            try {
                dbc.dc24m(pn,bhtn,dodv,doav,agev,sexv,diagnosis,hande,iv,cav,msv,pop,dpv,crdate,hv,srv,cv,idv);
                dbc.start();
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
            JOptionPane jop=new JOptionPane();
            jop.showMessageDialog(null,"Patient Information Added");
            patname.setText("");
            bhtno.setText("");
            doa.setText("");
            age.setText("");
            diagarea.setText("");
            hisexam.setText("");
            invs.setText("");
            ca.setText("");
            ms.setText("");
            poperiod.setText("");
            dp.setText("");
            cr.setText("");
            histology.setText("");
            sr.setText("");
        }                                  
    
        private void summaryActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
            DCard24Summary dc24s=new DCard24Summary();
            dc24s.rundc24s();
        }                                       
    
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
            JCalendarDemo jcd=new JCalendarDemo();
            jcd.runJCD();
        }                                        
    
        
        
        private void sokActionPerformed(java.awt.event.ActionEvent evt) {                                    
            String scb=(String) surgery.getSelectedItem();
            ms.append(scb);
        }                                   
    
        private void comokActionPerformed(java.awt.event.ActionEvent evt) {                                      
    // TODO add your handling code here:
            String ccb=(String) com.getSelectedItem();
            ca.append(ccb);
        }                                     
    
        private void diagokActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // TODO add your handling code here:
            String dcb=(String) diagcb.getSelectedItem();
            diagarea.append(dcb);
        }                                      
    
        private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  
    // TODO add your handling code here:
            java.util.Date now=new java.util.Date();
            SimpleDateFormat dtformat=new SimpleDateFormat("yyyy-MM-dd");
            String sqlDate = dtformat.format(now);
            dod.setText(sqlDate);
            
            /* database connection */
            DBConnection db=new DBConnection();
            
            Vector vd=new Vector();
            Vector vc=new Vector();
            Vector vs=new Vector();
            try {
                vd=db.diagCombo();
                vc=db.comCombo();
                vs=db.surCombo();
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
            Enumeration e=vd.elements();
            while (e.hasMoreElements())
            {
                diagcb.addItem(e.nextElement());
            }
            Enumeration e1=vc.elements();
            while (e1.hasMoreElements())
            {
                com.addItem(e1.nextElement());
            }
            Enumeration e2=vs.elements();
            while (e2.hasMoreElements())
            {
                surgery.addItem(e2.nextElement());
            }
        }                                 
    
        private void addsurActionPerformed(java.awt.event.ActionEvent evt) {                                       
            surgery s=new surgery();
            s.runS();
        }                                      
    
        private void addcomActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // TODO add your handling code here:
            Cmdts c=new Cmdts();
            c.runC();
        }                                      
    
        private void diagaddActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
            Diagnosis dg=new Diagnosis();
            dg.runDG();
        }                                       
    
        private void exitActionPerformed(java.awt.event.ActionEvent evt) {                                     
    // TODO add your handling code here:
            this.dispose();
        }                                    
        
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new DCard24Main().setVisible(true);
                }
            });
        }
    
        void getDOADate(String string) {
            doa.setText(string);
            //throw new UnsupportedOperationException("Not yet implemented");
        }
    
        
        // Variables declaration - do not modify                     
        private javax.swing.JButton addcom;
        private javax.swing.JButton addsur;    
        
    }
    this is the code for the calendar

    Java Code:
    public class JCalendarDemo extends JPanel {
    
        private JCalendar calendar;
        private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        private JTextArea outputTextArea;
    
        public JCalendarDemo() {
            init();
        }
    
        private void init() {
            setLayout(new GridBagLayout());
    
            calendar = new JCalendar();
            calendar.setBorder(BorderFactory.createTitledBorder("Calendar"));
            add(calendar, new GridBagConstraints(0, 0, 1, 1, 1, 1,
                GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    
     
    
            JPanel outputPanel = new JPanel();
            outputPanel.setBorder(BorderFactory.createTitledBorder("Output"));
            outputPanel.setLayout(new GridBagLayout());
            add(outputPanel, new GridBagConstraints(0, 2, 2, 1, 1, 1,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,  new Insets(0, 0, 0, 0), 0, 0));
    
            outputTextArea = new JTextArea("");
            outputTextArea.setRows(5);
            outputTextArea.setEditable(false);
            outputPanel.add(new JScrollPane(outputTextArea),
                    new GridBagConstraints(0, 0, 2, 1, 1, 1,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0), 0, 0));
    
            JButton selectedDateButton = new JButton("Select Date");
            selectedDateButton.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e) {
                    printSelectedDates(false);
                }
            });
            outputPanel.add(selectedDateButton, new GridBagConstraints(0, 1, 1, 1, 1, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE,  new Insets(0, 0, 0, 0), 0, 0));
            
            JButton selectedOKButton = new JButton("OK");
            selectedOKButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    OKActionPerformed(evt);
                    }
            });
            outputPanel.add(selectedOKButton, new GridBagConstraints(0, 1, 1, 1, 1, 0,
                GridBagConstraints.WEST, GridBagConstraints.NONE,  new Insets(0, 0, 0, 0), 0, 0));
        }
    
        private void printSelectedDates(boolean all) {
            Vector v=new Vector();
            Date[] dates = all ? calendar.getSelectedDates()
                    : new Date[]{calendar.getSelectedDate()};
            StringBuffer x = new StringBuffer();
            for (int i = 0; i < dates.length; i++) {
                if (dates[i] != null) {
                    x.append(dateFormat.format(dates[i])).append("\n");
                }
            }
            if (x.length() <= 0) {
                x.append("No dates selected.");
            }
            String a=x.toString();
            outputTextArea.setText(x.toString());
        }
        
       void  OKActionPerformed(ActionEvent evt)
        {
             DCard24Main dc24m = new DCard24Main();
             dc24m.getDOADate(outputTextArea.getText());
        }
    
        private class Spinner extends JPanel {
    
            private JTextField spinnerTextField;
            private ChangeListener listener;
    
            public Spinner(ChangeListener listener) {
                this.listener = listener;
    
                setLayout(new GridBagLayout());
    
                spinnerTextField = new JTextField("", 3) {
                    protected Document createDefaultModel() {
                        return new NumberDocument();
                    }
                };
                spinnerTextField.setHorizontalAlignment(JTextField.RIGHT);
                spinnerTextField.getDocument().addDocumentListener(new DocumentListener() {
                    public void changedUpdate(DocumentEvent e) {
                        Spinner.this.listener.stateChanged(new ChangeEvent(e));
                    }
    
                    public void insertUpdate(DocumentEvent e) {
                        changedUpdate(e);
                    }
    
                    public void removeUpdate(DocumentEvent e) {
                        //changedUpdate(e);
                    }
                });
    
                add(spinnerTextField, new GridBagConstraints(0, 0, 1, 2, 1, 0,
                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                        new Insets(0, 0, 0, 0), 0, 0)); 
    
                ArrowButton spinnerIncButton = new ArrowButton(SwingConstants.NORTH, 1, 3);
                spinnerIncButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        spinnerTextField.setText(String.valueOf(
                                Integer.parseInt(spinnerTextField.getText()) + 1));
                    }
                });
                ArrowButton spinnerDecButton = new ArrowButton(SwingConstants.SOUTH, 1, 3);
                spinnerDecButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        spinnerTextField.setText(String.valueOf(
                                Integer.parseInt(spinnerTextField.getText()) - 1));
                    }
                });
    
                add(spinnerIncButton, new GridBagConstraints(1, 0, 1, 1,
                        0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
                        new Insets(0, 0, 0, 0), 0, 0));
                add(spinnerDecButton, new GridBagConstraints(1, 1, 1, 1,
                        0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
                        new Insets(0, 0, 0, 0), 0, 0));
            }
    
            public int getValue() {
                int x = 0;
                try {
                    x = Integer.parseInt(spinnerTextField.getText());
                } catch(NumberFormatException exc) {}
                return x;
            }
    
            public void setValue(int value) {
                spinnerTextField.setText(String.valueOf(value));
            }
        }
    
        public static void main(String[] args) {
            // getiing the major and minor version of the current JRE
            String verStr = System.getProperty("java.version");
            int majVerIndex = verStr.indexOf('.');
            int majVer;
            try {
                majVer = Integer.parseInt(verStr.substring(0, majVerIndex));
            } catch (NumberFormatException exc) {
                majVer = 1;
            }
            int minVerIndex = verStr.indexOf('.', majVerIndex + 1);
            int minVer;
            try {
                minVer = Integer.parseInt(verStr.substring(majVerIndex + 1, minVerIndex));
            } catch (NumberFormatException exc) {
                minVer = 3;
            }
    
            JFrame f = new JFrame("Calendar");
            JCalendarDemo x = new JCalendarDemo();
            f.getContentPane().add(x);
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.out.println();
                    System.exit(0);
                }
            });
            f.pack();
            f.setVisible(true);
            // Setting the position of the dialog on the center of the screen
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            f.setLocation((int)d.getWidth()/2 - (int)f.getPreferredSize().getWidth()/2,
                    (int)d.getHeight()/2 - (int)f.getPreferredSize().getHeight()/2);
        }
    
        void runJCD() {
     String verStr = System.getProperty("java.version");
            int majVerIndex = verStr.indexOf('.');
            int majVer;
            try {
                majVer = Integer.parseInt(verStr.substring(0, majVerIndex));
            } catch (NumberFormatException exc) {
                majVer = 1;
            }
            int minVerIndex = verStr.indexOf('.', majVerIndex + 1);
            int minVer;
            try {
                minVer = Integer.parseInt(verStr.substring(majVerIndex + 1, minVerIndex));
            } catch (NumberFormatException exc) {
                minVer = 3;
            }
    
            JFrame f = new JFrame("Calendar");
            JCalendarDemo x = new JCalendarDemo();
            f.getContentPane().add(x);
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.out.println();
                    //System.exit(0);
                }
            });
            f.pack();
            f.setVisible(true);
            // Setting the position of the dialog on the center of the screen
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            f.setLocation((int)d.getWidth()/2 - (int)f.getPreferredSize().getWidth()/2,
                    (int)d.getHeight()/2 - (int)f.getPreferredSize().getHeight()/2);
        }
    }
    Thank You

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I'm glad that you've solved your problem.

  7. #7
    dem125 is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default

    no no no!! i didn't fix the problem. there is no error.. but the date is not displaying in the main form.. - i'm taking the listener route.. need more info about how to use the change listener.. thanks..

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I suggest that you start with a smaller program just to see if you can get the concept to work. Write two small programs that does nothing but attempts to pass the information between classes, and I'll probably be able to help you some. Otherwise someone else might help you, but if not, it could be because you may be asking the volunteers here to wade through too much unrelated code.

    Best of luck

    edit: Also, please make sure that the code you post is compilable on others' systems. I honestly did try to compile your code, but could not due to missing variable declarations and missing class dependencies. With a smaller program, this would be much less of a problem.
    Last edited by Fubarable; 03-03-2009 at 09:02 PM.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Here's an example where I used a ChangeListener to allow several JPanels to all share the same "model". My forum name here is encephalopathic:

    JLabel Updating Text

  10. #10
    dem125 is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Passing a value..
    By Lagarto in forum New To Java
    Replies: 3
    Last Post: 01-23-2011, 06:58 PM
  2. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 03:59 PM
  3. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 09:10 AM
  4. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 09:32 PM
  5. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •