Java Code Examples for javax.swing.JTextPane#setEditable()
The following examples show how to use
javax.swing.JTextPane#setEditable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogPane.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
/** * Create the log pane, with a standard mailbox. */ public LogPane () { // Build the scroll pane component = new JScrollPane(); component.setBorder(null); // log/status area logArea = new JTextPane(); logArea.setEditable(false); logArea.setMargin(new Insets(5, 5, 5, 5)); document = (AbstractDocument) logArea.getStyledDocument(); // Let the scroll pane display the log area component.setViewportView(logArea); }
Example 2
Source File: SwingStrategyDescriptionPanel.java From atdl4j with MIT License | 6 votes |
public JPanel buildStrategyDescriptionPanel(Window aParentContainer, Atdl4jOptions atdl4jOptions) { setAtdl4jOptions(atdl4jOptions); container = new JPanel(new BorderLayout()); container.setBorder(new TitledBorder("Strategy Description")); strategyDescription = new JTextPane(); strategyDescription.setContentType("text/html"); strategyDescription.setFont(new JLabel().getFont()); strategyDescription.setEditable(false); JScrollPane tempScrollPane = new JScrollPane(strategyDescription); container.add(tempScrollPane, BorderLayout.CENTER); return container; }
Example 3
Source File: HistoryCellRenderer.java From EchoSim with Apache License 2.0 | 6 votes |
@Override public Component getListCellRendererComponent( JList<? extends TransactionBean> list, TransactionBean value, int index, boolean isSelected, boolean cellHasFocus) { JTextPane client = new JTextPane(); client.setEditable(false); client.setContentType("text/html"); TransactionRenderOpsBean ops = mRuntime.getRenderOps(); String html = TransactionLogic.renderAsHTML(value, ops); int w = list.getFixedCellWidth(); if (w < 0) w = 750; else w = w*3/4; html = "<html><body><table width=\""+w+"px\">"+html+"</table></body></html>"; client.setText(html); if (cellHasFocus) client.setBorder(new MatteBorder(1, 5, 1, 1, Color.DARK_GRAY)); client.setBackground(isSelected ? SELECTED : DESELECTED); return client; }
Example 4
Source File: TextPaneAppender.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void setTextPane(JTextPane textpane) { this.textpane=textpane; textpane.setEditable(false); textpane.setBackground(Color.lightGray); this.doc=textpane.getStyledDocument(); }
Example 5
Source File: ROCViewer.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public ROCViewer(AreaUnderCurve auc) { setLayout(new BorderLayout()); String message = auc.toString(); criterionName = auc.getName(); // info string JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); infoPanel.setOpaque(true); infoPanel.setBackground(Colors.WHITE); JTextPane infoText = new JTextPane(); infoText.setEditable(false); infoText.setBackground(infoPanel.getBackground()); infoText.setFont(infoText.getFont().deriveFont(Font.BOLD)); infoText.setText(message); infoPanel.add(infoText); add(infoPanel, BorderLayout.NORTH); // plot panel plotter = new ROCChartPlotter(); plotter.addROCData("ROC", auc.getRocData()); JPanel innerPanel = new JPanel(new BorderLayout()); innerPanel.add(plotter, BorderLayout.CENTER); innerPanel.setBorder(BorderFactory.createMatteBorder(5, 0, 10, 10, Colors.WHITE)); add(innerPanel, BorderLayout.CENTER); }
Example 6
Source File: ApplicationXML.java From wandora with GNU General Public License v3.0 | 5 votes |
@Override protected JComponent getTextComponent(String locator) throws Exception { JTextPane textComponent = new JTextPane(); textComponent.setText(getContent(locator)); textComponent.setFont(new Font("monospaced", Font.PLAIN, 12)); textComponent.setEditable(false); textComponent.setCaretPosition(0); textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); return textComponent; }
Example 7
Source File: VersionPane.java From bigtable-sql with Apache License 2.0 | 5 votes |
public void mouseMoved(MouseEvent ev) { JTextPane editor = (JTextPane) ev.getSource(); editor.setEditable(false); Point pt = new Point(ev.getX(), ev.getY()); int pos = editor.viewToModel(pt); if (pos >= 0) { Document eDoc = editor.getDocument(); if (eDoc instanceof DefaultStyledDocument) { DefaultStyledDocument hdoc = (DefaultStyledDocument) eDoc; Element e = hdoc.getCharacterElement(pos); AttributeSet a = e.getAttributes(); AttributeSet tagA = (AttributeSet) a.getAttribute(HTML.Tag.A); String href = null; if (tagA!=null){ href = (String)tagA.getAttribute(HTML.Attribute.HREF); } if (href != null) { editor.setToolTipText(href); if (editor.getCursor().getType() != Cursor.HAND_CURSOR) { editor.setCursor(new Cursor(Cursor.HAND_CURSOR)); } } else { editor.setToolTipText(null); if (editor.getCursor().getType() != Cursor.DEFAULT_CURSOR) { editor.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } } else { editor.setToolTipText(null); } }
Example 8
Source File: ManualScriptPanel.java From EchoSim with Apache License 2.0 | 5 votes |
private void initInstantiate() { mGenerate = new JButton("Generate Script"); mExhaustive = new JCheckBox("All Possible Test Cases"); mExhaustive.setSelected(true); mNumberOfTests = new JSpinner(); mNumberOfTests.setEnabled(false); mRandomize = new JCheckBox("Randomize Order"); mUseHistory = new JCheckBox("Use History"); mUseHistory.setToolTipText("Use currently logged history to generate 'expected' results"); mScript = new JTextPane(); mScript.setContentType("text/html"); mScript.setEditable(false); }
Example 9
Source File: AboutDialog.java From rest-client with Apache License 2.0 | 5 votes |
/** * * @Title: init * @Description: Component Initialization * @param * @return void * @throws */ private void init() { this.setTitle(RESTConst.ABOUT_TOOL); this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH)); JPanel pnlDialog = new JPanel(); pnlDialog.setLayout(new BorderLayout()); JLabel lblTitle = new JLabel("<html><h3>" + RESTConst.REST_CLIENT_VERSION + "</h3></html>"); JPanel pnlNorth = new JPanel(); pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER)); pnlNorth.add(lblTitle); pnlDialog.add(pnlNorth, BorderLayout.NORTH); JPanel pnlCenter = new JPanel(); pnlCenter.setLayout(new GridLayout(1, 1)); JTextPane tp = new JTextPane(); tp.setEditable(false); tp.setContentType("text/html"); tp.setText(UIUtil.contents(RESTConst.WISDOM_TOOL_ORG)); pnlCenter.add(new JScrollPane(tp)); pnlDialog.add(pnlCenter, BorderLayout.CENTER); JPanel pnlSouth = new JPanel(); pnlSouth.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton btnOK = new JButton(RESTConst.OK); btnOK.addActionListener(this); btnOK.requestFocus(); getRootPane().setDefaultButton(btnOK); pnlSouth.add(btnOK); pnlDialog.add(pnlSouth, BorderLayout.SOUTH); this.setContentPane(pnlDialog); this.setIconImage(UIUtil.getImage(RESTConst.LOGO)); this.pack(); }
Example 10
Source File: PlayerInfoSummaryTextArea.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a text area with the players name, their IP and system ID. */ JComponent buildPlayerInfoSummary(final JDialog dialog, final PlayerSummary playerSummary) { final JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setText(buildPlayerInfoText(playerSummary)); textPane.addKeyListener(SwingComponents.escapeKeyListener(dialog::dispose)); return textPane; }
Example 11
Source File: VCSNotificationDisplayer.java From netbeans with Apache License 2.0 | 5 votes |
private JTextPane getPane(File[] files, File projectDir, String url, String revision) { JTextPane bubble = new JTextPane(); bubble.setOpaque(false); bubble.setEditable(false); if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { //NOI18N //#134837 //http://forums.java.net/jive/thread.jspa?messageID=283882 bubble.setBackground(new Color(0, 0, 0, 0)); } bubble.setContentType("text/html"); //NOI18N setupPane(bubble, files, projectDir, url, revision); return bubble; }
Example 12
Source File: CapabilityResponsePopUp.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override protected Window createComponent() { JDialog window = new JDialog(null, "Response to " + command, ModalityType.MODELESS); window.setAlwaysOnTop(false); window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // TODO remember dimensions window.setSize(800, 600); installEscapeCloseOperation(window); response = new JTextPane(); response.setEditable(false); response.setContentType("text/html"); response.setText(text); response.setCaretPosition(0); scroller = new JScrollPane(this.response); form = new FormView(); form.addField( Fields .textFieldBuilder() .notEditable() .labelled("Status") .named("status") .build() ); form.addField( Fields .textFieldBuilder() .notEditable() .labelled("From") .named("from") .build() ); form.addField( Fields .textFieldBuilder() .notEditable() .labelled("Type") .named("type") .build() ); form.addField( new JLabel("Attributes"), scroller, LabelLocation.TOP ); window.add(form.getComponent()); return window; }
Example 13
Source File: PlayerChunkViewer.java From ChickenChunks with MIT License | 4 votes |
public TicketInfoDialog(LinkedList<TicketInfo> tickets) { super(PlayerChunkViewer.this); setModalityType(ModalityType.DOCUMENT_MODAL); this.tickets = tickets; infoPane = new JTextPane(); infoPane.setEditable(false); infoPane.setOpaque(false); infoPane.setContentType("text/html"); infoScrollPane = new JScrollPane(infoPane); infoScrollPane.setOpaque(false); add(infoScrollPane); chunkPane = new JTextPane(); chunkPane.setEditable(false); chunkPane.setOpaque(false); chunkPane.setContentType("text/html"); chunkScrollPane = new JScrollPane(chunkPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(chunkScrollPane); ticketComboBox = new JComboBox<String>(); for(TicketInfo ticket : tickets) { String ident = ticket.modId; if(ticket.player != null) ident += ", " + ticket.player; ident += " #" + ticket.ID; ticketComboBox.addItem(ident); } add(ticketComboBox); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { dialog = null; } }); setLayout(this); setSize(getPreferredSize()); setLocationRelativeTo(null); pack(); dialog = this; setVisible(true); }
Example 14
Source File: DataTypePanel.java From ghidra with Apache License 2.0 | 4 votes |
private void create() { textPane = new JTextPane(); doc = textPane.getStyledDocument(); add(textPane, BorderLayout.CENTER); textPane.setEditable(false); pathAttrSet = new SimpleAttributeSet(); pathAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); pathAttrSet.addAttribute(StyleConstants.FontSize, new Integer(11)); pathAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); pathAttrSet.addAttribute(StyleConstants.Foreground, MergeConstants.CONFLICT_COLOR); nameAttrSet = new SimpleAttributeSet(); nameAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); nameAttrSet.addAttribute(StyleConstants.FontSize, new Integer(11)); nameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); sourceAttrSet = new SimpleAttributeSet(); sourceAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); sourceAttrSet.addAttribute(StyleConstants.FontSize, new Integer(11)); sourceAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); sourceAttrSet.addAttribute(StyleConstants.Foreground, SOURCE_COLOR); offsetAttrSet = new SimpleAttributeSet(); offsetAttrSet.addAttribute(StyleConstants.FontFamily, "Monospaced"); offsetAttrSet.addAttribute(StyleConstants.FontSize, new Integer(12)); offsetAttrSet.addAttribute(StyleConstants.Foreground, Color.BLACK); contentAttrSet = new SimpleAttributeSet(); contentAttrSet.addAttribute(StyleConstants.FontFamily, "Monospaced"); contentAttrSet.addAttribute(StyleConstants.FontSize, new Integer(12)); contentAttrSet.addAttribute(StyleConstants.Foreground, Color.BLUE); fieldNameAttrSet = new SimpleAttributeSet(); fieldNameAttrSet.addAttribute(StyleConstants.FontFamily, "Monospaced"); fieldNameAttrSet.addAttribute(StyleConstants.FontSize, new Integer(12)); fieldNameAttrSet.addAttribute(StyleConstants.Foreground, new Color(204, 0, 204)); commentAttrSet = new SimpleAttributeSet(); commentAttrSet.addAttribute(StyleConstants.FontFamily, "Monospaced"); commentAttrSet.addAttribute(StyleConstants.FontSize, new Integer(12)); commentAttrSet.addAttribute(StyleConstants.Foreground, new Color(0, 204, 51)); deletedAttrSet = new SimpleAttributeSet(); deletedAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); deletedAttrSet.addAttribute(StyleConstants.FontSize, new Integer(12)); deletedAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); deletedAttrSet.addAttribute(StyleConstants.Foreground, Color.RED); setDataType(dataType); }
Example 15
Source File: CommentHistoryPanel.java From ghidra with Apache License 2.0 | 4 votes |
private void create() { textPane = new JTextPane(); textPane.setEditable(false); add(textPane, BorderLayout.CENTER); doc = textPane.getStyledDocument(); }
Example 16
Source File: BroadcastFrame.java From JRakNet with MIT License | 4 votes |
/** * Creates a broadcast test frame. */ protected BroadcastFrame() { // Frame and content settings this.setResizable(false); this.setSize(FRAME_WIDTH, FRAME_HEIGHT); this.setTitle("JRakNet Broadcast Test"); this.getContentPane().setLayout(null); // Discovered MCPE Servers JTextPane txtpnDiscoveredMcpeServers = new JTextPane(); txtpnDiscoveredMcpeServers.setEditable(false); txtpnDiscoveredMcpeServers.setBackground(UIManager.getColor("Button.background")); txtpnDiscoveredMcpeServers.setText("Discovered servers"); txtpnDiscoveredMcpeServers.setBounds(10, 10, 350, 20); this.getContentPane().add(txtpnDiscoveredMcpeServers); // How the client will discover servers on the local network JComboBox<String> comboBoxDiscoveryType = new JComboBox<String>(); comboBoxDiscoveryType.setToolTipText( "Changing this will update how the client will discover servers, by default it will look for any possible connection on the network"); comboBoxDiscoveryType.setModel(new DefaultComboBoxModel<String>(DISCOVERY_MODE_OPTIONS)); comboBoxDiscoveryType.setBounds(370, 10, 115, 20); comboBoxDiscoveryType.addActionListener(new RakNetBroadcastDiscoveryTypeListener()); this.getContentPane().add(comboBoxDiscoveryType); // Used to update the discovery port JTextField textFieldDiscoveryPort = new JTextField(); textFieldDiscoveryPort.setBounds(370, 45, 115, 20); textFieldDiscoveryPort.setText(Integer.toString(Discovery.getPorts()[0])); this.getContentPane().add(textFieldDiscoveryPort); textFieldDiscoveryPort.setColumns(10); JButton btnUpdatePort = new JButton("Update Port"); btnUpdatePort.setBounds(370, 76, 114, 23); btnUpdatePort.addActionListener(new RakNetBroadcastUpdatePortListener(textFieldDiscoveryPort)); this.getContentPane().add(btnUpdatePort); // The text containing the discovered MCPE servers txtPnDiscoveredMcpeServerList = new JTextPane(); txtPnDiscoveredMcpeServerList.setToolTipText("This is the list of the discovered servers on the local network"); txtPnDiscoveredMcpeServerList.setEditable(false); txtPnDiscoveredMcpeServerList.setBackground(UIManager.getColor("Button.background")); txtPnDiscoveredMcpeServerList.setBounds(10, 30, 350, 165); this.getContentPane().add(txtPnDiscoveredMcpeServerList); }
Example 17
Source File: CommentPane.java From lizzie with GNU General Public License v3.0 | 4 votes |
/** Creates a window */ public CommentPane(LizzieMain owner) { super(owner); setLayout(new BorderLayout(0, 0)); htmlKit = new LizziePane.HtmlKit(); htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument(); htmlStyle = htmlKit.getStyleSheet(); String style = "body {background:#" + String.format( "%02x%02x%02x", Lizzie.config.commentBackgroundColor.getRed(), Lizzie.config.commentBackgroundColor.getGreen(), Lizzie.config.commentBackgroundColor.getBlue()) + "; color:#" + String.format( "%02x%02x%02x", Lizzie.config.commentFontColor.getRed(), Lizzie.config.commentFontColor.getGreen(), Lizzie.config.commentFontColor.getBlue()) + "; font-family:" + Lizzie.config.fontName + ", Consolas, Menlo, Monaco, 'Ubuntu Mono', monospace;" + (Lizzie.config.commentFontSize > 0 ? "font-size:" + Lizzie.config.commentFontSize : "") + "}"; htmlStyle.addRule(style); commentPane = new JTextPane(); commentPane.setBorder(BorderFactory.createEmptyBorder()); commentPane.setEditorKit(htmlKit); commentPane.setDocument(htmlDoc); commentPane.setText(""); commentPane.setEditable(false); commentPane.setFocusable(false); commentPane.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Lizzie.frame.getFocus(); } }); scrollPane = new JScrollPane(); scrollPane.setBorder(BorderFactory.createEmptyBorder()); scrollPane.setVerticalScrollBarPolicy( javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); add(scrollPane); scrollPane.setViewportView(commentPane); setVisible(false); // mouseMotionAdapter = new MouseMotionAdapter() { // @Override // public void mouseDragged(MouseEvent e) { // System.out.println("Mouse Dragged"); // owner.dispatchEvent(e); // } // }; // commentPane.addMouseMotionListener(mouseMotionAdapter); }
Example 18
Source File: GroovyConsoleSlide.java From COMP6237 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Component getComponent(int width, int height) throws IOException { final JPanel base = new JPanel(); base.setOpaque(false); base.setPreferredSize(new Dimension(width, height)); base.setLayout(new BorderLayout()); final JPanel controls = new JPanel(); final JButton runBtn = new JButton("Run"); runBtn.setActionCommand("run"); runBtn.addActionListener(this); controls.add(runBtn); base.add(controls, BorderLayout.NORTH); textArea = new RSyntaxTextArea(20, 60); Font font = textArea.getFont(); font = font.deriveFont(font.getStyle(), 18); textArea.setFont(font); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY); textArea.setCodeFoldingEnabled(true); textArea.setText(initialScript); final RTextScrollPane inputScrollPane = new RTextScrollPane(textArea); outputPane = new JTextPane(); outputPane.setEditable(false); outputPane.setFont(new Font("Monospaced", Font.PLAIN, 18)); outputPane.setBorder(new EmptyBorder(4, 4, 4, 4)); final JScrollPane outputScrollPane = new JScrollPane(outputPane); splitPane = new JSplitPane(orientation, inputScrollPane, outputScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(width / 2); final Dimension minimumSize = new Dimension(100, 50); inputScrollPane.setMinimumSize(minimumSize); outputScrollPane.setMinimumSize(minimumSize); final JPanel body = new JPanel(); body.setBackground(Color.RED); body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS)); body.add(splitPane); base.add(body, BorderLayout.CENTER); installInterceptors(); return base; }
Example 19
Source File: SimpleGUI.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * This method displays the about box. */ public Runner doAbout() { if (wrap) return wrapMe(); // Old about message // OurDialog.showmsg("About Alloy Analyzer " + Version.version(), OurUtil.loadIcon("images/logo.gif"), "Alloy Analyzer " + Version.version(), "Build date: " + " git: " + Version.commit, " ", "Lead developer: Felix Chang", "Engine developer: Emina Torlak", "Graphic design: Julie Pelaez", "Project lead: Daniel Jackson", " ", "Please post comments and questions to the Alloy Community Forum at http://alloy.mit.edu/", " ", "Thanks to: Ilya Shlyakhter, Manu Sridharan, Derek Rayside, Jonathan Edwards, Gregory Dennis,", "Robert Seater, Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,", "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, and Uriel Schafer."); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("body {color:#000; font-family:Verdana, Trebuchet MS,Geneva, sans-serif; font-size: 10px; margin: 4px; }"); styleSheet.addRule("h1 {color: blue;}"); styleSheet.addRule("h2 {color: #ff0000;}"); styleSheet.addRule("pre {font : 10px monaco; color : black; background-color: #C0C0C0; padding: 4px; margin: 4px; }"); styleSheet.addRule("th {text-align:left;}"); JTextPane ta = new JTextPane(); ta.setEditorKit(kit); ta.setContentType("text/html"); ta.setBackground(null); ta.setBorder(null); ta.setFont(new JLabel().getFont()); // @formatter:off ta.setText("<html><h1>Alloy Analyzer " + Version.getShortversion() + "</h1>" + "<br/>" + "<html>" + "<tr><th>Project Lead</th><td>Daniel Jackson</td></tr>" + "<tr><th>Chief Developer</th><td>Aleksandar Milicevic</td></tr>" + "<tr><th>Kodkod Engine</th><td>Emina Torlak</td></tr>" + "<tr><th>Open Source</th><td>Peter Kriens</td></tr>" + "</table><br/>" + "<p>For more information about Alloy, <a href='http://alloytools.org'>http://alloytools.org</a></p>" + "<p>Questions and comments about Alloy are welcome at the community forum:</p>" + "<p>Alloy Community Forum: <a href='https://groups.google.com/forum/#!forum/alloytools'>https://groups.google.com/forum/#!forum/alloytools</a></p>" + "<p>Alloy experts also respond to <a href='https://stackoverflow.com/questions/tagged/alloy'>https://stackoverflow.com</a> questions tagged <code>alloy</code>.</p>" + "<p>Major contributions to earlier versions of Alloy were made by: Felix Chang (v4);<br/>" + "Jonathan Edwards, Eunsuk Kang, Joe Near, Robert Seater, Derek Rayside, Greg Dennis,<br/>" + "Ilya Shlyakhter, Mana Taghdiri, Mandana Vaziri, Sarfraz Khurshid (v3); Manu Sridharan<br/>" + "(v2); Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,<br/>" + "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, Uriel<br/>" + "Schafer (v1).</p>" + "<p>The development of Alloy was funded by part by the National Science Foundation under<br/>" + "Grant Nos. 0325283, 0541183, 0438897 and 0707612; by the Air Force Research Laboratory<br/>" + "(AFRL/IF) and the Disruptive Technology Office (DTO) in the National Intelligence<br/>" + "Community Information Assurance Research (NICIAR) Program; and by the Nokia<br/>" + "Corporation as part of a collaboration between Nokia Research and MIT CSAIL.</p>" + "<br/><pre>" + "Build Date: " + Version.buildDate() + "<br/>" + "Git Commit: " + Version.commit + "</pre>"); // @formatter:on ta.setEditable(false); ta.addHyperlinkListener((e) -> { if (e.getEventType() == EventType.ACTIVATED) { if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { // ignore } } } }); OurDialog.showmsg("About Alloy Analyzer " + Version.version(), ta); return null; }
Example 20
Source File: AboutDialog.java From SubTitleSearcher with Apache License 2.0 | 4 votes |
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setIconImage(MainWin.icon); setSize(500, 300); setResizable(false); setLocationRelativeTo(this.getParent()); setTitle("About " + AppConfig.appTitle); JPanel mainPanel = new JPanel(new BorderLayout()); add(mainPanel); JPanel leftPanel = new JPanel(); mainPanel.add(leftPanel, BorderLayout.WEST); ImageIcon iconImg = new ImageIcon(MainWin.icon); iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH)); JLabel iconLabel = new JLabel(iconImg); iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10)); leftPanel.add(iconLabel); HyperlinkListener hlLsnr = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return; // 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。 // JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription()); URL linkUrl = e.getURL(); if (linkUrl != null) { try { Desktop.getDesktop().browse(linkUrl.toURI()); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE); } } }; JTextPane infoArea = new JTextPane(); //设置css单位(px/pt)和chrome一致 infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true); infoArea.addHyperlinkListener(hlLsnr); infoArea.setContentType("text/html"); infoArea.setText(getInfo()); infoArea.setEditable(false); infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10)); infoArea.setFocusable(false); JScrollPane infoAreaScrollPane = new JScrollPane(infoArea); infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); infoAreaScrollPane.getViewport().setBackground(Color.WHITE); mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER); }