本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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
}
示例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++;
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}