Java Code Examples for javax.swing.JLabel#setIconTextGap()

The following examples show how to use javax.swing.JLabel#setIconTextGap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelpHeaderRenderer.java    From lucene-solr with Apache License 2.0 7 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  if (table != null && this.table != table) {
    this.table = table;
    final JTableHeader header = table.getTableHeader();
    if (header != null) {
      panel.setLayout(new FlowLayout(FlowLayout.LEADING));
      panel.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
      panel.add(new JLabel(value.toString()));

      // add label with mouse click listener
      // when the label is clicked, help dialog will be displayed.
      JLabel helpLabel = new JLabel(FontUtils.elegantIconHtml("t", MessageUtils.getLocalizedMessage("label.help")));
      helpLabel.setHorizontalAlignment(JLabel.LEFT);
      helpLabel.setIconTextGap(5);
      panel.add(FontUtils.toLinkText(helpLabel));

      // add mouse listener to JTableHeader object.
      // see: https://stackoverflow.com/questions/7137786/how-can-i-put-a-control-in-the-jtableheader-of-a-jtable
      header.addMouseListener(new HelpClickListener(column));
    }
  }
  return panel;
}
 
Example 2
Source File: BoundingBoxValidator.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
private void init() {
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/org/citydb/gui/images/map/map_icon.png")));
	setLayout(new GridBagLayout());
	setBackground(Color.WHITE);	

	messageLabel = new JLabel();
	messageLabel.setIcon(new ImageIcon(getClass().getResource("/org/citydb/gui/images/map/loader.gif")));
	messageLabel.setIconTextGap(10);

	button = new JButton(Language.I18N.getString("common.button.ok"));
	button.setVisible(false);

	add(messageLabel, GuiUtil.setConstraints(0, 0, 1, 0, GridBagConstraints.HORIZONTAL, 10, 10, 10, 10));
	add(button, GuiUtil.setConstraints(0, 1, 0, 0, GridBagConstraints.NONE, 10, 5, 10, 5));

	button.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			dispose();
		}
	});

	pack();
	setLocationRelativeTo(getOwner());
	setResizable(false);
}
 
Example 3
Source File: EditorPanel.java    From jclic with GNU General Public License v2.0 6 votes vote down vote up
protected JLabel createTitleLabel(int preferredWidth) {
  JLabel result = new JLabel(getTitle());
  result.setHorizontalAlignment(SwingConstants.CENTER);
  if (getIcon() != null) {
    result.setIcon(getIcon());
    result.setIconTextGap(10);
  }
  result.setBackground(titleBgColor);
  result.setForeground(titleForeColor);
  result.setOpaque(true);
  result.setBorder(titleBorder);
  result.validate();
  Dimension d = result.getPreferredSize();
  result.setPreferredSize(new Dimension(Math.max(d.width, preferredWidth), d.height));
  result.setMinimumSize(result.getPreferredSize());
  return result;
}
 
Example 4
Source File: HiscorePanel.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private JPanel makeHiscorePanel(HiscoreSkill skill)
{
	HiscoreSkillType skillType = skill == null ? HiscoreSkillType.SKILL : skill.getType();

	JLabel label = new JLabel();
	label.setFont(FontManager.getRunescapeSmallFont());
	label.setText(pad("--", skillType));

	String directory;
	if (skill == null || skill == OVERALL)
	{
		directory = "/skill_icons/";
	}
	else if (skill.getType() == HiscoreSkillType.BOSS)
	{
		directory = "bosses/";
	}
	else
	{
		directory = "/skill_icons_small/";
	}

	String skillName = (skill == null ? "combat" : skill.name().toLowerCase());
	String skillIcon = directory + skillName + ".png";
	log.debug("Loading skill icon from {}", skillIcon);

	label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));

	boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat
	label.setIconTextGap(totalLabel ? 10 : 4);

	JPanel skillPanel = new JPanel();
	skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0));
	skillLabels.put(skill, label);
	skillPanel.add(label);

	return skillPanel;
}
 
