当前位置: 首页>>代码示例>>Java>>正文


Java JButton.setForeground方法代码示例

本文整理汇总了Java中javax.swing.JButton.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setForeground方法的具体用法?Java JButton.setForeground怎么用?Java JButton.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setForeground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDetails

import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createDetails(String text, ActionListener action) {
    try {
        text = (action == null ? "<html>" : "<html><a href=\"_blank\">") + XMLUtil.toElementContent(text); //NOI18N
    } catch (CharConversionException ex) {
        throw new IllegalArgumentException(ex);
    }
    if (null == action) {
        return new JLabel(text);
    }
    JButton btn = new JButton(text);
    btn.setFocusable(false);
    btn.setBorder(BorderFactory.createEmptyBorder());
    btn.setBorderPainted(false);
    btn.setFocusPainted(false);
    btn.setOpaque(false);
    btn.setContentAreaFilled(false);
    btn.addActionListener(action);
    btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
    if (c != null) {
        btn.setForeground(c);
    }
    return btn;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NotificationImpl.java

示例2: getLinkButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Return a button suitable for linking to another panel
 * (e.g. ColopediaPanel).
 *
 * @param text a {@code String} value
 * @param icon an {@code Icon} value
 * @param action a {@code String} value
 * @return a {@code JButton} value
 */
public static JButton getLinkButton(String text, Icon icon, String action) {
    JButton button = new JButton(text, icon);
    button.setMargin(EMPTY_MARGIN);
    button.setOpaque(false);
    button.setForeground(LINK_COLOR);
    button.setAlignmentY(0.8f);
    button.setBorder(blankBorder(0, 0, 0, 0));
    button.setActionCommand(action);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return button;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:21,代码来源:Utility.java

示例3: stylizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton(JButton b){
	b.setFocusPainted(false);
	b.setFont(font_16_bold);
	b.setForeground(Color.WHITE);
	b.setBackground(new Color(46, 49, 55));
	b.setEnabled(true);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:8,代码来源:SimulatorGui.java

示例4: stylizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Created by Kevin Le to stylize buttons to all look the same
 * @param b
 */
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   	b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:13,代码来源:TrainModelNewGUI.java

示例5: stylizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   	b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:9,代码来源:TrackModelGUI.java

示例6: addTip

import javax.swing.JButton; //导入方法依赖的package包/类
void addTip(ParameterContainer f, JButton b) {
    String s = f.getPropertyTooltip(b.getText());
    if (s == null) {
        return;
    }
    b.setToolTipText(s);
    b.setForeground(Color.BLUE);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:9,代码来源:ParameterBrowserPanel.java

示例7: addTip

import javax.swing.JButton; //导入方法依赖的package包/类
void addTip(EventFilter f, JButton b) {
    String s = f.getPropertyTooltip(b.getText());
    if (s == null) {
        return;
    }
    b.setToolTipText(s);
    b.setForeground(Color.BLUE);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:9,代码来源:FilterPanel.java

示例8: stylizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   		b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:9,代码来源:TrainC.java

示例9: stylizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * JComponent styling wrappers
 */
public void stylizeButton(JButton b){
	b.setFocusPainted(false);
	b.setFont(font_14_bold);
	b.setForeground(Color.WHITE);
	b.setBackground(new Color(102, 0, 153)); // Purple
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:10,代码来源:TrainControllerGUI.java

示例10: addUnitTypes

import javax.swing.JButton; //导入方法依赖的package包/类
private void addUnitTypes() {
    int row = 1;

    JButton allColonistsButton = createUnitNameButton(Messages.message("report.labour.allColonists"), labourData.getSummary());
    reportPanel.add(allColonistsButton, "cell " + COLONY_COLUMN + " " + row + " 1 " + labourData.getSummary().getUnitSummaryRowCount());

    row = addLocationData(labourData.getSummary().getTotal(), null, row);

    for (UnitType unitType : LabourData.getLabourTypes(getMyPlayer())) {
        LabourData.UnitData unitData = labourData.getUnitData(unitType);

        JButton unitButton = createUnitNameButton(unitData.getUnitName(), unitData);
        int rows = unitData.getUnitSummaryRowCount();
        reportPanel.add(unitButton, "cell " + COLONY_COLUMN + " " + row + " 1 " + rows);

        if (unitData.hasDetails()) {
            row = addLocationData(unitData.getTotal(), null, row);
        } else {
            unitButton.setEnabled(false);
            unitButton.setDisabledIcon(unitButton.getIcon());
            unitButton.setForeground(Color.GRAY);

            reportPanel.add(createEmptyLabel(), "cell " + UNIT_TYPE_COLUMN + " " + row + " " + (COLUMNS - 1) + " 1");
            row++;
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:28,代码来源:CompactLabourReport.java

示例11: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createButton(String name, ActionListener listener) {
    JButton button = new JButton(name);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setOpaque(false);
    button.setHorizontalAlignment(SwingConstants.LEADING);
    button.setForeground(Utility.LINK_COLOR);
    button.setBorder(Utility.LEFTCELLBORDER);
    button.addActionListener(listener);
    return button;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:11,代码来源:CompactLabourReport.java

示例12: newButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton newButton(String action, String h, ImageIcon i,
                          Color c, StringTemplate t) {
    if (h != null && Messages.containsKey(h)) h = Messages.message(h);
    JButton b = Utility.getLinkButton(h, i, action);
    b.setForeground((c == null) ? Color.BLACK : c);
    if (t != null) Utility.localizeToolTip(b, t);
    b.addActionListener(this);
    return b;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:10,代码来源:ReportCompactColonyPanel.java

示例13: ButtonHtmlDemo

import javax.swing.JButton; //导入方法依赖的package包/类
public ButtonHtmlDemo() {
    ImageIcon leftButtonIcon = createImageIcon("images/right.gif");
    ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
    ImageIcon rightButtonIcon = createImageIcon("images/left.gif");

    b1 = new JButton("<html><center><b><u>D</u>isable</b><br>" + "<font color=#ffffdd>middle button</font>", leftButtonIcon);
    Font font = b1.getFont().deriveFont(Font.PLAIN);
    b1.setFont(font);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for
                                                          // left-to-right
                                                          // locales
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("middle button", middleButtonIcon);
    b2.setFont(font);
    b2.setForeground(new Color(0xffffdd));
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("<html><center><b><u>E</u>nable</b><br>" + "<font color=#ffffdd>middle button</font>", rightButtonIcon);
    b3.setFont(font);
    // Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:43,代码来源:ButtonHtmlDemo.java

示例14: stylizeButton_Disabled

import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton_Disabled(JButton b){
	b.setFocusPainted(false);
	b.setFont(font_14_bold);
	b.setForeground(Color.GRAY);
	b.setBackground(new Color(50, 0, 70));
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:7,代码来源:TrackControllerGUI.java

示例15: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
public JButton createButton(String string, Color color, Color textColor) {

		JButton button = createButton(string);

		button.setBackground(color);
		button.setForeground(textColor);

		return button;
	}
 
开发者ID:Gallery-of-Kaeon,项目名称:Kaeon-FUSION,代码行数:10,代码来源:IDE.java


注:本文中的javax.swing.JButton.setForeground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。