List of usage examples for javax.swing JTextPane setMargin
@BeanProperty(description = "desired space between the border and text area") public void setMargin(Insets m)
From source file:Main.java
public static void main(String[] args) { final JTextPane textPane = new JTextPane(); final JScrollPane scrollPane = new JScrollPane(textPane); String text = "Lorem ipsum dolor sit amet, " + "consectetur adipiscing elit." + "Fusce nec sapien id diam consequat adipiscing."; textPane.setText(text);/*from w ww .j a va2 s . c om*/ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(scrollPane); frame.setSize(new Dimension(200, 200)); frame.setVisible(true); FontMetrics metrics = textPane.getFontMetrics(textPane.getFont()); textPane.setMargin(new Insets(scrollPane.getViewport().getHeight() - metrics.getHeight(), 0, 0, 0)); }
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); try {//from w ww . jav a2 s. co m for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); System.out.println("set"); break; } } } catch (Exception e) { e.printStackTrace(); } Object o = UIManager.get("TextArea[Enabled+NotInScrollPane].borderPainter"); UIDefaults paneDefaults = new UIDefaults(); paneDefaults.put("TextPane.borderPainter", o); JTextPane pane = new JTextPane(); pane.setMargin(new Insets(10, 10, 10, 10)); pane.putClientProperty("Nimbus.Overrides", paneDefaults); pane.putClientProperty("Nimbus.Overrides.InheritDefaults", false); pane.setText("this \nis \na \ntest\n"); add(pane); }
From source file:com.vgi.mafscaling.LogView.java
private void createUsageTab() { JTextPane usageTextArea = new JTextPane(); usageTextArea.setMargin(new Insets(10, 10, 10, 10)); usageTextArea.setContentType("text/html"); usageTextArea.setText(usage());//from w w w . j a v a 2 s. c o m usageTextArea.setEditable(false); usageTextArea.setCaretPosition(0); JScrollPane textScrollPane = new JScrollPane(usageTextArea); textScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); textScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); add(textScrollPane, "<html><div style='text-align: center;'>U<br>s<br>a<br>g<br>e</div></html>"); }
From source file:ome.formats.importer.gui.ErrorTable.java
/** * Constructor for class/*from w w w . ja v a 2 s . co m*/ */ public ErrorTable() { // set to layout that will maximize on resizing setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.setOpaque(false); // Main Panel containing all elements // Set up the main panel layout double mainTable[][] = { { 5, 200, 140, TableLayout.FILL, 140, 5 }, // columns { 5, TableLayout.PREFERRED, TableLayout.FILL, 5, 29, 5 } }; // rows mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug); String message = "All errors accumulated during your import are displayed here, " + "and will be uploaded to us if check-marked. You can send us feedback on " + "these problems by clicking the 'Send Feedback' button."; JTextPane instructions = GuiCommonElements.addTextPane(mainPanel, message, "1,1,4,0", debug); instructions.setMargin(new Insets(10, 10, 10, 10)); TableColumnModel cModel = eTable.getColumnModel(); // *** remove last 3 rows from display *** TableColumn hiddenColumn = cModel.getColumn(6); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(5); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(4); cModel.removeColumn(hiddenColumn); MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer(); //LeftTableHeaderRenderer leftHeader = new LeftTableHeaderRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(myHeader); cModel.getColumn(1).setHeaderRenderer(myHeader); cModel.getColumn(2).setHeaderRenderer(myHeader); cModel.getColumn(3).setHeaderRenderer(myHeader); cbe = new CheckboxCellEditor(new JCheckBox()); cbe.checkbox.addMouseListener(this); cbr = new CheckboxRenderer(); cModel.getColumn(0).setCellEditor(cbe); cModel.getColumn(0).setCellRenderer(cbr); cModel.getColumn(1).setCellRenderer(new LeftDotRenderer()); cModel.getColumn(2).setCellRenderer(new TextLeftRenderer()); cModel.getColumn(3).setCellRenderer(new StatusRenderer()); // Set the width of the status column TableColumn statusColumn = eTable.getColumnModel().getColumn(3); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); // Set the width of the error column TableColumn dateColumn = eTable.getColumnModel().getColumn(2); dateColumn.setPreferredWidth(errorWidth); dateColumn.setMaxWidth(errorWidth); dateColumn.setMinWidth(errorWidth); // Set the width of the upload column TableColumn uploadColumn = eTable.getColumnModel().getColumn(0); uploadColumn.setPreferredWidth(uploadWidth); uploadColumn.setMaxWidth(uploadWidth); uploadColumn.setMinWidth(uploadWidth); eTable.setRowSelectionAllowed(false); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(eTable); mainPanel.add(scrollPane, "1,2,4,1"); double progressTable[][] = { { 200 }, // columns { 12, 5, 12 } }; // rows progressPanel = GuiCommonElements.addPlanePanel(mainPanel, progressTable, debug); runThread = new Thread() { public void run() { try { bytesProgressBar = new JProgressBar(); progressPanel.add(bytesProgressBar, "0,0"); filesProgressBar = new JProgressBar(0, 20); progressPanel.add(filesProgressBar, "0,2"); } catch (Throwable error) { } } }; runThread.start(); mainPanel.add(progressPanel, "1,4"); progressPanel.setVisible(false); cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'c', "Cancel sending", "2,4,L,C", debug); cancelBtn.addActionListener(this); cancelBtn.setVisible(false); clearDoneBtn = GuiCommonElements.addButton(mainPanel, "Clear Done", 'd', "Clear done", "3,4,R,C", debug); clearDoneBtn.addActionListener(this); clearDoneBtn.setOpaque(false); clearDoneBtn.setEnabled(false); //clearDoneBtn.setVisible(false); // Disabled (See #5250) sendBtn = GuiCommonElements.addButton(mainPanel, "Send Feedback", 's', "Send your errors to the OMERO team", "4,4,R,C", debug); sendBtn.setOpaque(false); sendBtn.addActionListener(this); sendBtn.setEnabled(false); this.add(mainPanel); }
From source file:org.echocat.velma.dialogs.AboutDialog.java
protected void createIntroduction(@Nonnull Resources resources) { final URL iconUrl = resources.getIconUrl(48); final StringBuilder body = new StringBuilder(); body.append("<html>"); body.append("<head><style>" + "td { margin-right: 10px; }" + "</style></head>"); body.append("<body style='font-family: sans; font-size: 1em'><table><tr>"); body.append("<td valign='top'><img src='").append(iconUrl).append("' /></td>"); body.append("<td valign='top'>"); body.append("<h2>").append(escapeHtml4(resources.getApplicationName())); final String version = resources.getVersion(); if (!isEmpty(version)) { body.append("<br/><span style='font-size: 0.6em'>") .append(resources.formatEscaped("versionText", version)).append("</span>"); }/* w w w . j a v a2 s . c o m*/ body.append("</h2>"); body.append("<p>Copyright 2011-2012 <a href='https://echocat.org'>echocat</a></p>"); body.append("<p><a href='http://mozilla.org/MPL/2.0/'>") .append(resources.formatEscaped("licensedUnder", "MPL 2.0")).append("</a></p>"); body.append("<p><table cellpadding='0' cellspacing='0'>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "echocat")) .append(":</td><td><a href='https://echocat.org'>echocat.org</a></td></tr>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "Velma")) .append(":</td><td><a href='https://velma.echocat.org'>velma.echocat.org</a></td></tr>"); body.append("</table></p>"); body.append("<h4>").append(resources.formatEscaped("developers")) .append("</h4><table cellpadding='0' cellspacing='0'>"); body.append( "<tr><td>Gregor Noczinski</td><td><a href='mailto:gregor@noczinski.eu'>gregor@noczinski.eu</a></td><td><a href='https://github.com/blaubaer'>github.com/blaubaer</a></td></tr>"); body.append("</table>"); body.append("</td>"); body.append("</tr></table></body></html>"); final JTextPane text = new JTextPane(); text.setMargin(new Insets(0, 0, 0, 0)); text.setContentType("text/html"); text.setText(body.toString()); text.setFont(new Font(DIALOG, PLAIN, 12)); text.setBackground(new Color(255, 255, 255, 0)); text.setEditable(false); text.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == ACTIVATED && isDesktopSupported()) { final Desktop desktop = getDesktop(); if (desktop.isSupported(BROWSE)) { try { desktop.browse(e.getURL().toURI()); } catch (IOException | URISyntaxException exception) { LOG.error("Could not open " + e.getURL() + " because of an exception.", exception); } } else { LOG.error("Could not open " + e.getURL() + " because browse is not supported by desktop."); } } repaint(); } }); text.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { repaint(); } @Override public void mousePressed(MouseEvent e) { repaint(); } @Override public void mouseReleased(MouseEvent e) { repaint(); } @Override public void mouseEntered(MouseEvent e) { repaint(); } @Override public void mouseExited(MouseEvent e) { repaint(); } }); add(text, new CC().spanX(2).growX().minWidth("10px")); }
From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java
private JTextPane createEditablePane() { JTextPane textPane = new JTextPane(); // Get the preferences for wrapping lines of text final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[2].getId(), false); if (wrapText) { textPane = new JTextPane(); } else {//from ww w .ja v a 2 s. c om textPane = new NonWrappingTextPane(); } textPane.putClientProperty("charset", "UTF-8"); textPane.setEditable(true); textPane.setVisible(true); textPane.setFont(new Font("Verdana", Font.PLAIN, 12)); textPane.setMargin(new Insets(1, 1, 1, 1)); textPane.setBackground(Color.WHITE); textPane.setForeground(Color.BLACK); // Set the editor kit responsible for highlighting textPane.setEditorKit(new StyledEditorKit() { private static final long serialVersionUID = -6085642347022880064L; public Document createDefaultDocument() { return new TextHighlighter(); } }); // Right click: Cut, Copy, Paste, Select All RightClickPopups.rightClickRequestTextComponent(this, textPane); return textPane; }
From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java
JTextPane createSimplePane() { JTextPane textPane = new JTextPane(); textPane.setMargin(new Insets(1, 1, 1, 1)); textPane.setBackground(Color.WHITE); textPane.setForeground(Color.BLACK); return textPane; }