List of usage examples for javax.swing JTextPane JTextPane
public JTextPane()
JTextPane
. From source file:esmska.gui.AboutFrame.java
private void licenseButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_licenseButtonActionPerformed //show licence try {/*from w ww . j a va 2s. co m*/ logger.fine("Showing license..."); String license = IOUtils.toString(getClass().getResourceAsStream(RES + "license.txt"), "UTF-8"); final String agpl = IOUtils.toString(getClass().getResourceAsStream(RES + "gnu-agpl.txt"), "UTF-8"); license = MiscUtils.escapeHtml(license); license = license.replaceAll("GNU Affero General Public License", "<a href=\"agpl\">GNU Affero General Public License</a>"); final JTextPane tp = new JTextPane(); tp.setContentType("text/html; charset=UTF-8"); tp.setText("<html><pre>" + license + "</pre></html>"); tp.setEditable(false); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); tp.setPreferredSize(new Dimension((int) d.getWidth() / 2, (int) d.getHeight() / 2)); //reasonable size tp.setCaretPosition(0); //make links clickable tp.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { logger.fine("Showing GNU AGPL..."); tp.setText(null); tp.setContentType("text/plain"); tp.setText(agpl); tp.setCaretPosition(0); } } }); String option = l10n.getString("AboutFrame.Acknowledge"); JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option); JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.License")); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } catch (IOException ex) { logger.log(Level.WARNING, "Could not show license", ex); } }
From source file:com.ficeto.esp.EspExceptionDecoder.java
private void createAndUpload() { if (!PreferencesData.get("target_platform").contentEquals("esp8266") && !PreferencesData.get("target_platform").contentEquals("esp32") && !PreferencesData.get("target_platform").contentEquals("ESP31B")) { System.err.println();//from w ww. j av a 2s . co m editor.statusError("Not Supported on " + PreferencesData.get("target_platform")); return; } String tc = "esp32"; if (PreferencesData.get("target_platform").contentEquals("esp8266")) { tc = "lx106"; } TargetPlatform platform = BaseNoGui.getTargetPlatform(); String gccPath = PreferencesData.get("runtime.tools.xtensa-" + tc + "-elf-gcc.path"); if (gccPath == null) { gccPath = platform.getFolder() + "/tools/xtensa-" + tc + "-elf"; } String addr2line; if (PreferencesData.get("runtime.os").contentEquals("windows")) addr2line = "xtensa-" + tc + "-elf-addr2line.exe"; else addr2line = "xtensa-" + tc + "-elf-addr2line"; tool = new File(gccPath + "/bin", addr2line); if (!tool.exists() || !tool.isFile()) { System.err.println(); editor.statusError("ERROR: " + addr2line + " not found!"); return; } elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".ino.elf"); if (!elf.exists() || !elf.isFile()) { elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".cpp.elf"); if (!elf.exists() || !elf.isFile()) { //lets give the user a chance to select the elf final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new ElfFilter()); fc.setAcceptAllFileFilterUsed(false); int returnVal = fc.showDialog(editor, "Select ELF"); if (returnVal == JFileChooser.APPROVE_OPTION) { elf = fc.getSelectedFile(); } else { editor.statusError("ERROR: elf was not found!"); System.err.println("Open command cancelled by user."); return; } } } JFrame.setDefaultLookAndFeelDecorated(true); frame = new JFrame("Exception Decoder"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); inputArea = new JTextArea("Paste your stack trace here", 16, 60); inputArea.setLineWrap(true); inputArea.setWrapStyleWord(true); inputArea.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "commit"); inputArea.getActionMap().put("commit", new CommitAction()); inputArea.getDocument().addDocumentListener(this); frame.getContentPane().add(new JScrollPane(inputArea), BorderLayout.PAGE_START); outputText = ""; outputArea = new JTextPane(); outputArea.setContentType("text/html"); outputArea.setEditable(false); outputArea.setBackground(null); outputArea.setBorder(null); outputArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); outputArea.setText(outputText); JScrollPane outputScrollPane = new JScrollPane(outputArea); outputScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); outputScrollPane.setPreferredSize(new Dimension(640, 200)); outputScrollPane.setMinimumSize(new Dimension(10, 10)); frame.getContentPane().add(outputScrollPane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:org.jfree.chart.demo.SuperDemo.java
private JPanel createChartDisplayPanel() { displayPanel = new JPanel(new BorderLayout()); chartContainer = new JPanel(new BorderLayout()); chartContainer.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chartContainer.add(createNoDemoSelectedPanel()); descriptionContainer = new JPanel(new BorderLayout()); descriptionContainer.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); descriptionContainer.setPreferredSize(new Dimension(600, 140)); descriptionPane = new JTextPane(); descriptionPane.setEditable(false);/*from w w w . jav a2 s. co m*/ JScrollPane jscrollpane = new JScrollPane(descriptionPane, 20, 31); descriptionContainer.add(jscrollpane); displayDescription("select.html"); JSplitPane jsplitpane = new JSplitPane(0); jsplitpane.setTopComponent(chartContainer); jsplitpane.setBottomComponent(descriptionContainer); displayPanel.add(jsplitpane); jsplitpane.setDividerLocation(0.75D); return displayPanel; }
From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java
private JTextPane getJTextPaneSourceCodeNum() { if (jTextPaneSourceCodeNum == null) { jTextPaneSourceCodeNum = new JTextPane(); jTextPaneSourceCodeNum.setEditable(false); jTextPaneSourceCodeNum.setEnabled(false); jTextPaneSourceCodeNum.setAutoscrolls(false); }/* w w w. j a v a 2s .c om*/ return jTextPaneSourceCodeNum; }
From source file:logdruid.ui.DateEditor.java
/** * Create the panel.//from www . j av a2s .c o m */ public DateEditor(Repository rep) { repository = rep; model = new MyTableModel2(data, header); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 15, 550, 15 }; gridBagLayout.rowHeights = new int[] { 152, 300 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 1.0 }; setLayout(gridBagLayout); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.insets = new Insets(5, 0, 5, 5); gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; add(panel_1, gbc_panel_1); panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setBorder(UIManager.getBorder("TextPane.border")); table.setPreferredScrollableViewportSize(new Dimension(0, 0)); table.setFillsViewportHeight(true); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { // ((table.getSelectedRow()!=-1)?table.convertRowIndexToModel(table.getSelectedRow()):-1) // persist repository // display selected row if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1) >= 0) { /* * recEditor = new RecordingEditor(repository * .getRecordings().get(((table.getSelectedRow()!=-1)?table. * convertRowIndexToModel(table.getSelectedRow()):-1)), * repository); jPanelDetail.removeAll(); */ // jPanelDetail.add(recEditor, gbc_jPanelDetail); DateFormat df = repository.getDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); if (df != null) { textFieldName.setText((String) df.getName()); textFieldPattern.setText((String) df.getPattern()); textField.setText((String) df.getDateFormat()); } // jPanelDetail.revalidate(); // jPanelDetail.repaint(); // jPanelDetail.setVisible(true); // reloadTable(); those 2 ******** // jPanelDetail.revalidate(); } } }); JScrollPane scrollPane = new JScrollPane(table); panel_1.add(scrollPane, BorderLayout.CENTER); // Set up column sizes. initColumnSizes(table); JPanel panel = new JPanel(); FlowLayout flowLayout = (FlowLayout) panel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); flowLayout.setVgap(2); flowLayout.setHgap(2); panel_1.add(panel, BorderLayout.SOUTH); JButton btnNew = new JButton("New"); panel.add(btnNew); btnNew.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { DateFormat df = new DateFormat("name", "\\w{3}\\s[0-9]{1}/[0-9]{2}/[0-9]{2}\\s\\d\\d:\\d\\d:\\d\\d", "EEE. MM/dd/yy HH:mm:ss"); repository.addDateFormat(df); data.add(new Object[] { df.getName(), df.getPattern(), df.getDateFormat() }); table.repaint(); } }); JButton btnDuplicate = new JButton("Duplicate"); btnDuplicate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1) >= 0) { DateFormat df = repository.getDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); repository.addDateFormat(df); reloadTable(); // data.add(new Object[] { table.getRowCount()+1, // df.getName(),df.getDateFormat()}); table.repaint(); } } }); panel.add(btnDuplicate); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); if (selectedRow >= 0) { repository.deleteDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); data.remove( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); reloadTable(); table.setRowSelectionInterval(selectedRow, selectedRow); table.repaint(); } } }); panel.add(btnDelete); jPanelDetail = new JPanel(); gbc_jPanelDetail = new GridBagConstraints(); gbc_jPanelDetail.anchor = GridBagConstraints.NORTH; gbc_jPanelDetail.fill = GridBagConstraints.HORIZONTAL; gbc_jPanelDetail.gridx = 1; gbc_jPanelDetail.gridy = 1; add(jPanelDetail, gbc_jPanelDetail); GridBagLayout gbl_jPanelDetail = new GridBagLayout(); gbl_jPanelDetail.columnWidths = new int[] { 169 }; gbl_jPanelDetail.rowHeights = new int[] { 0, 0, 0, 0, 150, 0 }; gbl_jPanelDetail.columnWeights = new double[] { 1.0, 0.0 }; gbl_jPanelDetail.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 }; jPanelDetail.setLayout(gbl_jPanelDetail); JPanel panel_2 = new JPanel(); panel_2.setBorder(null); GridBagConstraints gbc_panel_2 = new GridBagConstraints(); gbc_panel_2.gridwidth = 2; gbc_panel_2.anchor = GridBagConstraints.NORTHWEST; gbc_panel_2.insets = new Insets(0, 0, 5, 0); gbc_panel_2.gridx = 0; gbc_panel_2.gridy = 0; jPanelDetail.add(panel_2, gbc_panel_2); panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); JLabel label = new JLabel("Name"); panel_2.add(label); textFieldName = new JTextField(); textFieldName.setColumns(20); panel_2.add(textFieldName); JPanel panel_3 = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) panel_3.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); panel_3.setBorder(null); GridBagConstraints gbc_panel_3 = new GridBagConstraints(); gbc_panel_3.insets = new Insets(0, 0, 5, 0); gbc_panel_3.gridwidth = 2; gbc_panel_3.anchor = GridBagConstraints.NORTHWEST; gbc_panel_3.gridx = 0; gbc_panel_3.gridy = 1; jPanelDetail.add(panel_3, gbc_panel_3); labelPattern = new JLabel("Pattern"); panel_3.add(labelPattern); textFieldPattern = new JTextField(); textFieldPattern.setColumns(40); panel_3.add(textFieldPattern); JButton btnSave = new JButton("Save"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DateFormat df1 = repository.getDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); df1.update(textFieldName.getText(), textFieldPattern.getText(), textField.getText()); reloadTable(); } }); JPanel panel_4 = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) panel_4.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); GridBagConstraints gbc_panel_4 = new GridBagConstraints(); gbc_panel_4.anchor = GridBagConstraints.WEST; gbc_panel_4.insets = new Insets(0, 0, 5, 5); gbc_panel_4.gridx = 0; gbc_panel_4.gridy = 2; jPanelDetail.add(panel_4, gbc_panel_4); JLabel lblFastDateFormat = new JLabel("FastDateFormat"); panel_4.add(lblFastDateFormat); textField = new JTextField(); panel_4.add(textField); textField.setColumns(30); JPanel panel_5 = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) panel_5.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); GridBagConstraints gbc_panel_5 = new GridBagConstraints(); gbc_panel_5.insets = new Insets(0, 0, 5, 5); gbc_panel_5.fill = GridBagConstraints.BOTH; gbc_panel_5.gridx = 0; gbc_panel_5.gridy = 3; jPanelDetail.add(panel_5, gbc_panel_5); JLabel lblSampleLabel = new JLabel("Sample"); panel_5.add(lblSampleLabel); JPanel panel_6 = new JPanel(); panel_6.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_6 = new GridBagConstraints(); gbc_panel_6.ipady = 1; gbc_panel_6.ipadx = 1; gbc_panel_6.insets = new Insets(0, 0, 5, 5); gbc_panel_6.fill = GridBagConstraints.BOTH; gbc_panel_6.gridx = 0; gbc_panel_6.gridy = 4; jPanelDetail.add(panel_6, gbc_panel_6); panel_6.setLayout(new BorderLayout(0, 0)); JTextPane textPane = new JTextPane(); textPane.setBackground(UIManager.getColor("windowBorder")); panel_6.add(textPane); GridBagConstraints gbc_btnSave = new GridBagConstraints(); gbc_btnSave.anchor = GridBagConstraints.WEST; gbc_btnSave.insets = new Insets(0, 0, 0, 5); gbc_btnSave.gridx = 0; gbc_btnSave.gridy = 5; jPanelDetail.add(btnSave, gbc_btnSave); reloadTable(); }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateLibrariesPanel.java
private void initComponents(Channel channel) { setBackground(UIConstants.BACKGROUND_COLOR); selectAllLabel = new JLabel("<html><u>Select All</u></html>"); selectAllLabel.setForeground(Color.BLUE); selectAllLabel.addMouseListener(new MouseAdapter() { @Override/*from w w w .ja va 2 s .c om*/ public void mouseReleased(MouseEvent evt) { for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((MutableTreeTableNode) libraryTreeTable .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) { MutableTreeTableNode libraryNode = libraryNodes.nextElement(); Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNode .getUserObject(); libraryTreeTable.getTreeTableModel().setValueAt( new MutableTriple<String, String, Boolean>(triple.getLeft(), triple.getMiddle(), true), libraryNode, libraryTreeTable.getHierarchicalColumn()); } libraryTreeTable.updateUI(); } }); selectSeparatorLabel = new JLabel("|"); deselectAllLabel = new JLabel("<html><u>Deselect All</u></html>"); deselectAllLabel.setForeground(Color.BLUE); deselectAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((MutableTreeTableNode) libraryTreeTable .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) { MutableTreeTableNode libraryNode = libraryNodes.nextElement(); Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNode .getUserObject(); libraryTreeTable.getTreeTableModel().setValueAt( new MutableTriple<String, String, Boolean>(triple.getLeft(), triple.getMiddle(), false), libraryNode, libraryTreeTable.getHierarchicalColumn()); } libraryTreeTable.updateUI(); } }); expandAllLabel = new JLabel("<html><u>Expand All</u></html>"); expandAllLabel.setForeground(Color.BLUE); expandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { libraryTreeTable.expandAll(); } }); expandSeparatorLabel = new JLabel("|"); collapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); collapseAllLabel.setForeground(Color.BLUE); collapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { libraryTreeTable.collapseAll(); } }); final TableCellEditor libraryCellEditor = new LibraryTreeCellEditor(); libraryTreeTable = new MirthTreeTable() { @Override public TableCellEditor getCellEditor(int row, int column) { if (isHierarchical(column)) { return libraryCellEditor; } else { return super.getCellEditor(row, column); } } }; DefaultTreeTableModel model = new SortableTreeTableModel(); DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(); model.setRoot(rootNode); libraryTreeTable.setLargeModel(true); libraryTreeTable.setTreeTableModel(model); libraryTreeTable.setOpenIcon(null); libraryTreeTable.setClosedIcon(null); libraryTreeTable.setLeafIcon(null); libraryTreeTable.setRootVisible(false); libraryTreeTable.setDoubleBuffered(true); libraryTreeTable.setDragEnabled(false); libraryTreeTable.setRowSelectionAllowed(true); libraryTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); libraryTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); libraryTreeTable.setFocusable(true); libraryTreeTable.setOpaque(true); libraryTreeTable.setEditable(true); libraryTreeTable.setSortable(false); libraryTreeTable.setAutoCreateColumnsFromModel(false); libraryTreeTable.setShowGrid(true, true); libraryTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { libraryTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } libraryTreeTable.setTreeCellRenderer(new LibraryTreeCellRenderer()); libraryTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (libraryTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { libraryTreeTable.clearSelection(); } } }); libraryTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean visible = false; int selectedRow = libraryTreeTable.getSelectedRow(); if (selectedRow >= 0) { TreePath selectedPath = libraryTreeTable.getPathForRow(selectedRow); if (selectedPath != null) { visible = true; Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); String description = ""; if (selectedPath.getPathCount() == 2) { description = libraryMap.get(triple.getLeft()).getDescription(); } else if (selectedPath.getPathCount() == 3) { description = PlatformUI.MIRTH_FRAME.codeTemplatePanel.getCachedCodeTemplates() .get(triple.getLeft()).getDescription(); } if (StringUtils.isBlank(description) || StringUtils.equals(description, CodeTemplateUtil .getDocumentation(CodeTemplate.DEFAULT_CODE).getDescription())) { descriptionTextPane.setText( "<html><body class=\"code-template-libraries-panel\"><i>No description.</i></body></html>"); } else { descriptionTextPane.setText("<html><body class=\"code-template-libraries-panel\">" + MirthXmlUtil.encode(description) + "</body></html>"); } } } descriptionScrollPane.setVisible(visible); updateUI(); } } }); libraryTreeTableScrollPane = new JScrollPane(libraryTreeTable); descriptionTextPane = new JTextPane(); descriptionTextPane.setContentType("text/html"); HTMLEditorKit editorKit = new HTMLEditorKit(); StyleSheet styleSheet = editorKit.getStyleSheet(); styleSheet.addRule(".code-template-libraries-panel {font-family:\"Tahoma\";font-size:11;text-align:top}"); descriptionTextPane.setEditorKit(editorKit); descriptionTextPane.setEditable(false); descriptionScrollPane = new JScrollPane(descriptionTextPane); descriptionScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); descriptionScrollPane.setVisible(false); }
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * Setup the General Tab Pane//from w w w. j a va 2s .com * * @return JPanel for pane */ private JPanel setupGeneralTab() { JPanel generalTab = new JPanel(); generalTab.setLayout(new BorderLayout()); /* -- Create Main Panels -- */ JPanel centerPanel = new JPanel(); JPanel northPanel = new JPanel(); JPanel southPanel = new JPanel(); generalTab.add(centerPanel, BorderLayout.CENTER); generalTab.add(northPanel, BorderLayout.NORTH); /* -- Create Center Contents -- */ // Statistics Panel JPanel statsPanel = setupStatsPanel(); // Log Panel JPanel logPanel = new JPanel(); logPanel.setLayout(new BorderLayout()); logPanel.setBorder(BorderFactory.createTitledBorder("Log Output")); JTextPane logTextPane = new JTextPane(); logTextPane.setEditable(false); logTextPane.setBackground(Color.BLACK); logTextPane.setForeground(Color.WHITE); logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); addUIElement("general.log", logTextPane); // Add to component map JPanel logOptionsPanel = new JPanel(); logPanel.add(logOptionsPanel, BorderLayout.SOUTH); logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log"); logScrollCheckbox.setSelected(true); logScrollCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected()); } }); logOptionsPanel.add(logScrollCheckbox); // Enable Logging JTextPaneAppender.setTextPane(logTextPane); centerPanel.setLayout(new BorderLayout(10, 10)); centerPanel.add(statsPanel, BorderLayout.NORTH); centerPanel.add(logPanel, BorderLayout.CENTER); /* -- Create Buttons (South) -- */ generalTab.add(southPanel, BorderLayout.SOUTH); final JButton shutdownButton = new JButton("Shutdown"); shutdownButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doShutdownCluster(); } }); southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10)); southPanel.add(shutdownButton); addUIElement("general.shutdown", shutdownButton); // Add to components map return generalTab; }
From source file:com.diversityarrays.dal.server.SqlDialog.java
private void processTaskResult(TaskResult taskResult) { if (taskResult.error == null) { if (taskResult.isQuery) { taskResult.showQueryResult(); } else {//from www .ja v a 2 s . co m taskResult.showUpdateResult(); } } else { StringWriter ew = new StringWriter(); PrintWriter ep = new PrintWriter(ew); taskResult.error.printStackTrace(ep); ep.close(); JPanel panel = new JPanel(new BorderLayout()); panel.add(BorderLayout.NORTH, GuiUtil.createLabelSeparator(taskResult.whyError)); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("<html><body><h3>SQL:</h3><pre>"); pw.println(DbUtil.htmlEscape(taskResult.sql)); pw.println("</pre><hr/>"); pw.println("<h3>Stacktrace</h3><pre>"); pw.print(DbUtil.htmlEscape(ew.toString())); pw.println("</pre>"); pw.println("</body></html>"); pw.close(); JTextPane text = new JTextPane(); text.setEditorKit(new HTMLEditorKit()); text.setEditable(false); ; text.setText(sw.toString()); ; panel.add(BorderLayout.CENTER, new JScrollPane(text)); addPanelToTabbedPane(panel); } }
From source file:esmska.gui.AboutFrame.java
private void creditsButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_creditsButtonActionPerformed //show credits try {/*from w ww.j a va 2 s . c o m*/ logger.fine("Showing credits..."); String credits = IOUtils.toString(getClass().getResourceAsStream(RES + "credits.html"), "UTF-8"); String translators = l10n.getString("Translators"); if ("translator-credits".equals(translators)) { //there are no translators mentioned translators = ""; } else { translators = translators.replaceAll("\n", "<br>\n").replaceAll("\n ", "\n "); //add hyperlinks to the Launchpad URLs translators = translators.replaceAll("(https://[^<]*)", "<a href=\"$1\">$1</a>"); } String document = MessageFormat.format(credits, l10n.getString("Credits.authors"), l10n.getString("Credits.contributors"), l10n.getString("Credits.graphics"), l10n.getString("Credits.sponsors"), l10n.getString("Credits.translators"), translators, Links.DONATORS, l10n.getString("Credits.moreDonators"), MessageFormat.format(l10n.getString("Credits.packagers"), Links.DOWNLOAD)); JTextPane tp = new JTextPane(); tp.setContentType("text/html; charset=UTF-8"); tp.setText(document); tp.setEditable(false); tp.setPreferredSize(new Dimension(450, 400)); tp.setCaretPosition(0); //make links clickable tp.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { logger.fine("Browsing URL: " + e.getURL()); Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { logger.log(Level.SEVERE, "Can't browse hyperlink: " + e.getURL(), ex); } } } }); String option = l10n.getString("AboutFrame.Thank_you"); JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option); JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.Credits")); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { logger.log(Level.WARNING, "Could not show credits", e); } }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * /*from ww w. j a v a 2s.c o m*/ */ private void synonymCleanup() { JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); String text = ""; try { String template = "synonym_cleanup_%s.html"; String fileName = String.format(template, Locale.getDefault().getLanguage()); File file = XMLHelper.getConfigDir(fileName); if (!file.exists()) { fileName = String.format(template, "en"); file = XMLHelper.getConfigDir(fileName); } text = FileUtils.readFileToString(file); } catch (Exception ex) { ex.printStackTrace(); } JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); p.add(js, BorderLayout.CENTER); tp.setContentType("text/html"); tp.setText(text); tp.setCaretPosition(0); tp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 18)); CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), getI18nRS("SYN_CLEANUP"), true, CustomDialog.OKCANCELAPPLY, p); dlg.setOkLabel(getI18nRS("SYN_CLEANUP")); dlg.setCancelLabel(getI18nRS("Report")); dlg.setApplyLabel(getResourceString("CANCEL")); dlg.setCloseOnApplyClk(true); dlg.createUI(); dlg.setSize(600, 450); UIHelper.centerAndShow(dlg); if (dlg.getBtnPressed() == CustomDialog.OK_BTN || dlg.getBtnPressed() == CustomDialog.CANCEL_BTN) { boolean doCleanup = dlg.getBtnPressed() == CustomDialog.OK_BTN; SynonymCleanup synonymCleanup = new SynonymCleanup(doCleanup); synonymCleanup.execute(); // start the background task } }