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


Java JLabel.setBackground方法代码示例

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


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

示例1: init

import javax.swing.JLabel; //导入方法依赖的package包/类
private void init() {
    setBackground(new Color(0, 0, 0, 0));
    setOpaque(false);
    JLabel modelo = new JLabel() {
        @Override
        public String toString() {
            return hero.getToString();
        }
    };
    modelo.setBackground(new Color(0, 0, 0, 0));
    modelo.setHorizontalAlignment(SwingConstants.CENTER);
    modelo.setIcon(Images.ARENA_HEROI);
    add(hero.getPanelHeroi(), AbsolutesConstraints.HEROI_PANEL_IMAGEM, 0);
    add(modelo, AbsolutesConstraints.ZERO, 0);
    add(hero.getPanelAtaque(), AbsolutesConstraints.HEROI_PANEL_ATAQUE, 0);
    add(hero.getPanelEscudo(), AbsolutesConstraints.HEROI_PANEL_SHIELD, 0);
    add(hero.getPanelVida(), AbsolutesConstraints.HEROI_PANEL_VIDA, 0);
    add(hero.getPanelPoder(), AbsolutesConstraints.HEROI_PANEL_PODER, 0);
    add(hero.getPanelArma(), AbsolutesConstraints.HEROI_PANEL_ARMA, 0);
    add(hero.getPanelSegredo(), AbsolutesConstraints.HEROI_PANEL_SEGREDO, 0);
    add(hero.getPanelDanoMagico(), AbsolutesConstraints.HEROI_PANEL_DANO_MAGICO, 0);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:23,代码来源:HeroiView.java

示例2: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Action[] actions = ((AbstractSummaryView.ActionsItem) value).getParent().getUserData().getActions();
    id = ((AbstractSummaryView.ActionsItem) value).getItemId();
    removeAll();
    labels = new HashMap<Component, Action>(actions.length);
    Component comp = dlcr.getListCellRendererComponent(list, "<html><a href=\"action\">ACTION_NAME</a>", index, isSelected, cellHasFocus); //NOI18N
    setBackground(comp.getBackground());
    for (Action a : actions) {
        JLabel label = getLabelFor((String) a.getValue(Action.NAME), isSelected ? comp.getForeground() : LINK_COLOR);
        label.setForeground(comp.getForeground());
        label.setBackground(comp.getBackground());
        label.setBorder(BorderFactory.createEmptyBorder());
        labels.put(label, a);
        add(label);
    }
    if (linkerSupport.getLinker(ActionHyperlink.class, id) == null) {
        linkerSupport.add(new ActionHyperlink(), id);
    }
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SummaryCellRenderer.java

示例3: initComponents

import javax.swing.JLabel; //导入方法依赖的package包/类
protected void initComponents() {        
    if (!oPanel.isPrepared()) {
        initComponent = new JLabel(NbBundle.getMessage(InitPanel.class, "LBL_computing")); // NOI18N
        initComponent.setPreferredSize(new Dimension(850, 450));
        // avoid flicking ?
        Color c = UIManager.getColor("Tree.background"); // NOI18N
        if (c == null) {
            //GTK 1.4.2 will return null for Tree.background
            c = Color.WHITE;
        }
        initComponent.setBackground(c);    // NOI18N               
        initComponent.setHorizontalAlignment(SwingConstants.CENTER);
        initComponent.setOpaque(true);
        
        CardLayout card = new CardLayout();
        setLayout(card);            
        add(initComponent, "init");    // NOI18N
        card.show(this, "init"); // NOI18N        
        Utilities.attachInitJob(this, this);
    } else {
        finished();  
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:InitPanel.java

示例4: addChoice

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Create a choice menu.
 *  @param name The name used to identify the entry (when calling get).
 *  @param label The label to attach to the entry.
 *  @param values The list of possible choices.
 *  @param defaultChoice Default choice.
 *  @param editable True if an arbitrary choice can be entered, in addition
 *   to the choices in values.
 *  @param background The background color for the editable part.
 */
public void addChoice(
        String name,
        String label,
        String[] values,
        String defaultChoice,
        boolean editable,
        Color background) {
    JLabel lbl = new JLabel(label + ": ");
    lbl.setBackground(_background);
    JComboBox combobox = new JComboBox(values);
    combobox.setEditable(editable);
    // FIXME: Typical of Swing, the following does not set
    // the background color.  How does one set the background
    // color?
    combobox.setBackground(background);
    combobox.setSelectedItem(defaultChoice);
    _addPair(name, lbl, combobox, combobox);
    // Add the listener last so that there is no notification
    // of the first value.
    combobox.addItemListener(new QueryItemListener(name));
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:31,代码来源:Query.java

示例5: decorateParameterPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Decorates the given parameter editor panel with a "mandatory parameter" hint.
 *
 * @param parameterEditor
 *            the parameter editor panel
 * @return the decorated panel
 */
private JPanel decorateParameterPanel(final JPanel parameterEditor) {
	JPanel parentPanel = new JPanel(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 1.0;
	gbc.weighty = 1.0;
	gbc.fill = GridBagConstraints.BOTH;
	parentPanel.add(parameterEditor, gbc);

	JLabel warningLabel = new JLabel(I18N.getGUIMessage("gui.bubble." + decorateI18N + ".label"));
	boolean isError = getStyle() == BubbleStyle.ERROR;
	warningLabel.setIcon(isError ? ERROR_ICON : WARNING_ICON);
	warningLabel.setBackground(isError ? BubbleStyle.ERROR.getColor() : BubbleStyle.WARNING.getColor());
	warningLabel.setOpaque(true);
	warningLabel.setBorder(new EmptyBorder(1, 1, 1, 0));
	gbc.gridy += 1;
	gbc.weighty = 0.0;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.insets = new Insets(2, 0, 0, 0);
	parentPanel.add(warningLabel, gbc);

	return parentPanel;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:ParameterErrorInfoBubble.java

示例6: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(
    JList<? extends JCheckBox> list, JCheckBox value, int index,
    boolean isSelected, boolean cellHasFocus) {
  JPanel panel = new JPanel(new BorderLayout());

  JCheckBox checkbox = value;
  final JCheckBox newCheck = new JCheckBox();
  final JLabel newLabel = new JLabel(checkbox.getText());
  newCheck.setSelected(checkbox.isSelected());
  // Drawing checkbox, change the appearance here
  newCheck.setBackground(isSelected ? getSelectionBackground()
      : getBackground());
  newCheck.setForeground(isSelected ? getSelectionForeground()
      : getForeground());
  newCheck.setEnabled(isEnabled());
  newCheck.setFont(getFont());
  newCheck.setFocusPainted(false);
  newCheck.setBorderPainted(true);
  newCheck.setBorder(isSelected ? UIManager
      .getBorder("List.focusCellHighlightBorder") : noFocusBorder);
  newLabel.setOpaque(true);
  newLabel.setBackground(isSelected ? getSelectionBackground()
      : getBackground());
  newLabel.setForeground(isSelected ? getSelectionForeground()
      : getForeground());
  newLabel.setEnabled(isEnabled());
  newLabel.setFocusable(false);
  newLabel.setFont(getFont());
  newLabel.setBorder(isSelected ? UIManager
      .getBorder("List.focusCellHighlightBorder") : noFocusBorder);
  newLabel.setIcon(checkbox.getIcon());

  panel.add(newCheck, BorderLayout.WEST);
  panel.add(newLabel, BorderLayout.CENTER);
  return panel;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:38,代码来源:JCheckBoxList.java

示例7: buildInfo

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
     * Builds the tool information
     *
     * @return JComponent
     */
    private JComponent buildInfo() {
        JPanel info = new JPanel();
        info.setLayout(new BoxLayout(info, BoxLayout.Y_AXIS));
        JLabel title = new JLabel("VISNode");
        title.setFont(new Font("Segoe UI", Font.PLAIN, 32));
        JLabel version = new JLabel(VERSION);
        version.setBackground(Color.red);
        
//        github = new JButton();
//        github.setIcon(IconFactory.get().create("fa:github"));
//        github.setText(GITHUB_URL);
//        github.setBorder(BorderFactory.createEmptyBorder());
//        github.setBorderPainted(false);
//        github.setContentAreaFilled(false);
//        github.setFocusPainted(false);
//        github.setOpaque(false);
        info.add(title);
        info.add(version);
        info.add(Labels.create(GITHUB_URL).icon(IconFactory.get().create("fa:github")).onClick((ev) -> {
            try {
                Desktop.getDesktop().browse(new URL(GITHUB_URL).toURI());
            } catch (IOException | URISyntaxException e) {
                ExceptionHandler.get().handle(e);
            }
        }));
        return info;
    }
 
开发者ID:VISNode,项目名称:VISNode,代码行数:33,代码来源:AboutVISNodePanel.java

示例8: initialize

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * This method initializes this with the default user interface options
 * @return void
 */
private void initialize() {
	jLabel = new JLabel();
	jLabel.setText("JLabel");
	jLabel.setBackground(Color.gray);
	jLabel.setForeground(highlightColor);
	jLabel.setHorizontalAlignment(SwingConstants.CENTER);
	this.setSize(300, 200);
	this.setLayout(new BorderLayout());
	this.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
	this.add(getLabelPanel(), BorderLayout.SOUTH);
	this.add(getContentPanel(), BorderLayout.CENTER);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:17,代码来源:GroupPanel.java

示例9: WarningMessage

import javax.swing.JLabel; //导入方法依赖的package包/类
public WarningMessage(String ErrMessage) {
	setBounds(100, 100, 650, 500);
	this.getContentPane().setLayout(new BorderLayout());
	{
		JPanel buttonPane = new JPanel();
		buttonPane.setBackground(new Color(144, 238, 144));
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);
		{
			JButton cancelButton = new JButton("OK");
			cancelButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					dispose();
				}
			});
			cancelButton.setFont(new Font("Times New Roman", Font.BOLD, 12));
			cancelButton.setHorizontalAlignment(SwingConstants.LEFT);
			buttonPane.add(cancelButton);
		}
	}
	{
		JLabel label = new JLabel("Warning!");
		label.setBackground(new Color(144, 238, 144));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setForeground(new Color(100, 0, 0));
		label.setFont(new Font("Times New Roman", Font.BOLD, 24));
		getContentPane().add(label, BorderLayout.NORTH);
	}
	{
		JScrollPane scrollPane = new JScrollPane();
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		{
			JTextArea txtErrMessage = new JTextArea();
			txtErrMessage.setText(ErrMessage);
			txtErrMessage.setFont(new Font("Monospaced", Font.PLAIN, 13));
			txtErrMessage.setBackground(new Color(144, 238, 144));
			scrollPane.setViewportView(txtErrMessage);
			txtErrMessage.setCaretPosition(0);
			txtErrMessage.setEditable(false);
		}
	}
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:43,代码来源:WarningMessage.java

示例10: DragFileHandle

import javax.swing.JLabel; //导入方法依赖的package包/类
private void DragFileHandle(final JPanel myPanel) {
    new FileDrop(myPanel, new FileDrop.Listener() {
        public void filesDropped(java.io.File[] files) {
            for (int i = 0; i < files.length; i++) {
                Icon ico = FileSystemView.getFileSystemView().getSystemIcon(files[i]);
                FindFiles(myPanel.getName(), files[i]);
                Image image = ((ImageIcon) ico).getImage();
                ImageIcon icon = new ImageIcon(getScaledImage(image, 45, 45));

                myPanel.removeAll();
                myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));

                JLabel label = new JLabel();
                label.setIcon(icon);
                label.setAlignmentX(CENTER_ALIGNMENT);

                myPanel.add(Box.createRigidArea(new Dimension(0, 60)));
                myPanel.add(label, BorderLayout.CENTER);

                GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
                JLabel labe2 = new JLabel(files[i].getName(), SwingConstants.CENTER);
                labe2.setBackground(new Color(240, 240, 240));
                labe2.setForeground(new Color(0, 0, 0));
                labe2.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
                labe2.setAlignmentX(CENTER_ALIGNMENT);

                myPanel.add(labe2, BorderLayout.LINE_START);
            }
        }
    });
}
 
开发者ID:PanagiotisDrakatos,项目名称:EasyDragDrop,代码行数:32,代码来源:MainFrame.java

示例11: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Component getTableCellRendererComponent(final JTable table,
        final Object value, final boolean isSelected,
        final boolean hasFocus, final int row, final int column) {
    Object newValue = value;

    if (value instanceof String) {
        if (value.equals(ClassModel.NO_CLASS)) {
            if (m_defaultClassModel.isActive()) {
                newValue = m_defaultClassModel.getStringValue();
            } else {
                newValue = "?"; // Not labeled!
            }
        }

        final JLabel label = new JLabel((String) newValue);

        if (isSelected) {
            label.setForeground(table.getSelectionForeground());
            label.setBackground(table.getSelectionBackground());
            label.setOpaque(true);
        }

        if (hasFocus) {
            label.setBorder(table.getBorder());
        }

        return label;
    }

    return new JLabel("non string");
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:36,代码来源:ClassCellRenderer.java

示例12: GoToPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Creates new form GoToPanel */
public GoToPanel( ContentProvider contentProvider, boolean multiSelection ) throws IOException {
    this.contentProvider = contentProvider;
    initComponents();
    ((AbstractDocument)nameField.getDocument()).setDocumentFilter(UiUtils.newUserInputFilter());
    containsScrollPane = true;
            
    matchesList.setSelectionMode( multiSelection ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION);
    //matchesList.setPrototypeCellValue("12345678901234567890123456789012345678901234567890123456789012345678901234567890");        
    matchesList.addListSelectionListener(null);
    
    Color bgColorBrighter = new Color(
                                Math.min(getBackground().getRed() + BRIGHTER_COLOR_COMPONENT, 255),
                                Math.min(getBackground().getGreen() + BRIGHTER_COLOR_COMPONENT, 255),
                                Math.min(getBackground().getBlue() + BRIGHTER_COLOR_COMPONENT, 255)
                        );
    
    messageLabel = new JLabel();
    messageLabel.setBackground(bgColorBrighter);
    messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
    messageLabel.setEnabled(true);
    messageLabel.setText(NbBundle.getMessage(GoToPanel.class, "TXT_NoTypesFound")); // NOI18N
    messageLabel.setFont(matchesList.getFont());
    
    // matchesList.setBackground( bgColorBrighter );
    // matchesScrollPane1.setBackground( bgColorBrighter );
    matchesList.setCellRenderer( contentProvider.getListCellRenderer(
            matchesList,
            caseSensitive.getModel()));
    contentProvider.setListModel( this, null );
    
    PatternListener pl = new PatternListener( this );
    nameField.getDocument().addDocumentListener(pl);
    caseSensitive.setSelected(UiOptions.GoToTypeDialog.getCaseSensitive());
    caseSensitive.addItemListener(pl);
    matchesList.addListSelectionListener(pl);                       

    searchHistory = new SearchHistory(GoToPanel.class, nameField);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:GoToPanel.java

示例13: createPossibleSetsJLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel createPossibleSetsJLabel() {
    JLabel label = new JLabel();
    label.setOpaque(true);
    label.setBackground(Color.gray);
    label.setBorder(new EmptyBorder(10, 10, 10, 10));
    return label;
}
 
开发者ID:mlpinit,项目名称:GameOfSet,代码行数:8,代码来源:InfoPanel.java

示例14: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	JLabel listCellRendererComponent = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
			isSelected, cellHasFocus);

	listCellRendererComponent.setPreferredSize(new Dimension(50, 20));

	if (!(value instanceof Color)) {
		return listCellRendererComponent;
	}

	listCellRendererComponent.setText("");

	Color color = (Color) value;

	Icon iicon = colorMap.get(color);
	if (iicon == null) {
		colorMap.put(color, createColoredRectangleIcon(color));
		iicon = colorMap.get(color);
	}

	listCellRendererComponent.setIcon(iicon);
	listCellRendererComponent.setBackground(color);

	if (isSelected && index != -1) {
		listCellRendererComponent.setBorder(focusBorder);
	} else {
		listCellRendererComponent.setBorder(noFocusBorder);
	}

	return listCellRendererComponent;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:34,代码来源:ColorRGBComboBoxCellRenderer.java

示例15: createJLabelForTable

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * It creates a new label for inclusion in a table.
 * 
 * @return A new label for inclusion in a table.
 *
 * @see #createJLabelForTable()
 */
static public JLabel createJLabelForTable() {
    JLabel label = new JLabel();
    setPlain(label);
    label.setOpaque(true);
    label.setForeground(TABLE_COMPONENT_FG_COLOR);
    label.setBackground(TABLE_COMPONENT_BG_COLOR);
    return label;
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:16,代码来源:GUIUtilities.java


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