List of usage examples for javax.swing JTextArea setFont
public void setFont(Font f)
From source file:Main.java
public Console() { JTextArea textArea = new JTextArea(24, 80); textArea.setBackground(Color.BLACK); textArea.setForeground(Color.LIGHT_GRAY); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); System.setOut(new PrintStream(new OutputStream() { @Override//from www.j av a 2 s .c o m public void write(int b) throws IOException { textArea.append(String.valueOf((char) b)); } })); frame.add(textArea); }
From source file:eu.lp0.cursus.ui.AboutDialog.java
private void initialise() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(Messages.getString("about.title", Constants.APP_DESC)); //$NON-NLS-1$ DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); FormLayout layout = new FormLayout("2dlu, pref, fill:pref:grow, max(30dlu;pref), 2dlu", //$NON-NLS-1$ "2dlu, max(15dlu;pref), 2dlu, max(15dlu;pref), 2dlu, fill:max(100dlu;pref):grow, 2dlu, max(16dlu;pref), 2dlu"); //$NON-NLS-1$ getContentPane().setLayout(layout);//from w w w . j a va 2s . c om JLabel lblName = new JLabel(Constants.APP_NAME + ": " + Messages.getString("about.description")); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblName, "2, 2, 3, 1"); //$NON-NLS-1$ getContentPane().add(new LinkJButton(Constants.APP_URL), "2, 4"); //$NON-NLS-1$ JScrollPane scrCopying = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); getContentPane().add(scrCopying, "2, 6, 3, 1"); //$NON-NLS-1$ JTextArea txtCopying = new JTextArea(loadResources("COPYRIGHT", "LICENCE")); //$NON-NLS-1$ //$NON-NLS-2$ txtCopying.setFont(Font.decode(Font.MONOSPACED)); txtCopying.setEditable(false); scrCopying.setViewportView(txtCopying); scrCopying.setPreferredSize( new Dimension(scrCopying.getPreferredSize().width, duc.dialogUnitYAsPixel(100, scrCopying))); Action actClose = new CloseDialogAction(this); JButton btnClose = new JButton(actClose); getContentPane().add(btnClose, "4, 8"); //$NON-NLS-1$ getRootPane().setDefaultButton(btnClose); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CloseDialogAction.class.getName()); getRootPane().getActionMap().put(CloseDialogAction.class.getName(), actClose); pack(); setMinimumSize(getSize()); setSize(getSize().width, getSize().height * 3 / 2); btnClose.requestFocusInWindow(); }
From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java
private void showErrorWindow(String title, String body) { try {/*from www . j a v a 2 s. c o m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // System.setProperty("apple.awt.UIElement", "false"); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JTextArea textArea = new JTextArea(body); JScrollPane scrollPane = new JScrollPane(textArea); textArea.setLineWrap(true); textArea.setFont(Font.getFont(Font.MONOSPACED)); textArea.setEditable(false); textArea.setWrapStyleWord(true); scrollPane.setPreferredSize(new Dimension(500, 500)); JTextPane titleLabel = new JTextPane(); titleLabel.setContentType("text/html"); // let the text pane know this is what you want titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off titleLabel.setEditable(false); titleLabel.setBackground(null); titleLabel.setBorder(null); panel.add(titleLabel); panel.add(scrollPane); final JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); moveCenter(frame); frame.setVisible(true); JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.", JOptionPane.CLOSED_OPTION); System.exit(1); } catch (Exception e) { log.error("Problem showing error window", e); } }
From source file:com.sshtools.common.ui.SshToolsApplicationPanel.java
/** * Show an error message with toggable detail * * @param parent// w w w .ja v a 2 s.c o m * @param mesg * @param title * @param exception */ public static void showErrorMessage(Component parent, String mesg, String title, Throwable exception) { boolean details = false; while (true) { String[] opts = new String[] { details ? "Hide Details" : "Details", "Ok" }; StringBuffer buf = new StringBuffer(); if (mesg != null) { buf.append(mesg); } appendException(exception, 0, buf, details); //MultilineLabel message = new MultilineLabel(buf.toString()); javax.swing.JTextArea message = new javax.swing.JTextArea(buf.toString()); message.setEditable(false); message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4)); javax.swing.JLabel jl = new javax.swing.JLabel(); message.setFont(jl.getFont()); message.setBackground(jl.getBackground()); int opt = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, opts, opts[1]); if (opt == 0) { details = !details; } else { break; } } }
From source file:net.sf.firemox.ui.component.SplashScreen.java
/** * Create a new instance of this class.//from ww w . j a v a2 s . c o m * * @param filename * the picture filename. * @param parent * the splash screen's parent. * @param waitTime * the maximum time before the screen is hidden. */ public SplashScreen(String filename, Frame parent, int waitTime) { super(parent); getContentPane().setLayout(null); toFront(); final JLabel l = new JLabel(new ImageIcon(filename)); final Dimension labelSize = l.getPreferredSize(); l.setLocation(0, 0); l.setSize(labelSize); setSize(labelSize); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - labelSize.width / 2, screenSize.height / 2 - labelSize.height / 2); final JLabel mp = new JLabel(IdConst.PROJECT_DISPLAY_NAME); mp.setLocation(30, 305); mp.setSize(new Dimension(300, 30)); final JLabel version = new JLabel(IdConst.VERSION); version.setLocation(235, 418); version.setSize(new Dimension(300, 30)); final JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setFont(MToolKit.defaultFont); disclaimer.setTabSize(2); // Then try and read it locally Reader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } final JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); disclaimerSPanel.setViewportView(disclaimer); disclaimerSPanel.setLocation(27, 340); disclaimerSPanel.setPreferredSize(new Dimension(283, 80)); disclaimerSPanel.setSize(disclaimerSPanel.getPreferredSize()); getContentPane().add(disclaimerSPanel); getContentPane().add(version); getContentPane().add(mp); getContentPane().add(l); final int pause = waitTime; final Runnable waitRunner = new Runnable() { public void run() { try { Thread.sleep(pause); while (!bKilled) { Thread.sleep(200); } } catch (InterruptedException e) { // Ignore this error } setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } }; // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { setVisible(false); dispose(); if (MagicUIComponents.magicForm != null) MagicUIComponents.magicForm.toFront(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } } }); setVisible(true); start(waitRunner); }
From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java
protected Component createPrettyPrintPanel(FIXMessage m) { final JTextArea textArea = new JTextArea(); textArea.setEditable(false);// w w w . ja va 2 s . c om textArea.setFont(Font.decode("Monospaced-PLAIN-12")); byte[] bytes = null; try { textArea.setText(FIXUtils.prettyPrint(m)); } catch (Throwable e) { textArea.setText(e.getMessage()); log.error("exception converting message to byte[]: ", e); } textArea.setCaretPosition(0); return SwingUtils.createJScrollPane(textArea); }
From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java
protected Component createHexPanel(FIXMessage m) { final JTextArea textArea = new JTextArea(); textArea.setEditable(false);/*from w w w .j a va 2s . co m*/ textArea.setFont(Font.decode("Monospaced-PLAIN-12")); byte[] bytes = null; try { textArea.setText(DumpUtils.dumpBinary(m.getBytes(), DumpUtils.DUMP_AS_HEX_AND_ALPHA)); } catch (Throwable e) { textArea.setText(e.getMessage()); log.error("exception converting message to byte[]: ", e); } textArea.setCaretPosition(0); final JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(textArea); return scrollPane; }
From source file:io.github.tavernaextras.biocatalogue.integration.config.BioCataloguePluginConfigurationPanel.java
private void initialiseUI() { this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.weightx = 1.0;/* w w w . j a v a 2s . com*/ c.gridx = 0; c.gridy = 0; JTextArea taDescription = new JTextArea("Configure the Service Catalogue integration functionality"); taDescription.setFont(taDescription.getFont().deriveFont(Font.PLAIN, 11)); taDescription.setLineWrap(true); taDescription.setWrapStyleWord(true); taDescription.setEditable(false); taDescription.setFocusable(false); taDescription.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(taDescription, c); c.gridy++; c.insets = new Insets(20, 0, 0, 0); JLabel jlBioCatalogueAPIBaseURL = new JLabel("Base URL of the Service Catalogue instance to connect to:"); this.add(jlBioCatalogueAPIBaseURL, c); c.gridy++; c.insets = new Insets(0, 0, 0, 0); tfBioCatalogueAPIBaseURL = new JTextField(); this.add(tfBioCatalogueAPIBaseURL, c); c.gridy++; c.insets = new Insets(30, 0, 0, 0); // We are not removing BioCatalogue services from its config panel any more - // they are being handled by the Taverna's Service Registry // JButton bForgetStoredServices = new JButton("Forget services added to Service Panel by BioCatalogue Plugin"); // bForgetStoredServices.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) // { // int response = JOptionPane.showConfirmDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent... // "Are you sure you want to clear all SOAP operations and REST methods\n" + // "that were added to the Service Panel by the BioCatalogue Plugin?\n\n" + // "This action is permanent is cannot be undone.\n\n" + // "Do you want to proceed?", "BioCatalogue Plugin", JOptionPane.YES_NO_OPTION); // // if (response == JOptionPane.YES_OPTION) // { // BioCatalogueServiceProvider.clearRegisteredServices(); // JOptionPane.showMessageDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent... // "Stored services have been successfully cleared, but will remain\n" + // "being shown in Service Panel during this session.\n\n" + // "They will not appear in the Service Panel after you restart Taverna.", // "BioCatalogue Plugin", JOptionPane.INFORMATION_MESSAGE); // } // } // }); // this.add(bForgetStoredServices, c); JButton bLoadDefaults = new JButton("Load Defaults"); bLoadDefaults.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadDefaults(); } }); JButton bReset = new JButton("Reset"); bReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetFields(); } }); JButton bApply = new JButton("Apply"); bApply.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyChanges(); } }); JPanel jpActionButtons = new JPanel(); jpActionButtons.add(bLoadDefaults); jpActionButtons.add(bReset); jpActionButtons.add(bApply); c.insets = new Insets(30, 0, 0, 0); c.gridy++; c.weighty = 1.0; this.add(jpActionButtons, c); }
From source file:net.sf.firemox.ui.wizard.About.java
/** * Creates a new instance of About <br> * //w w w .ja v a2s . c o m * @param parent */ public About(JFrame parent) { super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"), "mp64.gif", LanguageManager.getString("close"), 420, 620); JPanel thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLabel(IdConst.VERSION); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING)); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); thanksPanelLeft.setMaximumSize(new Dimension(100, 2000)); thanksPanelLeft.setMinimumSize(new Dimension(100, 16)); jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); thanksPanelLeft = new JPanel(); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); StringBuilder contributors = new StringBuilder(); addContributor(contributors, "Fabrice Daugan", "developper", "france"); addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia"); addContributor(contributors, "nico100", "graphist", "france"); addContributor(contributors, "seingalt_tm", "graphist", "france"); addContributor(contributors, "surtur2", "tester", null); addContributor(contributors, "Jan Blaha", "developper", "cz"); addContributor(contributors, "Tureba", "developper", "brazil"); addContributor(contributors, "hakvf", "tester", "france"); addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian"); jLabel5 = new JLabel(contributors.toString()); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); thanksPanelLeft.add(jLabel5); jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen"); jLabel5.setFont(MToolKit.defaultFont); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel blanklbl = new JLabel(); blanklbl.setHorizontalAlignment(SwingConstants.RIGHT); blanklbl.setMaximumSize(new Dimension(100, 16)); blanklbl.setMinimumSize(new Dimension(100, 16)); blanklbl.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(blanklbl); jLabel5 = new JLink( "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043", LanguageManager.getString("joindev")); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); // forum francais thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT); jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip")); thanksPanel.add(jLabel5); jLabel5 = new JLabel(); jLabel5.setMaximumSize(new Dimension(1000, 16)); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setTabSize(2); disclaimer.setFont(new Font("Arial", 0, 10)); // Then try and read it locally BufferedReader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(disclaimerSPanel); disclaimerSPanel.setViewportView(disclaimer); gameParamPanel.add(disclaimerSPanel); }
From source file:org.openmeetings.app.data.record.BatikMethods.java
public void drawTextByJTextArea(Graphics2D g2d, int x, int y, int width, int height, String text, String default_export_font, int style, int size, Color fontColor) throws Exception { // g2d.setClip(x, y, width, height); // g2d.setColor(Color.black); // g2d.drawString(text, x, y+20); //Font font = new Font("Verdana", Font.PLAIN, 11); Font font = new Font(default_export_font, style, size); String[] stringsText = text.split("\r"); //log.debug("TEXT: "+stringsText); //log.debug("TEXT: "+stringsText.length); String newText = ""; for (int i = 0; i < stringsText.length; i++) { newText += stringsText[i];/* ww w. j ava 2 s. c o m*/ if (i + 1 < stringsText.length) { newText += "\n"; } } JTextArea n = new JTextArea(newText); n.setFont(font); n.setWrapStyleWord(true); n.setLineWrap(true); n.setForeground(fontColor); //log.debug("Text at: "+x+" "+y); //int x, int y, int width, int height n.setBounds(x, y, width, height); n.setOpaque(false); //Text SVGGraphics2D svgGenerator2 = (SVGGraphics2D) g2d.create(x, y, width, height); //svgGenerator2.create(x, y, width, height); //svgGenerator2.draw(.dra) n.paint(svgGenerator2); }