gbc2.gridy = 0;
gbc2.weightx = 1;
gbc2.fill = GridBagConstraints.HORIZONTAL;
for (Action action : category.getActions())
{
final ActionButton b = new ActionButton(action);
actions.add(b);
b.addActionListener(new ActionListener()
{
/**
* {@inheritDoc}
*/
public void actionPerformed(ActionEvent ev)
{
// Constructs the panels using reflection.
Action action = b.getActionObject();
GenericFrame frame = frames.get(action);
if (frame == null)
{
Class<? extends StatusGenericPanel> panelClass =
action.getAssociatedPanelClass();
try
{
Constructor<? extends StatusGenericPanel> constructor =
panelClass.getDeclaredConstructor();
StatusGenericPanel panel = constructor.newInstance();
if (getInfo() != null)
{
panel.setInfo(getInfo());
}
frame = createFrame(panel);
frames.put(action, frame);
Utilities.centerGoldenMean(frame,
Utilities.getFrame(MainActionsPane.this));
}
catch (Throwable t)
{
// Bug
t.printStackTrace();
}
}
if (!frame.isVisible())
{
frame.setVisible(true);
}
else
{
frame.toFront();
}
}
});
categoryPanel.add(b, gbc2);
gbc2.gridy++;
group.add(b);
maxWidth = Math.max(maxWidth, b.getPreferredSize().width);
}
CategoryPanel p = new CategoryPanel(categoryPanel, category);
maxWidth = Math.max(maxWidth, p.getPreferredSize().width);
p.setExpanded(false);
add(p, gbc1);