Example 5
Source File: CardColorStatsPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
void setStats(CardStatistics stats) {

        lines.clear();
        for (int i = 0; i < stats.colorCount.length; i++) {
            if (stats.colorCount[i] > 0) {
                final MagicColor color = MagicColor.values()[i];
                final JLabel label = new JLabel(MagicImages.getIcon(color.getManaType()));
                label.setHorizontalAlignment(JLabel.LEFT);
                label.setIconTextGap(5);
                label.setText(MText.get(_S4,
                    stats.colorCount[i],
                    stats.colorMono[i],
                    stats.colorLands[i])
                );
                lines.add(label);
            }
        }

        final JLabel allLabel = new JLabel(MText.get(_S3,
            stats.monoColor,
            stats.multiColor,
            stats.colorless)
        );
        allLabel.setFont(allLabel.getFont().deriveFont(Font.ITALIC));
        lines.add(allLabel);

        final JPanel panel = new JPanel(new MigLayout("flowy, insets 4"));
        panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));
        panel.setOpaque(false);
        for (final JLabel line : lines) {
            panel.add(line, "w 100%");
        }

        removeAll();
        add(DeckStatisticsViewer.getCaptionLabel(MText.get(_S1)), "w 100%");
        add(panel, "w 100%");
        revalidate();
    }
 
Example 6
Source File: JComponentBuilders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void setupInstance(JLabel instance) {
    super.setupInstance(instance);
    
    instance.setText(text);
    
    if (defaultIcon != null) instance.setIcon(defaultIcon.createInstance());
    
    instance.setVerticalAlignment(verticalAlignment);
    instance.setHorizontalAlignment(horizontalAlignment);
    instance.setVerticalTextPosition(verticalTextPosition);
    instance.setHorizontalTextPosition(horizontalTextPosition);
    instance.setIconTextGap(iconTextGap);
}
 
Example 7
Source File: MainPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private static void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) {
    tabbedPane.add(tab);

    JLabel lbl = new JLabel(title);
    lbl.setIcon(icon);
    lbl.setIconTextGap(5);
    lbl.setHorizontalTextPosition(SwingConstants.RIGHT);

    tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl);
}
 
Example 8
Source File: BasicTaskPaneGroupUI.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public PaneBorder() {
  borderColor = UIManager.getColor("TaskPaneGroup.borderColor");      

  titleForeground = UIManager.getColor("TaskPaneGroup.titleForeground");

  specialTitleBackground = UIManager
    .getColor("TaskPaneGroup.specialTitleBackground");
  specialTitleForeground = UIManager
    .getColor("TaskPaneGroup.specialTitleForeground");

  titleBackgroundGradientStart = UIManager
    .getColor("TaskPaneGroup.titleBackgroundGradientStart");
  titleBackgroundGradientEnd = UIManager
    .getColor("TaskPaneGroup.titleBackgroundGradientEnd");
  
  titleOver = UIManager.getColor("TaskPaneGroup.titleOver");
  if (titleOver == null) {
    titleOver = specialTitleBackground.brighter();
  }
  specialTitleOver = UIManager.getColor("TaskPaneGroup.specialTitleOver");
  if (specialTitleOver == null) {
    specialTitleOver = specialTitleBackground.brighter();
  }
  
  label = new JLabel();
  label.setOpaque(false);
  label.setIconTextGap(8);
}
 
Example 9
Source File: JComponentBuilders.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void setupInstance(JLabel instance) {
    super.setupInstance(instance);
    
    instance.setText(text);
    
    if (defaultIcon != null) instance.setIcon(defaultIcon.createInstance());
    
    instance.setVerticalAlignment(verticalAlignment);
    instance.setHorizontalAlignment(horizontalAlignment);
    instance.setVerticalTextPosition(verticalTextPosition);
    instance.setHorizontalTextPosition(horizontalTextPosition);
    instance.setIconTextGap(iconTextGap);
}
 
