Search code examples
javadatechooser

How can I programmatically open the DateChooserPanel when my frame gets shown


I'm using the DateChooser Lib from Androsov Vadim which can be found here: Sourceforge Link

What I want to achieve is, simply show the popup menu when the frame gets shown. Here is a simple implementation of the DateChooserCombo

package testapp;

public class TestFrame extends javax.swing.JFrame {

public TestFrame() {
    initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    dateChooserCombo1 = new datechooser.beans.DateChooserCombo();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap(124, Short.MAX_VALUE)
            .addComponent(dateChooserCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(121, 121, 121))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(22, 22, 22)
            .addComponent(dateChooserCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(258, Short.MAX_VALUE))
    );

    pack();
}// </editor-fold>                        
// Variables declaration - do not modify                     
private datechooser.beans.DateChooserCombo dateChooserCombo1;
// End of variables declaration                   
}

This is how it looks now:

DateChooserCombo

And this is what i want to achieve:

DateChooserCombo with shown menue

If someone has done the same and could help me achieving this would be great.


Solution

  • After trying multiple attempts to solve this issue I downloaded the source of the Lib and edited the visibility of the method dateChooserLoaded from private to public, build the jar and implemented this edited version of the Lib into my Project.

    After that i can now simply call it like this:

    @Override
    public void windowActivated(WindowEvent e) {
        dateChooserLoaded();
    }
    

    maybe this helps someone else with a similar problem.