Whoops. I make this mistake too often in swing.
I did what you said re: putting it all in the constructor. I also had to change it to extends AbstractVisionPanel
instead of AbstractVisionComponent - the former works but the latter does not.
However, having said that -
It's alive! Now for the fun part of programming date logic
On that note though - as these date calculations will take place when a new dropdown selection is made - where would I put my JComboBox ActionListener? The constructor? onStartup?
Here's the current code (onStartup and onShutdown are empty)
public class DateSelectorComponent extends AbstractVisionPanel {
private final JPanel container;
private final JLabel dropdownLabel;
private final JComboBox<String> dateSelections;
private final JLabel startDateLabel;
private final JLabel toLabel;
private final PMIDateTimePopupSelector startDate;
private final PMIDateTimePopupSelector endDate;
private final String[] dateSelectionOptions = {"All", "Today", "This Week", "This Month", "This Year", "Last Week", "Last Month", "Last Year", "Last 3 Months", "Last 6 Months", "Last 12 Months", "Two Week Period", "Post Sept. 2014"};
public DateSelectorComponent() {
//Leftover from archetype example. setPreferredsize seems to do stuff, but unsure what else is appropriate to go here over onStartup.
setFont(new Font("Dialog", Font.PLAIN, 16));
// setPreferredSize(new Dimension(250, 100));
container = new JPanel(new MigLayout("wrap 4"));
//Dropdown row
dropdownLabel = new JLabel("Date:");
dateSelections = new JComboBox<>(dateSelectionOptions);
container.add(dropdownLabel, "grow");
container.add(dateSelections, "span");
//Datetime row
startDateLabel = new JLabel("Start Date:");
startDate = new PMIDateTimePopupSelector();
toLabel = new JLabel("to");
endDate = new PMIDateTimePopupSelector();
container.add(startDateLabel, "grow");
container.add(startDate, "grow");
container.add(toLabel, "grow");
container.add(endDate, "grow");
//Is this necessary?
container.setVisible(true);
this.add(container);
//not sure if the following is necessary
this.setVisible(true);
}
Exited this thing's actually coming to fruition now - thanks for all the help.