Example 10
Source File: JavaInformationsPanel.java    From javamelody with Apache License 2.0 5 votes vote down vote up
static JLabel toBar(String text, double percentValue) {
	final String tmp = replaceLineFeedWithHtmlBr(text);
	final JLabel label = new JLabel(tmp);
	label.setIconTextGap(10);
	try {
		label.setIcon(new ImageIcon(Bar.toBar(percentValue)));
	} catch (final IOException e) {
		throw new IllegalStateException(e);
	}
	label.setHorizontalTextPosition(SwingConstants.LEFT);
	final double myPercent = Math.max(Math.min(percentValue, 100d), 0d);
	label.setToolTipText(I18N.createPercentFormat().format(myPercent) + '%');
	return label;
}
 
Example 11
Source File: CategoryList.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static Icon centeredIcon(final Icon icon, final int width, final int height) {
    JLabel l = new JLabel(icon);
    l.setIconTextGap(0);
    l.setBorder(null);
    l.setSize(width, height);
    
    BufferedImage img = new BufferedImage(l.getWidth(), l.getHeight(), BufferedImage.TYPE_INT_ARGB);
    l.paint(img.getGraphics());
    
    return new ImageIcon(img);
}
 
Example 12
Source File: ThumbnailLabelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.addComponentListener(repaintComponentListener);
	JLabel label = (JLabel) c;
	label.setHorizontalTextPosition(SwingConstants.CENTER);
	label.setIconTextGap(3);
}
 
Example 13
Source File: HiscorePanel.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private JPanel makeHiscorePanel(HiscoreSkill skill)
{
	HiscoreSkillType skillType = skill == null ? HiscoreSkillType.SKILL : skill.getType();

	JLabel label = new JLabel();
	label.setFont(FontManager.getRunescapeSmallFont());
	label.setText(pad("--", skillType));

	String directory;
	if (skill == null || skill == OVERALL)
	{
		directory = "/skill_icons/";
	}
	else if (skill.getType() == HiscoreSkillType.BOSS)
	{
		directory = "bosses/";
	}
	else
	{
		directory = "/skill_icons_small/";
	}

	String skillName = (skill == null ? "combat" : skill.name().toLowerCase());
	String skillIcon = directory + skillName + ".png";
	log.debug("Loading skill icon from {}", skillIcon);

	label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));

	boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat
	label.setIconTextGap(totalLabel ? 10 : 4);

	JPanel skillPanel = new JPanel();
	skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0));
	skillLabels.put(skill, label);
	skillPanel.add(label);

	return skillPanel;
}
 
