List of usage examples for javax.swing JEditorPane getDocument
public Document getDocument()
From source file:org.geworkbench.components.lincs.LincsInterface.java
private void viewLicense_actionPerformed(String FileName) { getLicenseFromFile(FileName);/* ww w.j a va2 s . c om*/ JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(licenseContent); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle("Lincs Interface License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(this); licenseDialog.setVisible(true); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java
/** * Display a dialog box with a components license in it. * /*w w w.j a v a 2s . c o m*/ * @param ActionEvent * @return void */ private void viewLicense_actionPerformed(ActionEvent e) { int[] selectedRow = table.getSelectedRows(); String license = "Select a component in order to view its license."; String componentName = null; if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) { int modelRow = table.convertRowIndexToModel(selectedRow[0]); license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.LICENSE_INDEX); componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.NAME_INDEX); } JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(license); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle(componentName + " License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(frame); licenseDialog.setVisible(true); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java
/** * Display a dialog box with a components license in it. * /*from ww w . j a v a2 s.com*/ * @param ActionEvent * @return void */ private void viewLicense_actionPerformed(ActionEvent e) { int[] selectedRow = table.getSelectedRows(); String license = "Select a component in order to view its license."; String componentName = null; if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) { int modelRow = table.convertRowIndexToModel(selectedRow[0]); license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.LICENSE_INDEX); componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.NAME_INDEX); } JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(license); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle(componentName + " License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(frame); licenseDialog.setVisible(true); }
From source file:org.netbeans.modules.mongodb.ui.windows.MapReduceTopComponent.java
private void initEditor(JEditorPane epEditor) { epEditor.setEditorKit(CloneableEditorSupport.getEditorKit("text/x-javascript")); try {// ww w. j a v a 2s . c om FileObject fob = FileUtil.createMemoryFileSystem().getRoot().createData(epEditor.getName(), "js"); epEditor.getDocument().putProperty(javax.swing.text.Document.StreamDescriptionProperty, DataObject.find(fob)); DialogBinding.bindComponentToFile(fob, 0, 0, epEditor); } catch (IOException ex) { } }
From source file:tvbrowser.ui.settings.channel.ChannelGroupInfoDialog.java
/** * Create the GUI// w w w . jav a 2s . c om */ private void initGui() { UiUtilities.registerForClosing(this); JPanel panel = (JPanel) getContentPane(); panel.setBorder(Borders.DLU4_BORDER); panel.setLayout(new FormLayout("fill:default:grow, default", "fill:default:grow, 3dlu, default")); CellConstraints cc = new CellConstraints(); final JEditorPane infoPanel = new JEditorPane(); infoPanel.setEditorKit(new ExtendedHTMLEditorKit()); ExtendedHTMLDocument doc = (ExtendedHTMLDocument) infoPanel.getDocument(); infoPanel.setEditable(false); infoPanel.setText(generateHtml(doc)); infoPanel.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = evt.getURL(); if (url != null) { Launch.openURL(url.toString()); } } } }); final JScrollPane scrollPane = new JScrollPane(infoPanel); panel.add(scrollPane, cc.xyw(1, 1, 2)); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { infoPanel.scrollRectToVisible(new Rectangle(0, 0)); } }); panel.add(ok, cc.xy(2, 3)); setSize(500, 350); }
From source file:tvbrowser.ui.settings.PluginInfoDialog.java
/** * Create the GUI//from w ww . ja v a 2s.c o m */ private void initGui() { JPanel panel = (JPanel) getContentPane(); panel.setBorder(Borders.DLU4_BORDER); panel.setLayout(new FormLayout("fill:default:grow, default", "fill:default:grow, 3dlu, default")); CellConstraints cc = new CellConstraints(); JEditorPane infoPanel = new JEditorPane(); infoPanel.setEditorKit(new ExtendedHTMLEditorKit()); ExtendedHTMLDocument doc = (ExtendedHTMLDocument) infoPanel.getDocument(); infoPanel.setEditable(false); infoPanel.setText(generateHtml(doc)); infoPanel.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = evt.getURL(); if (url != null) { Launch.openURL(url.toString()); } } } }); panel.add(new JScrollPane(infoPanel), cc.xyw(1, 1, 2)); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { close(); } }); panel.add(ok, cc.xy(2, 3)); Settings.layoutWindow("pluginInfoDialog", this, new Dimension(700, 500)); UiUtilities.registerForClosing(this); }