private void btnAddForm_actionPerformed(){
JPanel newFormPanel=new JPanel();
JTextField formType = new JTextField("formType");
JFormattedTextField startDate = new JFormattedTextField("yyyy/mm/dd");
JFormattedTextField endDate = new JFormattedTextField("yyyy/mm/dd");
JRadioButton reqdIK = new JRadioButton();
JCheckBox chkDel = new JCheckBox();chkDel.setName("del");
newFormPanel.setLayout(new GridLayout(1,5));
newFormPanel.add(formType);newFormPanel.add(startDate);newFormPanel.add(endDate);
newFormPanel.add(reqdIK);newFormPanel.add(chkDel);newFormPanel.setVisible(true);
pnlFprmInput.add(newFormPanel);
scrollForms.getRootPane().paintImmediately(0,0,(int)pnlFprmInput.getSize().getWidth(),(int)pnlFprmInput.getSize().getHeight());
scrollForms.repaint();
dateAValidation(startDate,endDate);
dateBValidation(endDate,startDate);
}
I tried many things like paint , repaint, paintImmediately.
This is Java. It is the second best programming language, next to C++. It trades convenience for power. Putting a method with _actionPerformed() does not magically add an action listener to the object.
You have to call addActionListener(this) to btnAddForm.
The method also must be public.
It accepts an argument of ActionEvent.
public void actionPerformed(ActionEvent e) {}
Finally, the class must implement ActionListener.
No, My friend. it s not actually like u feel.
it is like
button.addActionListener(new ActionListener(){
public void actionPerformed(){
button_actionPerformed();
}
})
so action listener will be added.
and the added things are getting displayed when the scrreen is resized.
But, i need them to be displayed as and when they are added.
Any Ideas?