Example 14
Source File: BoundingBoxValidator.java    From importer-exporter with Apache License 2.0 4 votes vote down vote up
private void addBoundingBox() {
	JPanel bboxPanel = new JPanel();
	bboxPanel.setLayout(new GridBagLayout());

	JLabel title = new JLabel(Language.I18N.getString("map.boundingBox.label"));
	title.setFont(title.getFont().deriveFont(Font.BOLD));
	title.setIcon(new ImageIcon(getClass().getResource("/org/citydb/gui/images/map/selection.png")));
	title.setIconTextGap(5);

	JLabel lowerLabel = new JLabel("Xmin / Ymin");
	JLabel upperLabel = new JLabel("Xmax / Ymax");

	JLabel lower = new JLabel(String.valueOf(bbox.getLowerCorner().getX()) + " / " + String.valueOf(bbox.getLowerCorner().getY()));
	JLabel upper = new JLabel(String.valueOf(bbox.getUpperCorner().getX()) + " / " + String.valueOf(bbox.getUpperCorner().getY()));

	bboxPanel.add(title, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.HORIZONTAL,0,2,0,5));
	bboxPanel.add(new JSeparator(JSeparator.HORIZONTAL), GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,0,10,0,5));

	GridBagConstraints c = GuiUtil.setConstraints(0,1,0.0,0.0,GridBagConstraints.NONE,5,5,0,5);
	c.anchor = GridBagConstraints.EAST;			
	bboxPanel.add(lowerLabel, c);
	bboxPanel.add(lower, GuiUtil.setConstraints(1,1,1.0,0.0,GridBagConstraints.HORIZONTAL,5,20,0,5));

	c = GuiUtil.setConstraints(0,2,0.0,0.0,GridBagConstraints.NONE,5,5,0,5);
	c.anchor = GridBagConstraints.EAST;
	bboxPanel.add(upperLabel, c);
	bboxPanel.add(upper, GuiUtil.setConstraints(1,2,1.0,0.0,GridBagConstraints.HORIZONTAL,5,20,0,5));

	if (bbox.isSetSrs()) {
		String sridText = bbox.getSrs().getSrid() != 0 ? String.valueOf(bbox.getSrs().getSrid()) : "n/a";
		JLabel description = new JLabel(bbox.getSrs().getDescription());
		JLabel srid = new JLabel(sridText);

		c = GuiUtil.setConstraints(0,3,0.0,0.0,GridBagConstraints.NONE,5,5,0,5);
		c.anchor = GridBagConstraints.EAST;
		bboxPanel.add(new JLabel(Language.I18N.getString("pref.db.srs.label.description")), c);				
		bboxPanel.add(description, GuiUtil.setConstraints(1,3,1.0,0.0,GridBagConstraints.HORIZONTAL,5,20,0,5));

		c = GuiUtil.setConstraints(0,4,0.0,0.0,GridBagConstraints.NONE,5,5,0,5);
		c.anchor = GridBagConstraints.EAST;
		bboxPanel.add(new JLabel(Language.I18N.getString("pref.db.srs.label.srid")), c);
		bboxPanel.add(srid, GuiUtil.setConstraints(1,4,1.0,0.0,GridBagConstraints.HORIZONTAL,5,20,0,5));
	}

	add(bboxPanel, GuiUtil.setConstraints(0, row++, 1, 0, GridBagConstraints.BOTH, 5, 5, 5, 5));
}
 
Example 15
Source File: RocPlot.java    From rtg-tools with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates a new swing plot.
 * @param precisionRecall true defaults to precision recall graph
 * @param interpolate if true, enable curve interpolation
 */
