* fix layout issues

This commit is contained in:
Reinhard Pointner 2014-08-02 19:56:19 +00:00
parent 478dbef16b
commit 989fd687da
1 changed files with 35 additions and 44 deletions

View File

@ -1,7 +1,5 @@
package net.filebot.ui;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Component;
@ -29,7 +27,6 @@ import net.filebot.util.ui.DefaultFancyListCellRenderer;
import net.filebot.util.ui.SwingUI;
import net.miginfocom.swing.MigLayout;
public class SelectDialog<T> extends JDialog {
private final JLabel headerLabel = new JLabel();
@ -38,7 +35,6 @@ public class SelectDialog<T> extends JDialog {
private boolean valueSelected = false;
public SelectDialog(Component parent, Collection<? extends T> options) {
super(getWindow(parent), "Select", ModalityType.DOCUMENT_MODAL);
@ -68,30 +64,28 @@ public class SelectDialog<T> extends JDialog {
c.setLayout(new MigLayout("insets 1.5mm 1.5mm 2.7mm 1.5mm, nogrid, fill", "", "[pref!][fill][pref!]"));
c.add(headerLabel, "wrap");
c.add(new JScrollPane(list), "grow, wrap 2mm");
c.add(headerLabel, "wmin 150px, wrap");
c.add(new JScrollPane(list), "wmin 150px, hmin 150px, grow, wrap 2mm");
c.add(new JButton(selectAction), "align center, id select");
c.add(new JButton(cancelAction), "gap unrel, id cancel");
// set default size and location
setSize(new Dimension(210, 210));
setMinimumSize(new Dimension(220, 240));
setSize(new Dimension(240, 260));
// Shortcut Enter
SwingUI.installAction(list, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), selectAction);
}
protected String convertValueToString(Object value) {
return value.toString();
}
public JLabel getHeaderLabel() {
return headerLabel;
}
@SuppressWarnings("unchecked")
public T getSelectedValue() {
if (!valueSelected)
@ -100,18 +94,15 @@ public class SelectDialog<T> extends JDialog {
return (T) list.getSelectedValue();
}
public void close() {
setVisible(false);
dispose();
}
public Action getSelectAction() {
return selectAction;
}
public Action getCancelAction() {
return cancelAction;
}