private JComponent getCenterPanel() { JPanel center = new JPanel(new BorderLayout()); center.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); center.setBackground(Color.WHITE); JTextArea license = new javax.swing.JTextArea(); license.setLineWrap(true); license.setWrapStyleWord(true); license.setEditable(false); license.setFont(license.getFont().deriveFont(11.0f)); StringBuilder licenseText = new StringBuilder(); licenseText.append("Enhance current Java (JRE/JDK) installations with DCEVM (http://github.com/dcevm/dcevm)."); licenseText.append("\n\nYou can either replace current Java VM or install DCEVM as alternative JVM (run with -XXaltjvm=dcevm command-line option)."); licenseText.append("\nInstallation as alternative JVM is preferred, it gives you more control where you will use DCEVM.\nWhy this is important? Because DCEVM forces your JVM to use only one GC algorithm, and this may cause performance penalty."); licenseText.append("\n\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 only, as published by the Free Software Foundation.\n\nThis code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more details (a copy is included in the LICENSE file that accompanied this code).\n\nYou should have received a copy of the GNU General Public License version 2 along with this work; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA."); licenseText.append("\n\n\nASM LICENSE TEXT:\nCopyright (c) 2000-2005 INRIA, France Telecom\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."); license.setText(licenseText.toString()); JScrollPane licenses = new JScrollPane(license, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); licenses.setPreferredSize(new Dimension(150, 150)); center.add(licenses, BorderLayout.NORTH); center.add(getChooserPanel(), BorderLayout.CENTER); return center; }
private void positionPanel() { final JComponent contentComponent = myEditor.getContentComponent(); Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent); setSize(scroll.getSize()); myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight(); int count = countLines(myText.getText()); int visLines = getSize().height / myLineHeight - 1; int lines = Math.min(count, visLines); setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height + getBorder().getBorderInsets(this).top * 2); int height = getSize().height; Rectangle bounds = scroll.getBounds(); bounds.translate(0, scroll.getHeight() - height); bounds.height = height; Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), SwingUtilities.getRootPane(contentComponent).getGlassPane()); bounds.setLocation(pos); setBounds(bounds); myScrollPane.getVerticalScrollBar().setValue(0); if (!Options.getInstance().isSet("more")) { // FIX scrollOffset(100000); } else { scrollOffset(0); } }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) { if (index == selected) { numberLabel.setFont(doDeriveFont(numberLabel.getFont(), Font.BOLD)); ta.setFont(doDeriveFont(ta.getFont(), Font.BOLD)); } else { numberLabel.setFont(doDeriveFont(numberLabel.getFont(), Font.PLAIN)); ta.setFont(doDeriveFont(ta.getFont(), Font.PLAIN)); } if (contentNumbered) { numberLabel.setText(Integer.toString(index + 1) + "."); // NOI18N } // #21322: on JDK1.4 wrapping width is cleared between two rendering runs Insets taInsets = ta.getInsets(); ta.setSize(taWidth, taInsets.top + taInsets.bottom + 1); ta.setText((String) value); return this; }
numberLabel.setFont(ta.getFont()); numberLabel.setOpaque(false); numberLabel.setPreferredSize(new Dimension(25, 0));
private static int countLines(JTextArea component, String value, int max) { int lineCount = 0; FontMetrics fontMetrics = component.getFontMetrics(component.getFont()); for (String s : value.split("\n")) { lineCount += 1 + fontMetrics.stringWidth(s) / max; } return lineCount; } }
@Override public void actionPerformed(ActionEvent e) { setTamanhoFonteConsole(console.getFont().getSize() - VALOR_INCREMENTO_FONTE); } };
private static int getTextAreaBaseline(JTextArea text, int height) { Insets insets = text.getInsets(); FontMetrics fm = text.getFontMetrics(text.getFont()); return insets.top + fm.getAscent(); }
public ShowStats(OtrosApplication otrosApplication) { super("Show my usage statistics", Icons.DOCUMENT_NUMBER, otrosApplication); message = new JTextArea(""); message.setFont(new Font(Font.MONOSPACED, Font.PLAIN, message.getFont().getSize())); message.setEditable(false); scrollPane = new JScrollPane(message); scrollPane.setBorder(BorderFactory.createTitledBorder("OtrosLogViewer statistics")); }
@Override public Dimension getPreferredSize(int rows, int columns) { Font f = textArea.getFont(); FontMetrics fm = textArea.getFontMetrics(f); int w = fm.charWidth('m') * columns; int h = fm.getHeight() * rows; Dimension spSize = getSwingComponent().getMinimumSize(); spSize.width += w; spSize.height += h; return spSize; }
protected void createLicenseTextArea() { licenseTextArea = new javax.swing.JTextArea(); $objectMap.put("licenseTextArea", licenseTextArea); licenseTextArea.setName("licenseTextArea"); licenseTextArea.setColumns(15); licenseTextArea.setLineWrap(true); licenseTextArea.setWrapStyleWord(true); licenseTextArea.setEditable(false); if (licenseTextArea.getFont() != null) licenseTextArea.setFont(licenseTextArea.getFont().deriveFont((float) 11)); }
protected void createThirdpartyTextArea() { thirdpartyTextArea = new javax.swing.JTextArea(); $objectMap.put("thirdpartyTextArea", thirdpartyTextArea); thirdpartyTextArea.setName("thirdpartyTextArea"); thirdpartyTextArea.setColumns(15); thirdpartyTextArea.setLineWrap(true); thirdpartyTextArea.setWrapStyleWord(true); thirdpartyTextArea.setEditable(false); if (thirdpartyTextArea.getFont() != null) thirdpartyTextArea.setFont(thirdpartyTextArea.getFont().deriveFont((float) 11)); }
protected void createErrorStack() { $objectMap.put("errorStack", errorStack = new JTextArea()); errorStack.setName("errorStack"); errorStack.setColumns(15); errorStack.setLineWrap(true); errorStack.setWrapStyleWord(true); errorStack.setEditable(false); if (errorStack.getFont() != null) { errorStack.setFont(errorStack.getFont().deriveFont((float) 9)); } }
protected void createLicenseTextArea() { $objectMap.put("licenseTextArea", licenseTextArea = new JTextArea()); licenseTextArea.setName("licenseTextArea"); licenseTextArea.setColumns(15); licenseTextArea.setLineWrap(true); licenseTextArea.setWrapStyleWord(true); licenseTextArea.setEditable(false); if (licenseTextArea.getFont() != null) { licenseTextArea.setFont(licenseTextArea.getFont().deriveFont((float) 11)); } }
protected void createErrorStack() { errorStack = new javax.swing.JTextArea(); $objectMap.put("errorStack", errorStack); errorStack.setName("errorStack"); errorStack.setColumns(15); errorStack.setLineWrap(true); errorStack.setWrapStyleWord(true); errorStack.setEditable(false); if (errorStack.getFont() != null) errorStack.setFont(errorStack.getFont().deriveFont((float) 9)); }
protected void createErrorStack() { $objectMap.put("errorStack", errorStack = new JTextArea()); errorStack.setName("errorStack"); errorStack.setColumns(15); errorStack.setLineWrap(true); errorStack.setWrapStyleWord(true); errorStack.setEditable(false); if (errorStack.getFont() != null) { errorStack.setFont(errorStack.getFont().deriveFont((float) 9)); } }
protected void createDescription() { description = new javax.swing.JTextArea(); $objectMap.put("description", description); description.setName("description"); description.setColumns(15); description.setLineWrap(true); description.setWrapStyleWord(true); description.setFocusable(false); if (description.getFont() != null) description.setFont(description.getFont().deriveFont((float) 10)); description.setEditable(false); description.setRows(3); }
private JTextArea createTipTextArea(String tip) { tip = StringWrap.wrap(tip, 50, "\n", false); JTextArea tipArea = new JTextArea(tip); tipArea.setEditable(false); tipArea.setOpaque(false); Font font = tipArea.getFont(); tipArea.setFont(new Font(font.getFamily(), Font.PLAIN, font.getSize())); tipArea.setBorder(new EmptyBorder(10, 10, 10, 10)); return tipArea; }
private JTextArea createErrorTextArea(String msg) { msg = StringWrap.wrap(msg, 50, "\n", false); JTextArea errorArea = new JTextArea(msg); errorArea.setEditable(false); errorArea.setOpaque(false); Font font = errorArea.getFont(); errorArea.setFont(new Font(font.getFamily(), Font.BOLD, font.getSize()-1)); errorArea.setBorder(new EmptyBorder(10, 10, 0, 10)); return errorArea; }