RocPlot(boolean precisionRecall, boolean interpolate) {
  mInterpolate = interpolate;
  mMainPanel = new JPanel();
  UIManager.put("FileChooser.readOnly", Boolean.TRUE);
  mFileChooser = new JFileChooser();
  final Action details = mFileChooser.getActionMap().get("viewTypeDetails");
  if (details != null) {
    details.actionPerformed(null);
  }
  mFileChooser.setMultiSelectionEnabled(true);
  mFileChooser.setFileFilter(new RocFileFilter());
  mZoomPP = new RocZoomPlotPanel();
  mZoomPP.setOriginIsMin(true);
  mZoomPP.setTextAntialiasing(true);
  mProgressBar = new JProgressBar(-1, -1);
  mProgressBar.setVisible(true);
  mProgressBar.setStringPainted(true);
  mProgressBar.setIndeterminate(true);
  mStatusLabel = new JLabel();
  mPopup = new JPopupMenu();
  mRocLinesPanel = new RocLinesPanel(this);
  mScrollPane = new JScrollPane(mRocLinesPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  mScrollPane.setWheelScrollingEnabled(true);
  mLineWidthSlider = new JSlider(JSlider.HORIZONTAL, LINE_WIDTH_MIN, LINE_WIDTH_MAX, 1);
  mScoreCB = new JCheckBox("Show Scores");
  mScoreCB.setSelected(true);
  mSelectAllCB = new JCheckBox("Select / Deselect all");
  mTitleEntry = new JTextField("ROC");
  mTitleEntry.setMaximumSize(new Dimension(Integer.MAX_VALUE, mTitleEntry.getPreferredSize().height));
  mOpenButton = new JButton("Open...");
  mOpenButton.setToolTipText("Add a new curve from a file");
  mCommandButton = new JButton("Cmd...");
  mCommandButton.setToolTipText("Send the equivalent rocplot command-line to the terminal");
  final ImageIcon icon = createImageIcon("com/rtg/graph/resources/realtimegenomics_logo.png", "RTG Logo");
  mIconLabel = new JLabel(icon);
  mIconLabel.setBackground(new Color(16, 159, 205));
  mIconLabel.setForeground(Color.WHITE);
  mIconLabel.setOpaque(true);
  mIconLabel.setFont(new Font("Arial", Font.BOLD, 24));
  mIconLabel.setHorizontalAlignment(JLabel.LEFT);
  mIconLabel.setIconTextGap(50);
  if (icon != null) {
    mIconLabel.setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  }
  mGraphType = new JComboBox<>(new String[] {ROC_PLOT, PRECISION_SENSITIVITY});
  mGraphType.setSelectedItem(precisionRecall ? PRECISION_SENSITIVITY : ROC_PLOT);
  configureUI();
}
 
Example 16
Source File: CategoryList.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public Category(String caption, String tooltip,
                boolean initialState, Component[] items,
                int index, int categoriesCount) {

    expanded = initialState;

    setOpaque(false);
    setLayout(new BorderLayout());

    headerLabel = new JLabel(caption);
    headerLabel.setForeground(new JMenuItem().getForeground());
    headerLabel.setToolTipText(tooltip);
    headerLabel.setIconTextGap(5);
    headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    headerLabel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    headerLabel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            expanded = !expanded;
            updateState();
        }
    });
    
    JMenuBar menuBar = new JMenuBar();
    menuBar.setBorder(BorderFactory.createEmptyBorder());
    menuBar.setBorderPainted(false);
    menuBar.setLayout(new BorderLayout());
    menuBar.add(headerLabel, BorderLayout.CENTER);
    
    itemsContainer = new JPanel() {
        public void setEnabled(boolean enabled) {
            Component[] components = getComponents();
            for (Component c : components) c.setEnabled(enabled);
        }
    };
    itemsContainer.setOpaque(false);
    itemsContainer.setLayout(new VerticalLayout(false));

    for (int i = 0; i < items.length; i++)
        itemsContainer.add(items[i]);

    add(menuBar, BorderLayout.NORTH);
    add(itemsContainer, BorderLayout.CENTER);

    updateState();

}
 
Example 17
Source File: FeaturesView.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public FeaturesView(Component defaultView, String buttonString) {
    if (UIUtils.isOracleLookAndFeel()) {
        setOpaque(true);
        setBackground(UIUtils.getProfilerResultsBackground());
    } else {
        setOpaque(false);
    }
    setBorder(BorderFactory.createEmptyBorder());
    setLayout(new BorderLayout(0, 0));
    
    if (defaultView != null) {
        JScrollPane sp = new JScrollPane(defaultView, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
            public Dimension getMinimumSize() { return getPreferredSize(); }
        };
        sp.getVerticalScrollBar().setUnitIncrement(20);
        sp.setBorder(null);
        sp.setViewportBorder(null);

        this.defaultView = sp;
        add(this.defaultView, BorderLayout.CENTER);
    } else {
        this.defaultView = null;
    }
    
    if (buttonString != null) {
        hintLabel = new JLabel();
        hintLabel.setIcon(Icons.getIcon(GeneralIcons.INFO));
        hintLabel.setIconTextGap(hintLabel.getIconTextGap() + 1);
        hintLabel.setOpaque(false);
        
        Font font = new JToolTip().getFont();
        
        Color f = hintLabel.getForeground();
        int r = f.getRed() + 70;
        if (r > 255) r = f.getRed() - 70; else r = Math.min(r, 70);
        int g = f.getGreen() + 70;
        if (g > 255) g = f.getRed() - 70; else g = Math.min(g, 70);
        int b = f.getBlue() + 70;
        if (b > 255) b = f.getRed() - 70; else b = Math.min(b, 70);
        hintLabel.setText("<html><body text=\"rgb(" + r + ", " + g + ", " + b + ")\" style=\"font-size: " + //NOI18N
                          (font.getSize()) + "pt; font-family: " + font.getName() + ";\">" + //NOI18N
                          Bundle.FeaturesView_noData("<b>" + buttonString + "</b>") + "</body></html>"); //NOI18N
        
        hintLabel.setSize(hintLabel.getPreferredSize());
        
        Color c = UIUtils.getProfilerResultsBackground();
        hintColor = Utils.checkedColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 245));
    } else {
        hintColor = null;
    }
}
 
