本文整理匯總了Java中javax.swing.JComponent.setForeground方法的典型用法代碼示例。如果您正苦於以下問題:Java JComponent.setForeground方法的具體用法?Java JComponent.setForeground怎麽用?Java JComponent.setForeground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.setForeground方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareRenderer
import javax.swing.JComponent; //導入方法依賴的package包/類
protected void prepareRenderer(JComponent comp) {
comp.setBackground(getBackground());
comp.setForeground(getForeground());
comp.setBounds(0, 0, getWidth(), getHeight());
JComponent innermost;
if ((innermost = findInnermostRenderer(comp)) instanceof JComboBox) {
if (comp.getLayout() != null) {
comp.getLayout().layoutContainer(comp);
}
}
if (!isTableUI() && ((InplaceEditor) comp).supportsTextEntry()) {
innermost.setBackground(PropUtils.getTextFieldBackground());
innermost.setForeground(PropUtils.getTextFieldForeground());
}
}
示例2: getTableCellRendererComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
String valueStr = (String) value;
JLabel label = new JLabel(valueStr);
label.setHorizontalAlignment(SwingConstants.CENTER);
selectBox.setHorizontalAlignment(SwingConstants.CENTER);
selectBox.setBorderPainted(true);
JComponent component = (column == 0) ? selectBox : label;
component.setForeground(tableHeader.getForeground());
component.setBackground(tableHeader.getBackground());
component.setFont(tableHeader.getFont());
component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return component;
}
示例3: getTableCellRendererComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
JComponent comp = (JComponent) super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, col);
List<Integer> dupList = getDuplicate(row);
if (!dupList.isEmpty()) {
comp.setForeground(errorColor);
comp.setToolTipText("Duplicate with Step " + dupList);
} else if (col == ExecutionStep.HEADERS.Status.getIndex()) {
if ("Passed".equals(value)) {
comp.setForeground(Color.GREEN.darker());
} else if ("Failed".equals(value)) {
comp.setForeground(errorColor);
} else {
comp.setForeground(table.getForeground());
}
} else {
comp.setForeground(table.getForeground());
comp.setToolTipText(null);
}
return comp;
}
示例4: installUI
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void installUI(JComponent c) {
super.installUI(c);
if (c instanceof JButton) {
btn = (JButton) c;
// btn.setMargin(new Insets(0,0,0,0));
// Insets margins = btn.getInsets();
// btn.setMargin(btn.getInsets());//new Insets(2, margins.top, 2,
// margins.bottom));
btn.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
if (!(c instanceof XDMButton)) {
c.setForeground(Color.WHITE);
c.setBackground(StaticResource.btnBgColor);
btn.setBorderPainted(false);
}
}
}
示例5: getTableCellRendererComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
boolean joinTable = false;
boolean validClass = true;
boolean existentUpdate = false;
String problemDisplayName = null;
if (jTable.getModel() instanceof TableClassNamesModel) {
TableClassNamesModel model = (TableClassNamesModel)jTable.getModel();
Table table = model.getTableAt(row);
joinTable = table.isJoin();
if (column == 1) {
existentUpdate = table.getDisabledReason() instanceof Table.ExistingDisabledReason;
validClass = model.isValidClass(table);
if (!validClass) {
problemDisplayName = model.getProblemDisplayName(table);
}
}
}
Object realValue = null;
if (joinTable && column == 1) {
realValue = NbBundle.getMessage(TableUISupport.class, "LBL_JoinTable");
} else {
realValue = value;
}
JComponent component = (JComponent)super.getTableCellRendererComponent(jTable, realValue, isSelected, hasFocus, row, column);
component.setEnabled(!joinTable && !existentUpdate);
component.setToolTipText(joinTable ? NbBundle.getMessage(TableUISupport.class, "LBL_JoinTableDescription") : problemDisplayName);
component.setForeground((validClass) ? nonErrorForeground : errorForeground);
return component;
}
示例6: configureNewComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
void configureNewComponent(RADComponent item) {
if(item != null) {
JComponent c = (JComponent) formDesigner.getComponent(item);
if(c != null) {
c.setForeground(Color.LIGHT_GRAY);
}
}
}
示例7: configureEditedComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
private void configureEditedComponent(JComponent c) {
if(c == null) return;
if(USE_NEW_ITEM_COLOR_SWITCHING) {
if(c.getForeground() == Color.LIGHT_GRAY) {
c.setForeground(getNormalForeground(c));
}
}
}
示例8: keyReleased
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void keyReleased(KeyEvent e)
{
int code = e.getKeyCode();
if( code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE )
{
JComponent c = (JComponent) e.getComponent();
c.setForeground(mTextNormal);
c.setBackground(mBackgroundNormal);
}
}
示例9: getTreeCellRendererComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
setValue(value, row); // NOTE: should use table.convertRowIndexToModel(row)
JComponent comp = getComponent();
comp.setOpaque(false);
if (tree != null) {
comp.setForeground(tree.getForeground());
comp.setBackground(tree.getBackground());
}
return comp;
}
示例10: render
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void render(JComponent comp, TestStep step, Object value) {
comp.setForeground(getColor(step));
if (step.isCommented() || step.hasBreakPoint()) {
comp.setFont(new Font("Default", Font.BOLD, 11));
}
}
示例11: decorateJComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
private void decorateJComponent(JComponent component) {
String prop = (String)component.getClientProperty("com.rapidminer.ui.label.type");
if("header".equals(prop)) {
component.setFont(OPEN_SANS_LIGHT_28);
component.setForeground(SwingTools.RAPIDMINER_ORANGE);
} else if("bold".equals(prop)) {
component.setFont(OPEN_SANS_SEMIBOLD_14);
component.setForeground(Color.DARK_GRAY);
} else if("normal".equals(prop)) {
component.setFont(OPEN_SANS_LIGHT_14);
component.setForeground(Color.DARK_GRAY);
} else if("large".equals(prop)) {
component.setFont(OPEN_SANS_SEMIBOLD_16);
component.setForeground(Color.DARK_GRAY);
}
prop = (String)component.getClientProperty("com.rapidminer.ui.button.type");
if("cfa".equals(prop)) {
component.setFont(OPEN_SANS_SEMIBOLD_14);
component.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
} else if("normal".equals(prop)) {
component.setFont(OPEN_SANS_LIGHT_14);
component.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
component.setMinimumSize(new Dimension(175, component.getPreferredSize().height));
component.setPreferredSize(new Dimension(175, component.getPreferredSize().height));
}
prop = (String)component.getClientProperty("com.rapidmniner.ui.link_button.id");
if(prop != null && component instanceof LinkButton) {
((LinkButton)component).setText(this.generateHTML(prop));
}
Color foregroundColor = (Color)component.getClientProperty("com.rapidminer.ui.label.foreground");
if(foregroundColor != null) {
component.setForeground(foregroundColor);
}
}
示例12: mouseReleased
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public synchronized void mouseReleased(MouseEvent e)
{
JComponent c = (JComponent) e.getComponent();
c.setForeground(mTextNormal);
c.setBackground(mBackgroundNormal);
c.repaint();
}
示例13: mouseEntered
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public synchronized void mouseEntered(MouseEvent e)
{
JComponent c = (JComponent) e.getComponent();
if( c.isEnabled() )
{
c.setForeground(mTextActive);
c.setBackground(mBackgroundActive);
c.repaint();
}
}
示例14: mouseExited
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public synchronized void mouseExited(MouseEvent e)
{
JComponent c = (JComponent) e.getComponent();
c.setForeground(mTextNormal);
c.setBackground(mBackgroundNormal);
c.repaint();
}
示例15: keyReleased
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public synchronized void keyReleased(KeyEvent e)
{
int code = e.getKeyCode();
if( code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE )
{
JComponent c = (JComponent) e.getComponent();
c.setForeground(mTextNormal);
c.setBackground(mBackgroundNormal);
}
}