41 lines
1.4 KiB
Java
41 lines
1.4 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package puntocassa;
|
|
|
|
import java.awt.Font;
|
|
import java.awt.HeadlessException;
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.UIManager;
|
|
|
|
/**
|
|
*
|
|
* @author marco
|
|
*/
|
|
public class JEnhancedOptionPane extends JOptionPane {
|
|
public static String showInputDialog(final Object message, final Object[] options)
|
|
throws HeadlessException {
|
|
final JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE,
|
|
OK_CANCEL_OPTION, null,
|
|
options, null);
|
|
pane.setWantsInput(true);
|
|
pane.setComponentOrientation((getRootFrame()).getComponentOrientation());
|
|
pane.setMessageType(QUESTION_MESSAGE);
|
|
pane.selectInitialValue();
|
|
Font f=new Font("Tahoma",0,20);
|
|
|
|
|
|
final String title = UIManager.getString("OptionPane.inputDialogTitle", null);
|
|
final JDialog dialog = pane.createDialog(null, title);
|
|
dialog.setFont(f);
|
|
dialog.setVisible(true);
|
|
dialog.dispose();
|
|
final Object value = pane.getInputValue();
|
|
return (value == UNINITIALIZED_VALUE) ? null : (String) value;
|
|
}
|
|
}
|