Example 18
Source File: FeaturesView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FeaturesView(Component defaultView, String buttonString) {
    if (UIUtils.isOracleLookAndFeel()) {
        setOpaque(true);
        setBackground(UIUtils.getProfilerResultsBackground());
    } else {
        setOpaque(false);
    }
    setBorder(BorderFactory.createEmptyBorder());
    setLayout(new BorderLayout(0, 0));
    
    if (defaultView != null) {
        JScrollPane sp = new JScrollPane(defaultView, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
            public Dimension getMinimumSize() { return getPreferredSize(); }
        };
        sp.getVerticalScrollBar().setUnitIncrement(20);
        sp.setBorder(null);
        sp.setViewportBorder(null);

        this.defaultView = sp;
        add(this.defaultView, BorderLayout.CENTER);
    } else {
        this.defaultView = null;
    }
    
    if (buttonString != null) {
        hintLabel = new JLabel();
        hintLabel.setIcon(Icons.getIcon(GeneralIcons.INFO));
        hintLabel.setIconTextGap(hintLabel.getIconTextGap() + 1);
        hintLabel.setOpaque(false);
        
        Font font = new JToolTip().getFont();
        
        Color f = hintLabel.getForeground();
        int r = f.getRed() + 70;
        if (r > 255) r = f.getRed() - 70; else r = Math.min(r, 70);
        int g = f.getGreen() + 70;
        if (g > 255) g = f.getRed() - 70; else g = Math.min(g, 70);
        int b = f.getBlue() + 70;
        if (b > 255) b = f.getRed() - 70; else b = Math.min(b, 70);
        hintLabel.setText("<html><body text=\"rgb(" + r + ", " + g + ", " + b + ")\" style=\"font-size: " + //NOI18N
                          (font.getSize()) + "pt; font-family: " + font.getName() + ";\">" + //NOI18N
                          Bundle.FeaturesView_noData("<b>" + buttonString + "</b>") + "</body></html>"); //NOI18N
        
        hintLabel.setSize(hintLabel.getPreferredSize());
        
        Color c = UIUtils.getProfilerResultsBackground();
        hintColor = Utils.checkedColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 245));
    } else {
        hintColor = null;
    }
}
 
