List of usage examples for javax.swing JTextPane JTextPane
public JTextPane()
JTextPane
. From source file:com.mirth.connect.client.ui.ExportChannelLibrariesDialog.java
private void initComponents(Channel channel) { label1 = new JLabel(" The following code template libraries are linked to this channel:"); label1.setIcon(UIManager.getIcon("OptionPane.questionIcon")); librariesTextPane = new JTextPane(); librariesTextPane.setContentType("text/html"); HTMLEditorKit editorKit = new HTMLEditorKit(); StyleSheet styleSheet = editorKit.getStyleSheet(); styleSheet.addRule(".export-channel-libraries-dialog {font-family:\"Tahoma\";font-size:11;text-align:top}"); librariesTextPane.setEditorKit(editorKit); librariesTextPane.setEditable(false); librariesTextPane.setBackground(getBackground()); librariesTextPane.setBorder(null);/*from w w w. ja v a 2s .c om*/ StringBuilder librariesText = new StringBuilder("<html><ul class=\"export-channel-libraries-dialog\">"); for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel.getCachedCodeTemplateLibraries() .values()) { if (library.getEnabledChannelIds().contains(channel.getId()) || (library.isIncludeNewChannels() && !library.getDisabledChannelIds().contains(channel.getId()))) { librariesText.append("<li>").append(StringEscapeUtils.escapeHtml4(library.getName())) .append("</li>"); } } librariesText.append("</ul></html>"); librariesTextPane.setText(librariesText.toString()); librariesTextPane.setCaretPosition(0); librariesScrollPane = new JScrollPane(librariesTextPane); label2 = new JLabel("Do you wish to include these libraries in the channel export?"); alwaysChooseCheckBox = new JCheckBox( "Always choose this option by default in the future (may be changed in the Administrator settings)"); yesButton = new JButton("Yes"); yesButton.setMnemonic('Y'); yesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { result = JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries", true); } dispose(); } }); noButton = new JButton("No"); noButton.setMnemonic('N'); noButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { result = JOptionPane.NO_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries", false); } dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.setMnemonic('C'); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { result = JOptionPane.CANCEL_OPTION; dispose(); } }); }
From source file:net.itransformers.topologyviewer.rightclick.impl.NodeStatisticsRightClickHandler.java
public <G> void handleRightClick(JFrame parent, String v, Map<String, String> graphMLParams, Map<String, String> rightClickParams, File projectPath, File versionDir) throws Exception { Logger logger = Logger.getLogger(NodeStatisticsRightClickHandler.class); JFrame frame = new JFrame(" report for " + v + " "); frame.setSize(300, 200);/*from ww w . ja v a2 s. co m*/ frame.getContentPane().setLayout(new BorderLayout()); JTextPane text = new JTextPane(); text.setEditable(true); text.setContentType("text/html"); StringBuilder sb = new StringBuilder(); TopologyManagerFrame viewer = (TopologyManagerFrame) parent; final GraphViewerPanel viewerPanel = (GraphViewerPanel) viewer.getTabbedPane().getSelectedComponent(); final MyVisualizationViewer vv = (MyVisualizationViewer) viewerPanel.getVisualizationViewer(); Graph currentGraph = viewerPanel.getCurrentGraph(); int inDegree = currentGraph.inDegree(v); int outDegree = currentGraph.outDegree(v); sb.append("Number of incoming edges: ").append(inDegree); sb.append("\n"); sb.append("Number of outgoing edges: ").append(outDegree); text.setText(sb.toString()); JScrollPane scrollPane = new JScrollPane(text); frame.getContentPane().add("Center", scrollPane); frame.setVisible(true); }
From source file:com.clank.launcher.swing.MessageLog.java
private void initComponents() { if (colorEnabled) { JTextPane text = new JTextPane() { @Override/*from w w w . j a va 2 s .c om*/ public boolean getScrollableTracksViewportWidth() { return true; } }; this.textComponent = text; } else { JTextArea text = new JTextArea(); this.textComponent = text; text.setLineWrap(true); text.setWrapStyleWord(true); } textComponent.setFont(new JLabel().getFont()); textComponent.setEditable(false); textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE); DefaultCaret caret = (DefaultCaret) textComponent.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); document = textComponent.getDocument(); document.addDocumentListener(new LimitLinesDocumentListener(numLines, true)); JScrollPane scrollText = new JScrollPane(textComponent); scrollText.setBorder(null); scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollText, BorderLayout.CENTER); }
From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.dialogs.DownloadNotice.java
public DownloadNotice(HashMap<JSONObject, URL> downloads) { this.setDownloads(downloads); JPanel basic = new JPanel(); basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS)); add(basic);/* w ww. j a va 2 s . c o m*/ JPanel topPanel = new JPanel(new BorderLayout(0, 0)); topPanel.setMaximumSize(new Dimension(450, 0)); JLabel hint = new JLabel("CHGManager Download Manager"); hint.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0)); topPanel.add(hint); JSeparator separator = new JSeparator(); separator.setForeground(Color.gray); topPanel.add(separator, BorderLayout.SOUTH); basic.add(topPanel); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25)); this.setTextPanel(new JTextPane()); this.getTextPanel().setContentType("text/html"); String text = "<p><b>Some files are missing from your CHGManager install. Don't worry. We're trying to download them. Please don't close this panel!</b></p>"; this.getText().add(text); this.getTextPanel().setText(text); this.getTextPanel().setEditable(false); JScrollPane sp = new JScrollPane(); sp.setSize(this.getTextPanel().getSize()); basic.add(sp); //basic.add(textPanel); JPanel boxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0)); basic.add(boxPanel); JPanel bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton close = new JButton("Close"); bottom.add(close); basic.add(bottom); bottom.setMaximumSize(new Dimension(450, 0)); this.setTitle("CHGManager Download Manager"); this.setResizable(false); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); try { Thread.sleep(2000); } catch (InterruptedException e) { } this.startDownload(); }
From source file:de.huxhorn.lilith.swing.LicenseAgreementDialog.java
private void initUI() { JPanel content = new JPanel(); content.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); JTextPane licenseTextPane = new JTextPane(); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); String licenseText = null;/*ww w . j av a 2 s . c o m*/ InputStream licenseStream = LicenseAgreementDialog.class.getResourceAsStream("/licenses/license.html"); if (licenseStream != null) { try { licenseText = IOUtils.toString(licenseStream, StandardCharsets.UTF_8); } catch (IOException ex) { if (logger.isErrorEnabled()) logger.error("Exception while loading license!", ex); IOUtilities.interruptIfNecessary(ex); } finally { IOUtilities.closeQuietly(licenseStream); } } if (licenseText == null) { if (logger.isErrorEnabled()) logger.error("Couldn't find license text! Exiting!"); System.exit(-1); } licenseTextPane.setEditorKit(htmlEditorKit); licenseTextPane.setEditable(false); licenseTextPane.setText(licenseText); JScrollPane licenseScrollPane = new JScrollPane(licenseTextPane); licenseScrollPane.setPreferredSize(new Dimension(640, 480)); content.add(licenseScrollPane, BorderLayout.CENTER); content.add(buttonPanel, BorderLayout.SOUTH); AcceptAction acceptAction = new AcceptAction(); DeclineAction declineAction = new DeclineAction(); JButton acceptButton = new JButton(acceptAction); JButton declineButton = new JButton(declineAction); buttonPanel.add(acceptButton); buttonPanel.add(declineButton); setContentPane(content); licenseTextPane.setCaretPosition(0); declineButton.requestFocusInWindow(); }
From source file:com.hp.alm.ali.idea.ui.editor.field.HTMLAreaField.java
public static JTextPane createTextPane(final Project project, String value, boolean editable, boolean navigation) { JTextPane desc = new JTextPane(); desc.addHyperlinkListener(new NavigationListener(project)); enableCapability(desc, project, value, editable, navigation); return desc;//ww w .ja v a 2s . c o m }
From source file:net.rptools.maptool.client.AppSetup.java
public static void installLibrary(final String libraryName, final File root) throws IOException { // Add as a resource root AppPreferences.addAssetRoot(root);/* ww w . j av a 2 s. c o m*/ if (MapTool.getFrame() != null) { MapTool.getFrame().addAssetRoot(root); // License File licenseFile = new File(root, "License.txt"); if (!licenseFile.exists()) { licenseFile = new File(root, "license.txt"); } if (licenseFile.exists()) { final File licenseFileFinal = licenseFile; EventQueue.invokeLater(new Runnable() { public void run() { try { JTextPane pane = new JTextPane(); pane.setPage(licenseFileFinal.toURI().toURL()); JOptionPane.showMessageDialog(MapTool.getFrame(), pane, "License for " + libraryName, JOptionPane.INFORMATION_MESSAGE); } catch (MalformedURLException e) { log.error("Could not load license file: " + licenseFileFinal, e); } catch (IOException e) { log.error("Could not load license file: " + licenseFileFinal, e); } } }); } } new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { AssetManager.searchForImageReferences(root, AppConstants.IMAGE_FILE_FILTER); return null; } }.execute(); }
From source file:components.TextComponentDemo.java
public TextComponentDemo() { super("TextComponentDemo"); //Create the text pane and configure it. textPane = new JTextPane(); textPane.setCaretPosition(0);/*w ww . j a va2 s .c o m*/ textPane.setMargin(new Insets(5, 5, 5, 5)); StyledDocument styledDoc = textPane.getStyledDocument(); if (styledDoc instanceof AbstractDocument) { doc = (AbstractDocument) styledDoc; doc.setDocumentFilter(new DocumentSizeFilter(MAX_CHARACTERS)); } else { System.err.println("Text pane's document isn't an AbstractDocument!"); System.exit(-1); } JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(200, 200)); //Create the text area for the status log and configure it. changeLog = new JTextArea(5, 30); changeLog.setEditable(false); JScrollPane scrollPaneForLog = new JScrollPane(changeLog); //Create a split pane for the change log and the text area. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, scrollPaneForLog); splitPane.setOneTouchExpandable(true); //Create the status area. JPanel statusPane = new JPanel(new GridLayout(1, 1)); CaretListenerLabel caretListenerLabel = new CaretListenerLabel("Caret Status"); statusPane.add(caretListenerLabel); //Add the components. getContentPane().add(splitPane, BorderLayout.CENTER); getContentPane().add(statusPane, BorderLayout.PAGE_END); //Set up the menu bar. actions = createActionTable(textPane); JMenu editMenu = createEditMenu(); JMenu styleMenu = createStyleMenu(); JMenuBar mb = new JMenuBar(); mb.add(editMenu); mb.add(styleMenu); setJMenuBar(mb); //Add some key bindings. addBindings(); //Put the initial text into the text pane. initDocument(); textPane.setCaretPosition(0); //Start watching for undoable edits and caret changes. doc.addUndoableEditListener(new MyUndoableEditListener()); textPane.addCaretListener(caretListenerLabel); doc.addDocumentListener(new MyDocumentListener()); }
From source file:de.unentscheidbar.validation.swing.trigger.DocumentChangeTriggerTest.java
@Override protected void onSetUp() { JEditorPane text2 = new JEditorPane(); JTextPane text3 = new JTextPane(); text2.setDocument(text3.getDocument()); gui.add(text2Key, text2);/*from www . j a va 2s . co m*/ gui.add(text3Key, text3); }
From source file:de.speedprog.lantools.modules.about.AboutPanel.java
private void initialize() { setLayout(new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setPreferredSize(new Dimension(5, 200)); tabbedPane.setMaximumSize(new Dimension(32767, 300)); add(tabbedPane, "2, 2, fill, fill"); panelAppInfo = new JPanel(); tabbedPane.addTab("Application Info", null, panelAppInfo, null); panelAppInfo.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("168px:grow"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); scrollPaneAppInfo = new JScrollPane(); panelAppInfo.add(scrollPaneAppInfo, "1, 2, fill, fill"); textPaneAppInfo = new JTextPane(); textPaneAppInfo.setEditable(false);/*w w w . jav a 2 s . co m*/ textPaneAppInfo.setText(APP_INFO); scrollPaneAppInfo.setViewportView(textPaneAppInfo); panelDepInfo = new JPanel(); tabbedPane.addTab("Dependency Information", null, panelDepInfo, null); panelDepInfo.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); scrollPaneDepInfo = new JScrollPane(); panelDepInfo.add(scrollPaneDepInfo, "2, 2, fill, fill"); textPaneDepInfo = new JTextPane(); textPaneDepInfo.setEditable(false); textPaneDepInfo.setContentType("text/html"); textPaneDepInfo.setText(DEP_INFO); scrollPaneDepInfo.setViewportView(textPaneDepInfo); }