use of javax.swing.JDialog in project processdash by dtuma.
the class QuickSelectTaskAction method selectTask.
private void selectTask() {
if (taskProvider == null || activeTaskModel == null)
throw new IllegalStateException("Object not yet initialized");
TreeTableModel tasks = taskProvider.getTaskSelectionChoices();
final JFilterableTreeComponent selector = new JFilterableTreeComponent(tasks, resources.getString("Choose_Task.Find"), false);
final Object nodeToSelect = taskProvider.getTreeNodeForPath(activeTaskModel.getPath());
loadPrefs(selector);
selector.setMatchEntirePath(true);
TaskCompletionRenderer rend = null;
if (parentComponent instanceof DashboardContext)
rend = new TaskCompletionRenderer(selector, (DashboardContext) parentComponent);
new JOptionPaneActionHandler().install(selector);
Object[] message = new Object[] { resources.getString("Choose_Task.Prompt"), selector, new JOptionPaneTweaker.MakeResizable(), new JOptionPaneTweaker.GrabFocus(selector.getFilterTextField()), new JOptionPaneTweaker(50) {
public void doTweak(JDialog dialog) {
if (nodeToSelect != null)
selector.setAnchorSelectedNode(nodeToSelect);
}
} };
int userChoice = JOptionPane.showConfirmDialog(parentComponent, message, resources.getString("Choose_Task.Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
savePrefs(selector);
if (rend != null)
rend.dispose();
if (userChoice != JOptionPane.OK_OPTION)
return;
Object newTask = selector.getSelectedLeaf();
if (newTask == null)
return;
String newPath = taskProvider.getPathForTreeNode(newTask);
if (StringUtils.hasValue(newPath))
activeTaskModel.setPath(newPath);
}
use of javax.swing.JDialog in project jgnash by ccavanaugh.
the class ConsoleDialog method show.
public static void show() {
if (dialog == null) {
// only one visible window
init();
ResourceBundle rb = ResourceUtils.getBundle();
JButton copyButton = new JButton(rb.getString("Button.CopyToClip"));
copyButton.addActionListener(e -> {
if (console != null) {
console.selectAll();
console.copy();
}
});
JButton gcButton = new JButton(rb.getString("Button.ForceGC"));
gcButton.addActionListener(e -> System.gc());
JButton heapButton = new JButton(rb.getString("Button.CreateHeapDump"));
heapButton.addActionListener(e -> {
if (console != null) {
dumpHeap();
}
});
dialog = new JDialog(UIApplication.getFrame(), Dialog.ModalityType.MODELESS);
dialog.setTitle(rb.getString("Title.Console"));
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
/* force the shut down to the end of the event thread.
* Lets other listeners do their job */
EventQueue.invokeLater(() -> {
synchronized (consoleLock) {
ConsoleDialog.close();
}
});
}
});
synchronized (consoleLock) {
console = new JTextArea();
console.setEditable(false);
// set a mono spaced font to preserve spacing
console.setFont(new Font("Monospaced", Font.PLAIN, console.getFont().getSize()));
}
JPanel panel = new JPanel();
panel.setBorder(Borders.DIALOG);
panel.setLayout(new BorderLayout());
panel.add(new MemoryMonitor(), BorderLayout.NORTH);
panel.add(new JScrollPane(console), BorderLayout.CENTER);
JPanel buttonPanel = StaticUIMethods.buildRightAlignedBar(heapButton, gcButton, copyButton);
buttonPanel.setBorder(new EmptyBorder(10, 0, 10, 0));
panel.add(buttonPanel, BorderLayout.SOUTH);
dialog.getContentPane().add(panel, BorderLayout.CENTER);
dialog.pack();
// Minimum size
dialog.setMinimumSize(dialog.getSize());
dialog.setFocusableWindowState(false);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
DialogUtils.addBoundsListener(dialog);
dialog.setVisible(true);
}
}
use of javax.swing.JDialog in project jgnash by ccavanaugh.
the class AboutDialog method showDialog.
public static void showDialog(final Frame parent) {
EventQueue.invokeLater(() -> {
JDialog dlg = new AboutDialog(parent, false);
dlg.setVisible(true);
});
}
use of javax.swing.JDialog in project Fling by entertailion.
the class FlingFrame method createProgressDialog.
/**
* Create a progress indicator
*/
private void createProgressDialog() {
progressDialog = new JDialog(this, resourceBundle.getString("progress.title"), true);
JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
progressDialog.add(BorderLayout.CENTER, progressBar);
progressDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
progressDialog.setSize(300, 75);
progressDialog.setLocationRelativeTo(this);
}
use of javax.swing.JDialog in project smile by haifengl.
the class FontChooser method createDialog.
private JDialog createDialog(Component parent) {
Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);
Action okAction = new DialogOKAction(dialog);
Action cancelAction = new DialogCancelAction(dialog);
JButton okButton = new JButton(okAction);
okButton.setFont(DEFAULT_FONT);
JButton cancelButton = new JButton(cancelAction);
cancelButton.setFont(DEFAULT_FONT);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new GridLayout(2, 1));
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
ActionMap actionMap = buttonsPanel.getActionMap();
actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
JPanel dialogEastPanel = new JPanel();
dialogEastPanel.setLayout(new BorderLayout());
dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
dialog.getContentPane().add(this, BorderLayout.CENTER);
dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
dialog.pack();
dialog.setLocationRelativeTo(frame);
return dialog;
}
Aggregations