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


Java JComponent.setBackground方法代码示例

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


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

示例1: 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;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:18,代码来源:UserTableHeaderCellRenderer.java

示例2: adjustBackground

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Change background of given component to light gray on Mac look and feel
 * when the component is in a tabbed container and its background hasn't been
 * already changed (is instance of UIResource).
 * @param c
 */
static void adjustBackground( JComponent c ) {
    if( !isAquaLaF || useDefaultBackground )
        return;

    if( !isInTabbedContainer(c) )
        return;

    Color currentBackground = c.getBackground();
    if( currentBackground instanceof UIResource ) {
        c.setBackground(UIManager.getColor("NbExplorerView.background"));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ViewUtil.java

示例3: setSelectionColor

import javax.swing.JComponent; //导入方法依赖的package包/类
private void setSelectionColor(Boolean rowSelected, Boolean cellSelected,
        JComponent comp, Color defalutRowBgColor) {
    if (rowSelected) {
        comp.setBackground(BG_SELECT_COLOR);
    } else {
        comp.setBackground(defalutRowBgColor);
    }
    if (cellSelected) {
        if (focused) {
            comp.setBackground(DEF_SELECTION_COLOR);
        } else {
            comp.setBackground(NOFOCUS_SELECTION_COLOR);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:16,代码来源:XTable.java

示例4: applySelectionStyle

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Component showing task progress
 */

// some convenience methods
private void applySelectionStyle(boolean selected, JComponent c) {
    if (selected)
        c.setBackground(table.getSelectionBackground());
    else
        c.setBackground(table.getBackground());
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:12,代码来源:TimeLogTableCellRenderer.java

示例5: StatisticsPanel

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 */
public StatisticsPanel(final ResultDisplayHandler displayHandler) {
    super(new BorderLayout(0, 0));
    this.displayHandler = displayHandler;
    JComponent toolbar = createToolbar();
    treePanel = new ResultPanelTree(displayHandler, this);
    treePanel.setFilterMask(filterMask);

    add(toolbar, BorderLayout.WEST);
    add(treePanel, BorderLayout.CENTER);
    if( isMacLaf ) {
        toolbar.setBackground(macBackground);
        treePanel.setBackground(macBackground);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:StatisticsPanel.java

示例6: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProfilerTreeTable.java

示例7: updateFieldStatus

import javax.swing.JComponent; //导入方法依赖的package包/类
private void updateFieldStatus(JComponent label, IssueField... fields) {
    label.setOpaque(false);
    for (IssueField field : fields) {
        boolean highlight = !issue.isNew() && (issue.getFieldStatus(field) & BugzillaIssue.FIELD_STATUS_MODIFIED) != 0;
        if (highlight) {
            label.setOpaque(true);
            label.setBackground(incomingChangesColor);
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:IssuePanel.java

示例8: keyPressed

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public synchronized void keyPressed(KeyEvent e)
{
	int code = e.getKeyCode();
	if( code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE )
	{
		JComponent c = (JComponent) e.getComponent();
		c.setForeground(mTextPressed);
		c.setBackground(mBackgroundPressed);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:FlatterCheckBoxUI.java

示例9: getTableCellEditorComponent

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) {
	JComponent c = (JComponent) super.getTableCellEditorComponent(table, value, selected, row, column);
	if (!type.isOptional() && (type.getDefaultValue() == null)) {
		c.setFont(c.getFont().deriveFont(Font.BOLD, c.getFont().getSize()));
	}
	if (selected) {
		c.setBackground(SwingTools.LIGHTEST_BLUE);
	} else {
		c.setBackground(Color.WHITE);
	}
	return c;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:DefaultPropertyKeyRenderer.java

示例10: applySelectionStyle

import javax.swing.JComponent; //导入方法依赖的package包/类
private void applySelectionStyle(boolean selected, JComponent c) {
    if (selected){
        c.setBackground(table.getSelectionBackground());
    }
    else
        c.setBackground(table.getBackground());
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:8,代码来源:TaskTreeTableCellRenderer.java

示例11: 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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:FlatterCheckBoxUI.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:FlatterCheckBoxUI.java

示例13: setJComponentBGandFG

import javax.swing.JComponent; //导入方法依赖的package包/类
private void setJComponentBGandFG(JComponent jc) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException{
	jc.setBackground((Color)Color.class.getField(Configuration.get("BACKGROUND_COLOR_SETTING").toString()).get(null));
     try{
     	Color currnt = (Color)Color.class.getField(Configuration.get("BACKGROUND_COLOR_SETTING").toString()).get(null);
     	if(currnt.equals(Color.BLACK)){
     		jc.setForeground(Color.WHITE);
     	}
     	if(currnt.equals(Color.BLUE)){
     		jc.setForeground(Color.WHITE);
     	}
     }catch(IllegalArgumentException iae){
     	iae.printStackTrace();
     }
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:15,代码来源:SetAppDialog.java

示例14: applySelectionStyle

import javax.swing.JComponent; //导入方法依赖的package包/类
private void applySelectionStyle(boolean selected, JComponent c) {
    if (selected)
        c.setBackground(table.getSelectionBackground());
    else
        c.setBackground(table.getBackground());
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:7,代码来源:TaskTreeTableCellRenderer.java

示例15: apply

import javax.swing.JComponent; //导入方法依赖的package包/类
/** Apply this coloring to component colors/font.
* The underline and strikeThrough line colors have no effect here.
*/
public void apply(JComponent c) {
    // Possibly change font
    if (font != null) {
        if (fontMode == FONT_MODE_DEFAULT) {
            c.setFont(font);

        } else { // non-default font-mode
            Font origFont = c.getFont();
            if (origFont != null) {
                synchronized (cacheLock) {
                    Font f = (Font)fontAndForeColorCache.get(origFont);
                    if (f == null) {
                        f = modifyFont(origFont);
                        fontAndForeColorCache.put(origFont, f);
                    }
                    c.setFont(f);
                }
            }
        }
    }

    // Possibly change fore-color
    if (foreColor != null) {
        if (!hasAlpha(foreColor)) {
            c.setForeground(foreColor);

        } else { // non-default fore color-mode
            Color origForeColor = c.getForeground();
            if (origForeColor != null) {
                synchronized (cacheLock) {
                    Color fc = (Color)fontAndForeColorCache.get(origForeColor);
                    if (fc == null) {
                        fc = modifyForeColor(origForeColor);
                        fontAndForeColorCache.put(origForeColor, fc);
                    }
                    c.setForeground(fc);
                }
            }
        }
    }

    // Possibly change back-color
    if (backColor != null) {
        if (!hasAlpha(backColor)) {
            c.setBackground(backColor);

        } else { // non-default back color-mode
            Color origBackColor = c.getBackground();
            if (origBackColor != null) {
                synchronized (cacheLock) {
                    Color bc = (Color)backColorCache.get(origBackColor);
                    if (bc == null) {
                        bc = modifyBackColor(origBackColor);
                        backColorCache.put(origBackColor, bc);
                    }
                    c.setBackground(bc);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:65,代码来源:Coloring.java


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