下面列出了javax.swing.JEditorPane#setCaretPosition ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void performOpen(JEditorPane[] panes) {
if (panes == null || panes.length == 0) {
StatusDisplayer.getDefault().setStatusText(Bundle.ERR_ShellConsoleClosed());
return;
}
JEditorPane p = panes[0];
Rng[] fragments = theHandle.getFragments();
int to = fragments[0].start;
p.requestFocus();
int pos = Math.min(p.getDocument().getLength() - 1, to);
p.setCaretPosition(pos);
try {
Rectangle r = p.modelToView(pos);
p.scrollRectToVisible(r);
} catch (BadLocationException ex) {
}
}
@Override
public boolean canDrop(DropTargetDragEvent e) {
//check if the JEditorPane contains html document
JEditorPane pane = findPane(e.getDropTargetContext().getComponent());
if (pane == null) {
return false;
}
int offset = getLineEndOffset(pane, e.getLocation());
if (!containsLanguageAtOffset(pane.getDocument(), offset)) {
return false;
} else {
//update the caret as the user drags the object
//needs to be done explicitly here as QuietEditorPane doesn't call
//the original Swings DropTarget which does this
pane.setCaretPosition(offset);
pane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but ExternalDropHandler don't handle dragEnter event
return canDrop(e.getCurrentDataFlavors());
}
}
@Override
public boolean canDrop(DropTargetDragEvent e) {
//check if the JEditorPane contains html document
JEditorPane pane = findPane(e.getDropTargetContext().getComponent());
if (pane == null) {
return false;
}
int offset = getLineEndOffset(pane, e.getLocation());
if (!containsLanguageAtOffset(pane.getDocument(), offset)) {
return false;
} else {
//update the caret as the user drags the object
//needs to be done explicitly here as QuietEditorPane doesn't call
//the original Swings DropTarget which does this
pane.setCaretPosition(offset);
pane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but ExternalDropHandler don't handle dragEnter event
return canDrop(e.getCurrentDataFlavors());
}
}
public MyFrame() {
JEditorPane editpane = new JEditorPane();
editpane.setEditable(false);
editpane.setText(content);
editpane.setCaretPosition(0);
JScrollPane scrollpane = new JScrollPane(editpane);
add(scrollpane);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setSize(new Dimension(200, 200));
bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
setResizable(false);
setVisible(true);
}
@Override
public boolean canDrop(DropTargetDragEvent event) {
JEditorPane editorPane = findPane(event.getDropTargetContext().getComponent());
if (editorPane == null || !isInCakePHP(editorPane)) {
return false;
}
Transferable t = event.getTransferable();
canDrop = canDrop(t);
if (!canDrop) {
return false;
}
editorPane.setCaretPosition(getOffset(editorPane, event.getLocation()));
editorPane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but ExternalDropHandler don't handle dragEnter event
return canDrop(event.getCurrentDataFlavors());
}
public void emitDoc() {
try {
if (last_env == null || last_prog == null) {
respArea2.setText("Must compile before emitting documentation.");
}
String html = AqlDoc.doc(last_env, last_prog);
File file = File.createTempFile("catdata" + title, ".html");
FileWriter w = new FileWriter(file);
w.write(html);
w.close();
JTabbedPane p = new JTabbedPane();
JEditorPane pane = new JEditorPane("text/html", html);
pane.setEditable(false);
pane.setCaretPosition(0);
// p.addTab("Rendered", new JScrollPane(pane));
p.addTab("HTML", new CodeTextPanel("", html));
JFrame f = new JFrame("HTML for " + title);
JPanel ret = new JPanel(new GridLayout(1, 1));
f.setContentPane(ret);
ret.add(p);
f.setSize(600, 800);
f.setLocation(100, 600);
f.setVisible(true);
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Desktop.getDesktop().browse(file.toURI());
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void doTestTemplateInsert(String template, String code, String expected) throws Exception {
clearWorkDir();
FileObject testFile = FileUtil.toFileObject(getWorkDir()).createData("Test.java");
EditorKit kit = new JavaKit();
JEditorPane pane = new JEditorPane();
pane.setEditorKit(kit);
Document doc = pane.getDocument();
doc.putProperty(Document.StreamDescriptionProperty, testFile);
doc.putProperty(Language.class, JavaTokenId.language());
doc.putProperty("mimeType", "text/x-java");
int caretOffset = code.indexOf('|');
assertTrue(caretOffset != (-1));
String text = code.substring(0, caretOffset) + code.substring(caretOffset + 1);
pane.setText(text);
pane.setCaretPosition(caretOffset);
try (OutputStream out = testFile.getOutputStream();
Writer w = new OutputStreamWriter(out)) {
w.append(text);
}
CodeTemplateManager manager = CodeTemplateManager.get(doc);
CodeTemplate ct = manager.createTemporary(template);
CodeTemplateInsertHandler handler = new CodeTemplateInsertHandler(ct, pane, Arrays.asList(new JavaCodeTemplateProcessor.Factory()), OnExpandAction.INDENT);
handler.processTemplate();
int resultCaretOffset = expected.indexOf('|');
assertTrue(resultCaretOffset != (-1));
String expectedText = expected.substring(0, resultCaretOffset) + expected.substring(resultCaretOffset + 1);
assertEquals(expectedText, doc.getText(0, doc.getLength()));
assertEquals(resultCaretOffset, pane.getCaretPosition());
}
private void openPane(JEditorPane pane, NavigationCase navCase) {
final Cursor editCursor = pane.getCursor();
pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
pane.setCaretPosition(navCase.findPosition() + 2);
pane.setCursor(editCursor);
StatusDisplayer.getDefault().setStatusText(""); //NOI18N
}
public void testDoNotAutocompleteQuteInHtmlAttribute() throws DataObjectNotFoundException, IOException, BadLocationException {
FileObject fo = getTestFile("testfiles/test.html");
assertEquals("text/html", fo.getMIMEType());
DataObject dobj = DataObject.find(fo);
EditorCookie ec = dobj.getCookie(EditorCookie.class);
Document document = ec.openDocument();
ec.open();
JEditorPane jep = ec.getOpenedPanes()[0];
BaseAction type = (BaseAction) jep.getActionMap().get(NbEditorKit.defaultKeyTypedAction);
//find the pipe
String text = document.getText(0, document.getLength());
int pipeIdx = text.indexOf('|');
assertTrue(pipeIdx != -1);
//delete the pipe
document.remove(pipeIdx, 1);
jep.setCaretPosition(pipeIdx);
//type "
ActionEvent ae = new ActionEvent(doc, 0, "\"");
type.actionPerformed(ae, jep);
//check the document content
String beforeCaret = document.getText(pipeIdx, 2);
assertEquals("\" ", beforeCaret);
}
static Component showOutOfDateComponent(final Version latestVersionOut) {
final JPanel panel = new JPanel(new BorderLayout());
final JEditorPane intro = new JEditorPane("text/html", getOutOfDateMessage(latestVersionOut));
intro.setEditable(false);
intro.setOpaque(false);
intro.setBorder(BorderFactory.createEmptyBorder());
final HyperlinkListener hyperlinkListener =
e -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
OpenFileUtility.openUrl(e.getDescription());
}
};
intro.addHyperlinkListener(hyperlinkListener);
panel.add(intro, BorderLayout.NORTH);
final JEditorPane updates = new JEditorPane("text/html", getOutOfDateReleaseUpdates());
updates.setEditable(false);
updates.setOpaque(false);
updates.setBorder(BorderFactory.createEmptyBorder());
updates.addHyperlinkListener(hyperlinkListener);
updates.setCaretPosition(0);
final JScrollPane scroll = new JScrollPane(updates);
panel.add(scroll, BorderLayout.CENTER);
final Dimension maxDimension = panel.getPreferredSize();
maxDimension.width = Math.min(maxDimension.width, 700);
maxDimension.height = Math.min(maxDimension.height, 480);
panel.setMaximumSize(maxDimension);
panel.setPreferredSize(maxDimension);
return panel;
}
private static JEditorPane createNotesPane(final String html) {
final JEditorPane gameNotesPane = new JEditorPane("text/html", html);
gameNotesPane.setEditable(false);
gameNotesPane.setForeground(Color.BLACK);
gameNotesPane.setCaretPosition(0);
return gameNotesPane;
}
public void actionPerformed(ActionEvent ev) {
if (ev.getSource().equals(comboWeight)
|| ev.getSource().equals(comboUnitType)) {
filterUnits();
} else if (ev.getSource().equals(btnSelect)) {
select(false);
} else if (ev.getSource().equals(btnSelectClose)) {
select(true);
} else if (ev.getSource().equals(btnClose)) {
close();
} else if (ev.getSource().equals(btnShowBV)) {
JEditorPane tEditorPane = new JEditorPane();
tEditorPane.setContentType("text/html");
tEditorPane.setEditable(false);
Entity e = getSelectedEntity();
if (null == e) {
return;
}
e.calculateBattleValue();
tEditorPane.setText(e.getBVText());
tEditorPane.setCaretPosition(0);
JScrollPane tScroll = new JScrollPane(tEditorPane,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
Dimension size = new Dimension(550, 300);
tScroll.setPreferredSize(size);
JOptionPane.showMessageDialog(null, tScroll, "BV", JOptionPane.INFORMATION_MESSAGE, null);
} else if(ev.getSource().equals(btnAdvSearch)) {
searchFilter = asd.showDialog();
btnResetSearch.setEnabled((searchFilter != null) && !searchFilter.isDisabled);
filterUnits();
} else if(ev.getSource().equals(btnResetSearch)) {
asd.clearValues();
searchFilter=null;
btnResetSearch.setEnabled(false);
filterUnits();
}
}
protected void performTest(String source, int caretPos, String textToInsert, String toPerformItemRE, String goldenFileName, String sourceLevel) throws Exception {
this.sourceLevel.set(sourceLevel);
File testSource = new File(getWorkDir(), "test/Test.java");
testSource.getParentFile().mkdirs();
copyToWorkDir(new File(getDataDir(), "org/netbeans/modules/java/editor/completion/data/" + source + ".java"), testSource);
FileObject testSourceFO = FileUtil.toFileObject(testSource);
assertNotNull(testSourceFO);
DataObject testSourceDO = DataObject.find(testSourceFO);
assertNotNull(testSourceDO);
EditorCookie ec = (EditorCookie) testSourceDO.getCookie(EditorCookie.class);
assertNotNull(ec);
final Document doc = ec.openDocument();
assertNotNull(doc);
doc.putProperty(Language.class, JavaTokenId.language());
doc.putProperty("mimeType", "text/x-java");
int textToInsertLength = textToInsert != null ? textToInsert.length() : 0;
if (textToInsertLength > 0)
doc.insertString(caretPos, textToInsert, null);
Source s = Source.create(doc);
List<? extends CompletionItem> items = JavaCompletionProvider.query(s, CompletionProvider.COMPLETION_QUERY_TYPE, caretPos + textToInsertLength, caretPos + textToInsertLength);
Collections.sort(items, CompletionItemComparator.BY_PRIORITY);
assertNotNull(goldenFileName);
Pattern p = Pattern.compile(toPerformItemRE);
CompletionItem item = null;
for (CompletionItem i : items) {
if (p.matcher(i.toString()).find()) {
item = i;
break;
}
}
assertNotNull(item);
JEditorPane editor = new JEditorPane();
SwingUtilities.invokeAndWait(() -> {
editor.setEditorKit(new JavaKit());
});
editor.setDocument(doc);
editor.setCaretPosition(caretPos + textToInsertLength);
item.defaultAction(editor);
SwingUtilities.invokeAndWait(() -> {});
File output = new File(getWorkDir(), getName() + ".out2");
Writer out = new FileWriter(output);
out.write(doc.getText(0, doc.getLength()));
out.close();
File goldenFile = getGoldenFile(goldenFileName);
File diffFile = new File(getWorkDir(), getName() + ".diff");
assertFile(output, goldenFile, diffFile, new WhitespaceIgnoringDiff());
LifecycleManager.getDefault().saveAll();
}
private void updateFramesImpl(JEditorPane pane, boolean rawData) throws BadLocationException {
Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
StyledDocument doc = (StyledDocument)pane.getDocument();
Style timingStyle = doc.addStyle("timing", defaultStyle);
StyleConstants.setForeground(timingStyle, Color.lightGray);
Style infoStyle = doc.addStyle("comment", defaultStyle);
StyleConstants.setForeground(infoStyle, Color.darkGray);
StyleConstants.setBold(infoStyle, true);
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
pane.setText("");
StringBuilder sb = new StringBuilder();
int lastFrameType = -1;
for (Network.WebSocketFrame f : wsRequest.getFrames()) {
int opcode = f.getOpcode();
if (opcode == 0) { // "continuation frame"
opcode = lastFrameType;
} else {
lastFrameType = opcode;
}
if (opcode == 1) { // "text frame"
if (!rawData) {
doc.insertString(doc.getLength(), formatter.format(f.getTimestamp()), timingStyle);
doc.insertString(doc.getLength(), f.getDirection() == Network.Direction.SEND ? " SENT " : " RECV ", timingStyle);
}
doc.insertString(doc.getLength(), f.getPayload()+"\n", defaultStyle);
} else if (opcode == 2) { // "binary frame"
if (!rawData) {
doc.insertString(doc.getLength(), formatter.format(f.getTimestamp()), timingStyle);
doc.insertString(doc.getLength(), f.getDirection() == Network.Direction.SEND ? " SENT " : " RECV ", timingStyle);
}
// XXX: binary data???
doc.insertString(doc.getLength(), f.getPayload()+"\n", defaultStyle);
} else if (opcode == 8) { // "close frame"
if (!rawData) {
doc.insertString(doc.getLength(), formatter.format(f.getTimestamp()), timingStyle);
doc.insertString(doc.getLength(), f.getDirection() == Network.Direction.SEND ? " SENT " : " RECV ", timingStyle);
}
doc.insertString(doc.getLength(), "Frame closed\n", infoStyle);
}
}
data = sb.toString();
pane.setCaretPosition(0);
}
private void updateTextInAWT(EditorCookie es, final String in) throws IOException, BadLocationException {
StyledDocument tmpdoc = es.getDocument();
if (tmpdoc == null)
tmpdoc = es.openDocument();
//sample editor position
JEditorPane[] eps = es.getOpenedPanes();
JEditorPane pane = null;
JViewport port = null;
int caretPosition = 0;
Point viewPosition = null;
if (eps != null) {
pane = eps[0];
caretPosition = pane.getCaretPosition();
port = getParentViewport (pane);
if (port != null)
viewPosition = port.getViewPosition();
}
// prepare modification task
final Exception[] taskEx = new Exception[] {null};
final StyledDocument sdoc = tmpdoc;
Runnable task = new Runnable() {
public void run() {
try {
sdoc.remove (0, sdoc.getLength()); // right alternative
// we are at Unicode level
sdoc.insertString (0, in, null);
} catch (Exception iex) {
taskEx[0] = iex;
}
}
};
// perform document modification
org.openide.text.NbDocument.runAtomicAsUser(sdoc, task);
//??? setModified (true);
//restore editor position
if (eps != null) {
try {
pane.setCaretPosition (caretPosition);
} catch (IllegalArgumentException e) {
}
port.setViewPosition (viewPosition);
}
if (taskEx[0]!=null) {
if (taskEx[0] instanceof IOException) {
throw (IOException)taskEx[0];
}
throw new IOException(taskEx[0]);
}
}
private EULADialog(@Nullable Project project, @NotNull String title, @Nullable String eulaText, boolean isPlainText, OnEulaAccepted onAccept) {
super(project);
this.onAccept = onAccept;
myEulaTextFound = eulaText != null;
JComponent component;
if (isPlainText) {
JTextArea textArea = new JTextArea();
textArea.setText(eulaText);
textArea.setMinimumSize(null);
textArea.setEditable(false);
textArea.setCaretPosition(0);
textArea.setBackground(null);
textArea.setBorder(JBUI.Borders.empty());
component = textArea;
} else {
JEditorPane editor = new JEditorPane();
editor.setContentType("text/html");
editor.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); // work around <meta> tag
editor.setText(eulaText);
editor.setEditable(false);
editor.setCaretPosition(0);
editor.setMinimumSize(null);
editor.setBorder(JBUI.Borders.empty());
component = editor;
}
myScrollPane = new JBScrollPane(component);
myScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
setModal(true);
setTitle(title);
setOKButtonText("Accept");
getOKAction().putValue(DEFAULT_ACTION, null);
setCancelButtonText("Decline");
getCancelAction().putValue(DEFAULT_ACTION, Boolean.TRUE);
init();
}
private void setData(JEditorPane jEditorPane, Value value) {
if (value == null) {
value = new Value("", Settings.getNow()); //Create empty
}
Output output = new Output();
output.addHeading(TabsValues.get().columnTotal());
output.addValue(value.getTotal());
output.addNone();
output.addHeading(TabsValues.get().columnWalletBalance());
output.addValue(value.getBalanceTotal());
output.addNone();
output.addHeading(TabsValues.get().columnAssets());
output.addValue(value.getAssetsTotal());
output.addNone();
output.addHeading(TabsValues.get().columnSellOrders());
output.addValue(value.getSellOrders());
output.addNone();
output.addHeading(TabsValues.get().columnEscrowsToCover());
output.addValue(value.getEscrows(), value.getEscrowsToCover());
output.addNone();
output.addHeading(TabsValues.get().columnBestAsset());
output.addValue(value.getBestAssetName(), value.getBestAssetValue());
output.addNone(2);
output.addHeading(TabsValues.get().columnBestShip());
output.addValue(value.getBestShipName(), value.getBestShipValue());
output.addNone(2);
/*
//FIXME - No room for Best Ship Fitted
output.addHeading(TabsValues.get().columnBestShipFitted());
output.addValue(value.getBestShipFittedName(), value.getBestShipFittedValue());
output.addNone(2);
*/
output.addHeading(TabsValues.get().columnBestModule());
output.addValue(value.getBestModuleName(), value.getBestModuleValue());
output.addNone(2);
jEditorPane.setText(output.getOutput());
jEditorPane.setCaretPosition(0);
}
public void createAndShow() {
// init dialog
setTitle(settings.getString("i18n.aboutTitle"));
setPreferredSize(new Dimension(600, 350));
setMinimumSize(new Dimension(400, 300));
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
setVisible(false);
dispose();
}
});
// sidebar
SidebarPanel sidebarPanel = new SidebarPanel(
ImageUtils.loadImage(this.sidebarImageUrl),
ImageUtils.loadImage(brandingImageUrl)
);
// about section
JEditorPane aboutPane = new JEditorPane();
aboutPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
aboutPane.setEditable(false);
aboutPane.setOpaque(true);
aboutPane.setBackground(Color.WHITE);
aboutPane.setContentType("text/html");
aboutPane.setText(replaceVariables(getAboutText()));
aboutPane.setCaretPosition(0);
aboutPane.addHyperlinkListener(e -> {
//LOGGER.debug("hyperlink / " + e.getEventType() + " / " + e.getURL());
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()))
AppUtils.browse(e.getURL());
});
JScrollPane aboutScrollPane = new JScrollPane(aboutPane);
aboutScrollPane.setOpaque(false);
aboutScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
// close button
JButton closeButton = new JButton();
closeButton.setText(settings.getString("i18n.close"));
closeButton.addActionListener(e -> {
setVisible(false);
dispose();
});
// website button
JButton websiteButton = new JButton();
websiteButton.setText(settings.getString("i18n.website"));
websiteButton.addActionListener(e -> AppUtils.browse(this.settings.getString("website.author")));
// github button
JButton githubButton = new JButton();
githubButton.setText(settings.getString("i18n.source"));
githubButton.addActionListener(e -> AppUtils.browse(this.settings.getString("website.source")));
// build bottom bar
JPanel buttonBarLeft = new JPanel(new FlowLayout());
buttonBarLeft.setOpaque(false);
buttonBarLeft.add(websiteButton);
buttonBarLeft.add(githubButton);
JPanel buttonBarRight = new JPanel(new FlowLayout());
buttonBarRight.setOpaque(false);
buttonBarRight.add(closeButton);
JPanel bottomBar = new JPanel(new BorderLayout());
bottomBar.setOpaque(false);
bottomBar.add(buttonBarLeft, BorderLayout.WEST);
bottomBar.add(buttonBarRight, BorderLayout.EAST);
// add components to the dialog
getRootPane().setOpaque(true);
getRootPane().setBackground(Color.WHITE);
getRootPane().setLayout(new BorderLayout());
getRootPane().add(sidebarPanel, BorderLayout.WEST);
getRootPane().add(aboutScrollPane, BorderLayout.CENTER);
getRootPane().add(bottomBar, BorderLayout.SOUTH);
// show dialog
pack();
setLocationRelativeTo(this.getOwner());
setVisible(true);
}
/**
* Create the dialog.
*/
public UsageDialog() {
final ResourceBundle resourceBundle = Preferences.getResourceBundle();
setTitle(resourceBundle.getString("ui.dialog.usage.title"));
setBounds(100, 100, 657, 535);
getContentPane().setLayout(new BorderLayout());
final JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.LINE_AXIS));
final JEditorPane dtrpngpxNavigator = new JEditorPane();
dtrpngpxNavigator.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
dtrpngpxNavigator.setEditable(false);
dtrpngpxNavigator.setContentType("text/html");
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
pw.println("<dl>"); //NON-NLS
Help.printHelp((option, argument, track, defaultValue) -> {
// TODO html escape
pw.print("<dt><b>--"); //NON-NLS
pw.print(option.getName());
if (argument != null) {
pw.print(" <"); //NON-NLS
pw.print(argument);
pw.print(">"); //NON-NLS
}
pw.println("</b></dt>"); //NON-NLS
pw.print("<dd>"); //NON-NLS
pw.print(option.getHelp());
if (track) {
pw.print("; ".concat(resourceBundle.getString("ui.dialog.usage.multiple")));
}
if (defaultValue != null) {
pw.print("; ".concat(resourceBundle.getString("ui.dialog.usage.default")).concat(" "));
pw.print(defaultValue);
}
pw.println("</dd>"); //NON-NLS
});
pw.println("</dl>"); //NON-NLS
pw.close();
dtrpngpxNavigator.setText(resourceBundle.getString("ui.dialog.usage.cliparams").concat(sw.toString()));
dtrpngpxNavigator.setCaretPosition(0);
final JScrollPane scrollPane = new JScrollPane(dtrpngpxNavigator);
contentPanel.add(scrollPane);
final JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
getContentPane().add(buttonPane, BorderLayout.PAGE_END);
final JButton okButton = new JButton(resourceBundle.getString("ui.dialog.usage.button.ok"));
okButton.addActionListener(e -> UsageDialog.this.dispose());
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}