private final void addHyperLinkListener(final MultiLineLabel text) { text.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { BrowserLauncher.openURL(myURL); } catch (Exception ex) { IJ.error("" + ex); } } public void mouseEntered(MouseEvent e) { text.setForeground(Color.BLUE); text.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { text.setForeground(Color.BLACK); text.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); }
public void mouseExited(MouseEvent e) { text.setForeground(Color.BLACK); text.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } });
protected void measure() { Font font = getFont(); FontMetrics fm = font!=null?getFontMetrics(font):null; // If we don't have font metrics yet, just return. if (fm == null) return; line_height = fm.getHeight(); line_ascent = fm.getAscent(); max_width = 0; for(int i = 0; i < num_lines; i++) { line_widths[i] = fm.stringWidth(lines[i]); if (line_widths[i] > max_width) max_width = line_widths[i]; } }
if (text!=null && text.startsWith("IJ: ")) text = text.substring(4); label = new MultiLineLabel(text, 175); if (!IJ.isLinux()) label.setFont(new Font("SansSerif", Font.PLAIN, 14)); if (IJ.isMacOSX()) { RoiManager rm = RoiManager.getInstance();
public void addMessage(String text) { if (text.indexOf('\n')>=0) theLabel = new MultiLineLabel(text); else theLabel = new Label(text); theLabel.setFont(font); c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(text.equals("")?0:10,10,0,0); grid.setConstraints(theLabel, c); add(theLabel); y++; }
if (text!=null && text.startsWith("IJ: ")) text = text.substring(4); label = new MultiLineLabel(text, 175); if (!IJ.isLinux()) label.setFont(new Font("SansSerif", Font.PLAIN, 14)); if (IJ.isMacOSX()) { RoiManager rm = RoiManager.getInstance();
/** Adds a message consisting of one or more lines of text, which will be displayed using the specified font and color. */ public void addMessage(String text, Font font, Color color) { theLabel = null; if (text.indexOf('\n')>=0) theLabel = new MultiLineLabel(text); else theLabel = new Label(text); if (addToSameRow) { c.gridx = GridBagConstraints.RELATIVE; addToSameRow = false; } else { c.gridx = 0; c.gridy++; c.insets = getInsets("".equals(text)?0:10, 20, 0, 0); // top, left, bottom, right } c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; if (font!=null) { if (Prefs.getGuiScale()>1.0) font = font.deriveFont((float)(font.getSize()*Prefs.getGuiScale())); theLabel.setFont(font); } if (color!=null) theLabel.setForeground(color); add(theLabel, c); c.fill = GridBagConstraints.NONE; }
setFont(font); label = new MultiLineLabel(message); if (font!=null) label.setFont(font); else if (!IJ.isLinux()) label.setFont(new Font("SansSerif", Font.PLAIN, 14)); Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
@Override public void mouseExited( final MouseEvent e ) { text.setForeground( Color.BLACK ); text.setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) ); } });
/** Adds a message consisting of one or more lines of text, which will be displayed using the specified font and color. */ public void addMessage(String text, Font font, Color color) { theLabel = null; if (text.indexOf('\n')>=0) theLabel = new MultiLineLabel(text); else theLabel = new Label(text); if (addToSameRow) { c.gridx = GridBagConstraints.RELATIVE; addToSameRow = false; } else { c.gridx = 0; c.gridy++; c.insets = getInsets("".equals(text)?0:10, 20, 0, 0); // top, left, bottom, right } c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; if (font!=null) { if (Prefs.getGuiScale()>1.0) font = font.deriveFont((float)(font.getSize()*Prefs.getGuiScale())); theLabel.setFont(font); } if (color!=null) theLabel.setForeground(color); add(theLabel, c); c.fill = GridBagConstraints.NONE; }
text.addMouseListener( new MouseAdapter()
protected void measure() { Font font = getFont(); FontMetrics fm = font!=null?getFontMetrics(font):null; // If we don't have font metrics yet, just return. if (fm == null) return; line_height = fm.getHeight(); line_ascent = fm.getAscent(); max_width = 0; for(int i = 0; i < num_lines; i++) { line_widths[i] = fm.stringWidth(lines[i]); if (line_widths[i] > max_width) max_width = line_widths[i]; } }
public ChoicesDialog(Frame parent, String title, String msg, String[] options) { super(parent, title, true); setLayout(new BorderLayout()); Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); MultiLineLabel message = new MultiLineLabel(msg); message.setFont(new Font("Dialog", Font.BOLD, 12)); panel.add(message); add("North", panel); panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 8)); buttons = new Button[options.length]; chosen = new boolean[options.length]; for (int i=0;i<options.length;++i) { buttons[i]=new Button(options[i]); buttons[i].addActionListener(this); panel.add(buttons[i]); } add("South", panel); if (ij.IJ.isMacintosh()) setResizable(false); pack(); GUI.center(this); setVisible(true); }
@Override public void mouseEntered( final MouseEvent e ) { text.setForeground( Color.BLUE ); text.setCursor( new Cursor( Cursor.HAND_CURSOR ) ); }
else { if (fileName.length()>22) message = new MultiLineLabel("Save changes to\n" + "\"" + fileName + "\"?"); else message = new Label("Save changes to \"" + fileName + "\"?");
text.addMouseListener(new MouseAdapter()
setFont(font); label = new MultiLineLabel(message); if (font!=null) label.setFont(font); else if (!IJ.isLinux()) label.setFont(new Font("SansSerif", Font.PLAIN, 14)); Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
@Override public void mouseExited(MouseEvent e) { text.setForeground(Color.BLACK); text.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } });
else { if (fileName.length()>22) message = new MultiLineLabel("Save changes to\n" + "\"" + fileName + "\"?"); else message = new Label("Save changes to \"" + fileName + "\"?");
Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); MultiLineLabel message = new MultiLineLabel(msg); message.setFont(new Font("Dialog", Font.PLAIN, 12)); panel.add(message); add("North", panel);