List of usage examples for javax.swing JEditorPane JEditorPane
public JEditorPane()
JEditorPane
. From source file:embedding.ExampleJava2D2PDF.java
/** * Creates a PDF file. The contents are painted using a Graphics2D implementation that * generates an PDF file.// w ww .j a va 2 s . c om * @param outputFile the target file * @throws IOException In case of an I/O error * @throws ConfigurationException if an error occurs configuring the PDF output */ public void generatePDF(File outputFile) throws IOException, ConfigurationException { OutputStream out = new java.io.FileOutputStream(outputFile); out = new java.io.BufferedOutputStream(out); try { //Instantiate the PDFDocumentGraphics2D instance PDFDocumentGraphics2D g2d = new PDFDocumentGraphics2D(false); g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); //Configure the G2D with the necessary fonts configure(g2d, createAutoFontsConfiguration()); //Set up the document size Dimension pageSize = new Dimension((int) Math.ceil(UnitConv.mm2pt(210)), (int) Math.ceil(UnitConv.mm2pt(297))); //page size A4 (in pt) g2d.setupDocument(out, pageSize.width, pageSize.height); g2d.translate(144, 72); //Establish some page borders //A few rectangles rotated and with different color Graphics2D copy = (Graphics2D) g2d.create(); int c = 12; for (int i = 0; i < c; i++) { float f = ((i + 1) / (float) c); Color col = new Color(0.0f, 1 - f, 0.0f); copy.setColor(col); copy.fillRect(70, 90, 50, 50); copy.rotate(-2 * Math.PI / c, 70, 90); } copy.dispose(); //Some text g2d.rotate(-0.25); g2d.setColor(Color.RED); g2d.setFont(new Font("sans-serif", Font.PLAIN, 36)); g2d.drawString("Hello world!", 140, 140); g2d.setColor(Color.RED.darker()); g2d.setFont(new Font("serif", Font.PLAIN, 36)); g2d.drawString("Hello world!", 140, 180); pageSize = new Dimension(pageSize.height, pageSize.width); g2d.nextPage(pageSize.width, pageSize.height); //Demonstrate painting rich text String someHTML = "<html><body style=\"font-family:Verdana\">" + "<p>Welcome to <b>page 2!</b></p>" + "<h2>PDFDocumentGraphics2D Demonstration</h2>" + "<p>We can <i>easily</i> paint some HTML here!</p>" + "<p style=\"color:green;\">" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin accumsan" + " condimentum ullamcorper. Sed varius quam id arcu fermentum luctus. Praesent" + " nisi ligula, cursus sed vestibulum vel, sodales sed lectus.</p>" + "</body></html>"; JEditorPane htmlComp = new JEditorPane(); htmlComp.setContentType("text/html"); htmlComp.read(new StringReader(someHTML), null); htmlComp.setSize(new Dimension(pageSize.width - 72, pageSize.height - 72)); //htmlComp.setBackground(Color.ORANGE); htmlComp.validate(); htmlComp.printAll(g2d); //Cleanup g2d.finish(); } finally { IOUtils.closeQuietly(out); } }
From source file:fxts.stations.ui.help.HelpPane.java
/** * Inits all components./*from w w w.jav a2 s. c o m*/ */ private void initComponents() { //creates history mHistory = new HelpContentHistory(); //Create the text area for contents mTabbedPane = new JTabbedPane(); //creates content tree mContentTree = new ContentTree("fxts/stations/trader/resources/help/contents.xml"); mContentTree.addListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(mContentTree.getTree()); mTabbedPane.addTab(mResMan.getString("IDS_HELP_CONTENTS", "Contents"), treeView); //xxx workaround for bug #6424509, memory leak JEditorPane.registerEditorKitForContentType("text/html", WeakHTMLEditorKit.class.getName()); //creates the text area for the showing of the help. mHtmlPage = new JEditorPane(); mHtmlPage.setEditable(false); mHtmlPage.putClientProperty("charset", "UTF-16"); mHtmlPage.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent aEvent) { if (aEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { onSelectContentByHyperlink(aEvent.getURL()); mHtmlPage.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } catch (Exception e) { mLogger.error("Hiperlink not processed!"); e.printStackTrace(); } } } }); JScrollPane scrollPane = new JScrollPane(mHtmlPage); //creates a split pane for the change log and the text area. mSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTabbedPane, scrollPane); mSplitPane.setOneTouchExpandable(true); //Creates the toolbar area. JToolBar toolbar = UIManager.getInst().createToolBar(); toolbar.setFloatable(false); //creates label with left arrow UIManager uiMan = UIManager.getInst(); mBackButton = uiMan.createButton(null, "ID_HELP_LEFT_ARROW", "ID_HELP_LEFT_ARROW_DESC", "ID_HELP_LEFT_ARROW_DESC"); mBackButton.setEnabled(false); mBackButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { if (mHistory.hasBackStep()) { mIsHistorycalStep = true; onSelectContent(mHistory.back()); mBackButton.setEnabled(mHistory.hasBackStep()); mForwardButton.setEnabled(mHistory.hasForwardStep()); } } }); toolbar.add(mBackButton); //creates label with right arrow mForwardButton = uiMan.createButton(null, "ID_HELP_RIGHT_ARROW", "ID_HELP_RIGHT_ARROW_DESC", "ID_HELP_RIGHT_ARROW_DESC"); mForwardButton.setEnabled(false); mForwardButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { if (mHistory.hasForwardStep()) { mIsHistorycalStep = true; onSelectContent(mHistory.forward()); mBackButton.setEnabled(mHistory.hasBackStep()); mForwardButton.setEnabled(mHistory.hasForwardStep()); } } }); toolbar.add(mForwardButton); //creates label with up arrow mUpButton = uiMan.createButton(null, "ID_HELP_UP_ARROW", "ID_HELP_UP_ARROW_DESC", "ID_HELP_UP_ARROW_DESC"); mUpButton.setEnabled(mContentTree.getIterator().hasPrevious()); mUpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { mContentsBrowsing = true; onSelectContent(mContentTree.getIterator().previous()); mUpButton.setEnabled(mContentTree.getIterator().hasPrevious()); mDownButton.setEnabled(mContentTree.getIterator().hasNext()); } }); toolbar.add(mUpButton); //creates label with down arrow mDownButton = uiMan.createButton(null, "ID_HELP_DOWN_ARROW", "ID_HELP_DOWN_ARROW_DESC", "ID_HELP_DOWN_ARROW_DESC"); mDownButton.setEnabled(mContentTree.getIterator().hasNext()); mDownButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { mContentsBrowsing = true; onSelectContent(mContentTree.getIterator().next()); mUpButton.setEnabled(mContentTree.getIterator().hasPrevious()); mDownButton.setEnabled(mContentTree.getIterator().hasNext()); } }); toolbar.add(mDownButton); //sets layout setLayout(new BorderLayout()); //add the components to the frame. add(mSplitPane, BorderLayout.CENTER); add(toolbar, BorderLayout.NORTH); //sets first page onSelectContent(mContentTree.getIterator().toBegin()); }
From source file:com.fedroot.dacs.swing.DacsNoticePresentationDialog.java
/** * Called by constructors to initialize the dialog. */// w w w . j ava 2 s . c om @Override protected void dialogInit() { if (labels == null) { setLocale(Locale.getDefault()); } ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == acceptButton) { pressed_ACCEPT = true; DacsNoticePresentationDialog.this.setVisible(false); } else if (source == declineButton) { pressed_ACCEPT = false; DacsNoticePresentationDialog.this.setVisible(false); } else { pressed_ACCEPT = false; DacsNoticePresentationDialog.this.setVisible(false); } } }; acceptButton = new JButton(labels.getString("dialog.accept")); declineButton = new JButton(labels.getString("dialog.decline")); super.dialogInit(); JPanel inputpane = new JPanel(new FlowLayout()); inputpane.add(acceptButton); inputpane.add(declineButton); acceptButton.addActionListener(actionListener); inputpane.add(acceptButton); declineButton.addActionListener(actionListener); inputpane.add(declineButton); htmlpane = new JEditorPane(); // htmlpane.setContentType("image/png"); htmlpane.setEditable(false); // initialize htmlpane with something setDocumentContent("text/html", "<html><body><img src=\"http://fedroot.com/images/rick-and-frog.jpg\" width=400 height=300></body></html>"); // not set when called from super() setDocumentContent(this.content); JScrollPane presentation = new JScrollPane(htmlpane); JPanel pane = new JPanel(); pane.setLayout(new BorderLayout()); pane.add(presentation, BorderLayout.CENTER); pane.add(inputpane, BorderLayout.SOUTH); Container container = getContentPane(); container.add(pane); container.setSize(600, 400); pack(); }
From source file:com.eviware.soapui.support.SoapUIVersionUpdate.java
protected JEditorPane createReleaseNotesPane() { JEditorPane text = new JEditorPane(); try {//ww w.j a v a 2 s . c o m text.setPage(getReleaseNotes()); text.setEditable(false); text.setBorder(BorderFactory.createLineBorder(Color.black)); } catch (IOException e) { text.setText(NO_RELEASE_NOTES_INFO); SoapUI.logError(e); } return text; }
From source file:org.jfree.chart.demo.SuperDemo.java
private JPanel createSourceCodePanel() { JPanel jpanel = new JPanel(new BorderLayout()); jpanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); JEditorPane jeditorpane = new JEditorPane(); jeditorpane.setEditable(false);//from w w w . ja v a 2s . co m java.net.URL url = (SuperDemo.class).getResource("source.html"); if (url != null) try { jeditorpane.setPage(url); } catch (IOException ioexception) { System.err.println("Attempted to read a bad URL: " + url); } else System.err.println("Couldn't find file: source.html"); JScrollPane jscrollpane = new JScrollPane(jeditorpane); jscrollpane.setVerticalScrollBarPolicy(20); jscrollpane.setPreferredSize(new Dimension(250, 145)); jscrollpane.setMinimumSize(new Dimension(10, 10)); jpanel.add(jscrollpane); return jpanel; }
From source file:fedroot.dacs.swingdemo.DacsClientFrame.java
/** * //from w w w. ja va 2 s . c om * @param dacsClientContext * @param feduri * @throws java.lang.Exception */ public DacsClientFrame(DacsClientContext dacsClientContext, Federation federation) throws Exception { logger.log(Level.INFO, "Federation {0}", federation.getFederationName()); this.federation = federation; this.dacsClientContext = dacsClientContext; // this.dacsClientContext.setDacs902EventHandler(federation, new Event902Handler(this)); // this.dacsClientContext.setDacs905EventHandler(federation, new Event905Handler(this)); JPanel mainPanel = new JPanel(new BorderLayout()); JPanel gotoUrlPanel = new JPanel(new FlowLayout()); JPanel actionPanel = new JPanel(new FlowLayout()); JPanel modifiersPanel = new JPanel(new FlowLayout()); /** Enable/Disable DACS Check_only mode */ checkOnlyCheckBox = new JCheckBox("Enable DACS Check Only", false); checkOnlyCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (checkOnlyCheckBox.isSelected()) { enableEventHandlingCheckBox.setSelected(false); enableEventHandlingCheckBox.setEnabled(false); } else { enableEventHandlingCheckBox.setEnabled(true); } } }); /** Enable/Disable Event Handling */ enableEventHandlingCheckBox = new JCheckBox("Enable Event Handling", false); final JButton btnGOTO = new JButton("Goto URL"); btnGOTO.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { followUrl(new URI(urlTextField.getText().trim())); } catch (URISyntaxException ex) { // TODO implement popup for error messages } } }); final JButton btnGO = new JButton("GO"); btnGO.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { followUrl(new URI(actionUrls[actionsComboBox.getSelectedIndex()])); } catch (URISyntaxException ex) { // TODO implement popup for error messages } } }); final JButton btnUSERNAMES = new JButton("Usernames"); btnUSERNAMES.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { createAndShowDacsUsernameFrame(); } }); final JButton btnLOGIN = new JButton("Login"); btnLOGIN.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { createAndShowLoginFrame(); } }); final JButton btnNAT = new JButton("NATs"); btnNAT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { createAndShowDacsNatFrame(); } }); Container container = this.getContentPane(); actionsComboBox = new JComboBox(actions); actionsComboBox.setToolTipText("Select an Action"); actionsComboBox.setEditable(true); actionsComboBox.setSelectedIndex(0); JLabel actionLabel = new JLabel("Action:"); urlTextField = new TextField(70); urlTextField.setEditable(true); gotoUrlPanel.add(urlTextField); gotoUrlPanel.add(btnGOTO); actionPanel.add(actionLabel); actionPanel.add(actionsComboBox); actionPanel.add(btnGO); actionPanel.add(btnLOGIN); actionPanel.add(btnUSERNAMES); actionPanel.add(btnNAT); mainPanel.add(gotoUrlPanel, BorderLayout.NORTH); mainPanel.add(actionPanel, BorderLayout.SOUTH); modifiersPanel.add(checkOnlyCheckBox); modifiersPanel.add(enableEventHandlingCheckBox); JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel); splitInputPane.setOneTouchExpandable(false); responseTextArea = new JTextArea(); responseTextArea.setEditable(false); responseTextArea.setCaretPosition(0); htmlPane = new JEditorPane(); // htmlPane.setContentType("image/png"); htmlPane.setEditable(false); JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea), new JScrollPane(htmlPane)); splitResponsePane.setOneTouchExpandable(false); splitResponsePane.setResizeWeight(0.35); container.setLayout(new BorderLayout()); container.add(splitInputPane, BorderLayout.NORTH); container.add(splitResponsePane, BorderLayout.CENTER); }
From source file:fedroot.dacs.swingdemo.DemoFrame.java
/** * /* www . j a v a2s . c o m*/ * @param dacsClientContext * @param feduri * @throws java.lang.Exception */ public DemoFrame(DacsClientContext dacsClientContext, Federation federation) throws Exception { logger.log(Level.INFO, "Federation {0}", federation.getFederationName()); this.federation = federation; this.dacsClientContext = dacsClientContext; // this.dacsClientContext.setDacs902EventHandler(federation, new Event902Handler(this)); // this.dacsClientContext.setDacs905EventHandler(federation, new Event905Handler(this)); JPanel mainPanel = new JPanel(new BorderLayout()); JPanel gotoUrlPanel = new JPanel(new FlowLayout()); JPanel actionPanel = new JPanel(new FlowLayout()); JPanel modifiersPanel = new JPanel(new FlowLayout()); /** Enable/Disable DACS Check_only mode */ checkOnlyCheckBox = new JCheckBox("Enable DACS Check Only", false); checkOnlyCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (checkOnlyCheckBox.isSelected()) { enableEventHandlingCheckBox.setSelected(false); enableEventHandlingCheckBox.setEnabled(false); } else { enableEventHandlingCheckBox.setEnabled(true); } } }); /** Enable/Disable Event Handling */ enableEventHandlingCheckBox = new JCheckBox("Enable Event Handling", false); final JButton btnGOTO = new JButton("Goto URL"); btnGOTO.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { followUrl(new URI(urlTextField.getText().trim())); } catch (URISyntaxException ex) { // TODO implement popup for error messages } } }); final JButton btnGO = new JButton("GO"); btnGO.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { followUrl(new URI(actionUrls[actionsComboBox.getSelectedIndex()])); } catch (URISyntaxException ex) { // TODO implement popup for error messages } } }); final JButton btnUSERNAMES = new JButton("Usernames"); btnUSERNAMES.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { createAndShowDacsUsernameFrame(); } }); final JButton btnLOGIN = new JButton("Login"); btnLOGIN.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { createAndShowLoginFrame(); } }); final JButton btnNAT = new JButton("NATs"); btnNAT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { createAndShowDacsNatFrame(); } }); Container container = this.getContentPane(); actionsComboBox = new JComboBox(actions); actionsComboBox.setToolTipText("Select an Action"); actionsComboBox.setEditable(true); actionsComboBox.setSelectedIndex(0); JLabel actionLabel = new JLabel("Action:"); urlTextField = new TextField(70); urlTextField.setEditable(true); gotoUrlPanel.add(urlTextField); gotoUrlPanel.add(btnGOTO); actionPanel.add(actionLabel); actionPanel.add(actionsComboBox); actionPanel.add(btnGO); actionPanel.add(btnLOGIN); actionPanel.add(btnUSERNAMES); actionPanel.add(btnNAT); mainPanel.add(gotoUrlPanel, BorderLayout.NORTH); mainPanel.add(actionPanel, BorderLayout.SOUTH); modifiersPanel.add(checkOnlyCheckBox); modifiersPanel.add(enableEventHandlingCheckBox); JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel); splitInputPane.setOneTouchExpandable(false); responseTextArea = new JTextArea(); responseTextArea.setEditable(false); responseTextArea.setCaretPosition(0); htmlPane = new JEditorPane(); // htmlPane.setContentType("image/png"); htmlPane.setEditable(false); JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea), new JScrollPane(htmlPane)); splitResponsePane.setOneTouchExpandable(false); splitResponsePane.setResizeWeight(0.35); container.setLayout(new BorderLayout()); container.add(splitInputPane, BorderLayout.NORTH); container.add(splitResponsePane, BorderLayout.CENTER); }
From source file:net.sf.housekeeper.swing.MainFrame.java
/** * Shows the About dialog for the application. *//* w w w. j a v a2 s. c om*/ private void showAboutDialog() { final JEditorPane editorPane = new JEditorPane(); editorPane.setEditable(false); final String aboutFile = "/net/sf/housekeeper/about.html"; final URL helpURL = MainFrame.class.getResource(aboutFile); if (helpURL != null) { try { editorPane.setPage(helpURL); } catch (IOException ex) { LogFactory.getLog(MainFrame.AboutDialogAction.class) .error("Attempted to read a bad URL: " + helpURL, ex); } } else { LogFactory.getLog(MainFrame.AboutDialogAction.class).error("Could not find file: " + aboutFile); } editorPane.setPreferredSize(new Dimension(400, 200)); JOptionPane.showMessageDialog(view, editorPane); }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java
private void initComponents() { ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel(); jtExtensions = new JKseTable(extensionsTableModel); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel); sorter.setComparator(2, new ObjectIdComparator()); jtExtensions.setRowSorter(sorter);// www .ja v a2s .c o m jtExtensions.setShowGrid(false); jtExtensions.setRowMargin(0); jtExtensions.getColumnModel().setColumnMargin(0); jtExtensions.getTableHeader().setReorderingAllowed(false); jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS); jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight())); for (int i = 0; i < jtExtensions.getColumnCount(); i++) { TableColumn column = jtExtensions.getColumnModel().getColumn(i); column.setHeaderRenderer( new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer())); column.setCellRenderer(new ExtensionsTableCellRend()); } TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0); criticalCol.setResizable(false); criticalCol.setMinWidth(28); criticalCol.setMaxWidth(28); criticalCol.setPreferredWidth(28); ListSelectionModel selectionModel = jtExtensions.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { try { CursorUtil.setCursorBusy(DViewExtensions.this); updateExtensionValue(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } } }); jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground()); jpExtensionsTable = new JPanel(new BorderLayout(5, 5)); jpExtensionsTable.setPreferredSize(new Dimension(500, 200)); jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER); jpExtensionValue = new JPanel(new BorderLayout(5, 5)); jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text")); jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH); jepExtensionValue = new JEditorPane(); jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize())); jepExtensionValue.setEditable(false); jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip")); // JGoodies - keep uneditable color same as editable jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE); // for displaying URLs in extensions as clickable links jepExtensionValue.setContentType("text/html"); jepExtensionValue.addHyperlinkListener(this); // use default font and foreground color from the component jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5)); jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200)); jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER); jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER); jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text")); PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0)); jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip")); jbAsn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DViewExtensions.this); asn1DumpPressed(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } }); jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jpExtensionValueAsn1.add(jbAsn1); jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH); jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5)); jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)))); jpExtensions.add(jpExtensionsTable); jpExtensions.add(jpExtensionValue); jbOK = new JButton(res.getString("DViewExtensions.jbOK.text")); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false); extensionsTableModel.load(extensions); if (extensionsTableModel.getRowCount() > 0) { jtExtensions.changeSelection(0, 0, false, false); } getContentPane().add(jpExtensions, BorderLayout.CENTER); getContentPane().add(jpOK, BorderLayout.SOUTH); setResizable(false); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); getRootPane().setDefaultButton(jbOK); pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jbOK.requestFocus(); } }); }
From source file:net.sf.jabref.gui.PreviewPanel.java
private void createPreviewPane() { previewPane = new JEditorPane() { @Override//from w ww . j av a2s.com public Dimension getPreferredScrollableViewportSize() { return getPreferredSize(); } }; previewPane.setMargin(new Insets(3, 3, 3, 3)); previewPane.setComponentPopupMenu(createPopupMenu()); previewPane.setEditable(false); previewPane.setDragEnabled(true); // this has an effect only, if no custom transfer handler is registered. We keep the statement if the transfer handler is removed. previewPane.setContentType("text/html"); previewPane.addHyperlinkListener(hyperlinkEvent -> { if ((hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) && PreviewPanel.this.databaseContext.isPresent()) { try { String address = hyperlinkEvent.getURL().toString(); JabRefDesktop.openExternalViewer(PreviewPanel.this.databaseContext.get(), address, FieldName.URL); } catch (IOException e) { LOGGER.warn("Could not open external viewer", e); } } }); }