Example 19
Source File: MainWindow.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
private JPanel createToolbar() {
	JPanel p = new JPanel(new BorderLayout());
	Box toolBox = Box.createHorizontalBox();
	toolBox.add(Box.createRigidArea(new Dimension(scale(20), scale(60))));
	toolBox.setBackground(ColorResource.getTitleColor());
	toolBox.setOpaque(true);

	JButton btn1 = createToolButton("ADD_URL", "tool_add.png");
	btn1.setToolTipText(StringResource.get("MENU_ADD_URL"));
	toolBox.add(btn1);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn2 = createToolButton("DELETE", "tool_del.png");
	btn2.setToolTipText(StringResource.get("MENU_DELETE_DWN"));
	toolBox.add(btn2);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn3 = createToolButton("PAUSE", "tool_pause.png");
	btn3.setToolTipText(StringResource.get("MENU_PAUSE"));
	toolBox.add(btn3);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn4 = createToolButton("RESUME", "tool_resume.png");
	btn4.setToolTipText(StringResource.get("MENU_RESUME"));
	toolBox.add(btn4);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn5 = createToolButton("OPTIONS", "tool_settings.png");
	btn5.setToolTipText(StringResource.get("TITLE_SETTINGS"));
	toolBox.add(btn5);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn6 = createToolButton("MENU_VIDEO_DWN", "tool_video.png");
	btn6.setToolTipText(StringResource.get("MENU_VIDEO_DWN"));
	toolBox.add(btn6);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn7 = createToolButton("MENU_MEDIA_CONVERTER", "tool_convert.png");
	btn7.setToolTipText(StringResource.get("MENU_MEDIA_CONVERTER"));
	toolBox.add(btn7);
	toolBox.add(Box.createHorizontalGlue());

	btnMonitoring = new JLabel(ImageResource.getIcon("on.png", 85, 21));
	// btnMonitoring.setForeground(Color.WHITE);
	btnMonitoring.setIconTextGap(scale(15));
	btnMonitoring.putClientProperty("xdmbutton.norollover", "true");
	// btnMonitoring.setBackground(ColorResource.getTitleColor());
	btnMonitoring.setName("BROWSER_MONITORING");
	btnMonitoring.setText(StringResource.get("BROWSER_MONITORING"));
	btnMonitoring.setHorizontalTextPosition(JButton.LEADING);
	btnMonitoring.setFont(FontResource.getBigFont());

	btnMonitoring
			.setIcon(Config.getInstance().isBrowserMonitoringEnabled() ? ImageResource.getIcon("on.png", 85, 21)
					: ImageResource.getIcon("off.png", 85, 21));

	btnMonitoring.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseReleased(MouseEvent e) {
			toggleMonitoring((JLabel) e.getSource());
		}
	});
	toolBox.add(btnMonitoring);
	toolBox.add(Box.createRigidArea(new Dimension(scale(25), scale(10))));
	p.add(toolBox);
	return p;
}
 
Example 20
Source File: OnlyMessageBox.java    From oim-fx with MIT License 4 votes vote down vote up
private void init(String message, OnlyMessageBox.MessageType messageType, int option) {

      iconMap = new HashMap<OnlyMessageBox.MessageType, Icon>();
      iconMap.put(OnlyMessageBox.MessageType.ERROR, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.INFORMATION, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.QUESTION, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.WARNING, new ImageIcon());

      JPanel buttonPane = new JPanel();
      lbMessage = new JLabel(message, iconMap.get(messageType), JLabel.LEFT);
      btnOK = new JButton("确定");
      btnCancel = new JButton("取消");
      btnYes = new JButton("是");
      btnNo = new JButton("否");
      JButton[] buttons = {btnOK, btnYes, btnNo, btnCancel};
      int[] options = {OK_OPTION, YES_OPTION, NO_OPTION, CANCEL_OPTION};
      final Dimension buttonSize = new Dimension(69, 21);
      int index = 0;
      boolean hasDefaultButton = false;

     
      lbMessage.setIconTextGap(16);
      lbMessage.setHorizontalAlignment(JLabel.LEFT);
      lbMessage.setVerticalAlignment(JLabel.TOP);
      lbMessage.setVerticalTextPosition(JLabel.TOP);
      lbMessage.setBorder(new EmptyBorder(15, 25, 15, 25));
      buttonPane.setLayout(new LineLayout(6, 0, 0, 0, 0, LineLayout.LEADING, LineLayout.LEADING, LineLayout.HORIZONTAL));
      buttonPane.setPreferredSize(new Dimension(-1, 33));
      buttonPane.setBorder(new EmptyBorder(5, 9, 0, 9));
      buttonPane.setBackground(new Color(255, 255, 255, 170));

      for (JButton button : buttons) {
          button.setActionCommand(String.valueOf(options[index]));
          button.setPreferredSize(buttonSize);
          button.setVisible((option & options[index]) != 0);
          button.addActionListener(this);
          buttonPane.add(button, LineLayout.END);
          index++;

          if (!hasDefaultButton && button.isVisible()) {
              getRootPane().setDefaultButton(button);
              hasDefaultButton = true;
          }
      }

      getContentPane().setLayout(new LineLayout(0, 1, 1, 3, 1, LineLayout.LEADING, LineLayout.LEADING, LineLayout.VERTICAL));
      getContentPane().add(lbMessage, LineLayout.MIDDLE_FILL);
      getContentPane().add(buttonPane, LineLayout.END_FILL);
  }