public EntryTypeDialog(BibtexBaseFrame baseFrame_) {
super(baseFrame_, true); // Set modal on.
setTitle("Select entry type");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
cancelAction.actionPerformed(null);
}
});
getContentPane().setLayout(new BorderLayout());
JPanel pan = new JPanel();
getContentPane().add(pan, BorderLayout.CENTER);
JPanel lower = new JPanel();
JButton // ok = new JButton("Ok"),
cancel = new JButton("Cancel");
//ok.addActionListener(this);
cancel.addActionListener(this);
// Make ESC close dialog, equivalent to clicking Cancel.
cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(GUIGlobals.exitDialog, "close");
cancel.getActionMap().put("close", cancelAction);
//lower.add(ok);
lower.add(cancel);
getContentPane().add(lower, BorderLayout.SOUTH);
GridBagLayout gbl = new GridBagLayout();
pan.setLayout(gbl);
GridBagConstraints con = new GridBagConstraints();
con.anchor = GridBagConstraints.WEST;
con.fill = GridBagConstraints.HORIZONTAL;
con.insets = new Insets(4, 4, 4, 4);
int col = 0;
TreeSet buttons = new TreeSet();
Iterator iter = BibtexEntryType.ALL_TYPES.iterator();
for (;iter.hasNext();) {
BibtexEntryType type = (BibtexEntryType)(iter.next());
TypeButton b = new TypeButton(type.getName(), type);
buttons.add(b);
}
// We added the buttons to a TreeSet, sorting them according to their names.
// The sort is based on the compareTo() method in TypeButton.
iter = buttons.iterator();
for (;iter.hasNext();) {
TypeButton b = (TypeButton)(iter.next());
b.setAlignmentX(SwingConstants.LEFT);
b.addActionListener(this);
// Check if we should finish the row.
col++;
if (col == COLNUM) {
col = 0;
con.gridwidth = GridBagConstraints.REMAINDER;
} else
con.gridwidth = 1;
gbl.setConstraints(b, con);
pan.add(b);
}
pan.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
"Entry types"));
//pan.setBackground(Color.white);
//lower.setBackground(Color.white);
pack();
setResizable(false);
}
|