List of usage examples for javax.swing JEditorPane getCaretPosition
@Transient public int getCaretPosition()
From source file:org.geworkbench.components.lincs.LincsInterface.java
private void viewLicense_actionPerformed(String FileName) { getLicenseFromFile(FileName);/* w w w .j av a 2 s .c o m*/ 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 .ja v a 2s . co 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. * /*w w w . j a va2 s.c om*/ * @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); }