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


Java JLabel.setOpaque方法代码示例

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


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

示例1: buildContentLoadingLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent buildContentLoadingLabel() {
    JLabel label = new JLabel( BundleSupport.getLabel( "ContentLoading" ) ); // NOI18N
    label.setHorizontalAlignment( JLabel.CENTER );
    label.setVerticalAlignment( JLabel.CENTER );
    label.setOpaque( false );
    Component header = getContentHeader();
    if( null != header ) {
        JPanel panel = new JPanel( new GridBagLayout() );
        panel.setOpaque( false );
        panel.add( header, new GridBagConstraints(0,0,1,1,1.0,1.0,
            GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
        panel.add( label, new GridBagConstraints(0,1,1,1,1.0,1.0,
            GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
        panel.setBorder( BorderFactory.createEmptyBorder(40, 0, 40, 0));
        return panel;
    }
    label.setBorder( BorderFactory.createEmptyBorder(40, 0, 40, 0));
    return label;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RSSFeed.java

示例2: MyPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
public MyPanel()
{
    setLayout(new MigLayout("ins 5, gapx 12, gapy 1", "[][35!][100:500:10000]", ""));
    setBorder(new UnderlineBorder(new Color(180, 180, 180)));

    status = new JLabel();
    status.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
    status.setOpaque(false);
    add(status, "ay center, spany 2");

    payment = new JLabel();
    payment.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    add(payment, "ax right, spany 2");

    carinfo = new JLabel();
    carinfo.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    add(carinfo, "gap 0, wrap");

    cardesc = new JLabel();
    cardesc.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
    add(cardesc, "gap 0");
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:23,代码来源:CarRenderer.java

示例3: FlyingToolTip

import javax.swing.JLabel; //导入方法依赖的package包/类
public FlyingToolTip(final FlyingToolTipListener source) {
    this.source = source;
    label = new JLabel("test", JLabel.CENTER) {
        @Override
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            int w = getWidth(), h = getHeight();
            g.setColor(getBackground());
            g.fillRect(0,0,w,h);

            if (path != null) {                    
                g2.setStroke(new BasicStroke(4f));
                g2.setColor(getForeground());
                g2.draw(path);
            }
            setOpaque(false);
            super.paintComponent(g2);
            setOpaque(true);
            g2.dispose();
        }
    };    
    label.setBorder(new EmptyBorder(2,4,10,4));
    label.setOpaque(true);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:25,代码来源:FlyingToolTip.java

示例4: setSelectionEntry

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 
 */
public void setSelectionEntry(JLabel entry, mxGraphTransferable t)
{
	JLabel previous = selectedEntry;
	selectedEntry = entry;

	if (previous != null)
	{
		previous.setBorder(null);
		previous.setOpaque(false);
	}

	if (selectedEntry != null)
	{
		selectedEntry.setBorder(ShadowBorder.getSharedInstance());
		selectedEntry.setOpaque(true);
	}

	eventSource.fireEvent(new mxEventObject(mxEvent.SELECT, "entry",
			selectedEntry, "transferable", t, "previous", previous));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:EditorPalette.java

示例5: configRenderer

import javax.swing.JLabel; //导入方法依赖的package包/类
private void configRenderer () {
    resultLabel = new JLabel();
    resultLabel.setOpaque(true);
    resultLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));

    itemPanel = new JPanel();
    itemPanel.setBackground(QuickSearchComboBar.getResultBackground());
    itemPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 3));
    itemPanel.setLayout(new BorderLayout());
    itemPanel.add(resultLabel, BorderLayout.CENTER);

    rendererComponent = new JPanel();
    rendererComponent.setLayout(new BorderLayout());
    rendererComponent.add(itemPanel, BorderLayout.CENTER);
    
    dividerLine = new JPanel();
    dividerLine.setBackground(QuickSearchComboBar.getPopupBorderColor());
    dividerLine.setPreferredSize(new Dimension(dividerLine.getPreferredSize().width, 1));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SearchResultRenderer.java

示例6: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (c instanceof JLabel) {
        JLabel label = (JLabel)c;
        label.setOpaque(isSelected);
        EclipseProject project = projects[row];
        if (project.isImportSupported()) {
            label.setIcon(project.getProjectTypeFactory().getProjectTypeIcon());
        } else {
            label.setIcon(null);
        }
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProjectSelectionPanel.java

示例7: 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

示例8: formatLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Sets the desired look of the lavel.
 * 
 * @param label
 *            Label to apply style to.
 * @param selected
 *            If label is selected or not.
 */
default void formatLabel(JLabel label, boolean selected) {
	label.setFont(Fonts.monospace);
	label.setOpaque(true);
	label.setBorder(BorderFactory.createEtchedBorder());
	if (selected) {
		label.setBackground(Color.decode(getTheme().listItemSelected));
	} else {
		label.setBackground(Color.decode(getTheme().listItemBackground));
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:19,代码来源:RenderFormatter.java

示例9: localizedHeaderLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Gets a label containing a localized message using the header font.
 *
 * @param key The message key to use.
 * @param alignment The alignment.
 * @param size The font size.
 * @return A suitable {@code JLabel}.
 */
public static JLabel localizedHeaderLabel(String key, int alignment,
                                          FontLibrary.FontSize size) {
    String text = Messages.message(key);
    JLabel header = new JLabel(text, alignment);
    header.setFont(FontLibrary.createCompatibleFont(
        text, FontLibrary.FontType.HEADER, size));
    header.setOpaque(false);
    return header;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:18,代码来源:Utility.java

示例10: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
	JLabel label = new JLabel(stationData.getStationName(value), JMTImageLoader.loadImage(stationData.getStationType(value) + "Combo"),
			SwingConstants.LEFT);
	label.setOpaque(true);
	label.setBorder(new LineBorder(cellHasFocus ? Color.BLUE : Color.WHITE));
	label.setBackground(isSelected ? list.getSelectionBackground() : Color.WHITE);
	label.setForeground(isSelected ? list.getSelectionForeground() : Color.BLACK);
	label.setFont(isSelected ? label.getFont().deriveFont(Font.BOLD) : label.getFont().deriveFont(Font.ROMAN_BASELINE));
	return label;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:11,代码来源:AllStationsParametersPanel.java

示例11: Sectors3DPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Builds a new Sectors3D Panel to show results of 3-class models
 * @param s3d results vector
 * @param classNames array with class names
 */
public Sectors3DPanel(Vector<Object> s3d, String[] classNames) {
	super(new BorderLayout());
	this.s3d = s3d;
	this.classNames = classNames;
	this.setBackground(BGCOLOR);
	this.setBorder(BorderFactory.createEtchedBorder());

	// Label to show coordinates
	coordLabel = new JLabel();
	coordLabel.setBorder(BorderFactory.createEtchedBorder());
	coordLabel.setVisible(false);
	coordLabel.setOpaque(true);
	// Puts label on south-east corner
	JPanel tmp = new JPanel(new BorderLayout());
	tmp.add(coordLabel, BorderLayout.EAST);
	tmp.setOpaque(false);
	this.add(tmp, BorderLayout.SOUTH);

	// Adds a mouseListener to show graph coordinates
	this.addMouseMotionListener(new MouseMotionAdapter() {
		@Override
		public void mouseMoved(MouseEvent e) {
			if (isShown) {
				String coord = getCoordinates(e.getX(), e.getY());
				if (coord != null) {
					coordLabel.setText(coord);
					coordLabel.setVisible(true);
					Sectors3DPanel.this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
				} else {
					coordLabel.setText("");
					coordLabel.setVisible(false);
					Sectors3DPanel.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
				}
			}
		}
	});
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:43,代码来源:Sectors3DPanel.java

示例12: createGradientTitle

import javax.swing.JLabel; //导入方法依赖的package包/类
public static GradientPanel createGradientTitle(String title) {
	GradientPanel panel = new GradientPanel(UIManager.getColor(TITLE_GRADIENT_COLOR_A), UIManager.getColor(TITLE_GRADIENT_COLOR_B));
	panel.setLayout(new BorderLayout());
	panel.setBorder(TITLE_BORDER);
	panel.setPreferredSize(new Dimension(0, 40));
	JLabel label = new JLabel(title);
	label.setOpaque(false);
	label.setFont(UIManager.getFont(TITLE_FONT));
	label.setForeground(UIManager.getColor(TITLE_FOREGROUND));
	label.setHorizontalAlignment(JLabel.LEADING);
	panel.add(label, BorderLayout.CENTER);
	return panel;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:14,代码来源:Guitilities.java

示例13: prepareRenderer

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component prepareRenderer(
        TableCellRenderer renderer,
        int row,
        int column) {
    
    SwitcherTableItem item
            = (SwitcherTableItem) getSwitcherTableModel().getValueAt(row, column);
    
    boolean selected = row == getSelectedRow() &&
            column == getSelectedColumn() && item != null;
    
    Component ren = renderer.getTableCellRendererComponent(this, item,
            selected, selected, row, column);
    JLabel lbl = null;
    if (ren instanceof JLabel) {
        // #199007: Swing HTML renderer does a poor job of truncating long labels
        JLabel prototype = (JLabel) ren;
        lbl = HtmlRenderer.createLabel();
        if( lbl instanceof HtmlRenderer.Renderer ) {
            ((HtmlRenderer.Renderer)lbl).setRenderStyle( HtmlRenderer.STYLE_TRUNCATE );
        }
        lbl.setForeground(prototype.getForeground());
        lbl.setBackground(prototype.getBackground());
        lbl.setFont(prototype.getFont());
        // border, text will be overwritten below anyway
        ren = lbl;
    }
    
    if (item == null) {
        // it's a filler space, we're done
        if( null != lbl ) {
            lbl.setOpaque(false);
            lbl.setIcon(null);
        }
        return ren;
    }
    
    Icon icon = item.getIcon();
    if (icon == null || icon.getIconWidth() == 0 ) {
        icon = nullIcon;
    }
    boolean active = item.isActive();
    if( null != lbl ) {
        lbl.setText((selected || (active && !TABNAMES_HTML)) ? stripHtml( item.getHtmlName() ) : item.getHtmlName());
        lbl.setBorder(rendererBorder);
        if( showIcons ) {
            lbl.setIcon(icon);
            lbl.setIconTextGap(26 - icon.getIconWidth());
        }
    }
    
    if (active) {
        if (TABNAMES_HTML) {
            if( null != lbl )
                lbl.setText(lbl.getText() + " ←"); // NOI18N
        } else if (Utilities.isWindows()) {
            ren.setFont(getFont().deriveFont(Font.BOLD, getFont().getSize()));
        } else {
            // don't use deriveFont() - see #49973 for details
            ren.setFont(new Font(getFont().getName(), Font.BOLD, getFont().getSize()));
        }
    }

    if( null != lbl )
        lbl.setOpaque(true);
    
    return ren;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:SwitcherTable.java

示例14: initComponentsMore

import javax.swing.JLabel; //导入方法依赖的package包/类
private void initComponentsMore(ImportData data, boolean removeUnusedImports) {
    contentPanel.setLayout( new GridBagLayout() );
    contentPanel.setBackground( UIManager.getColor("Table.background") ); //NOI18N
    jScrollPane1.setBorder( UIManager.getBorder("ScrollPane.border") ); //NOI18N
    jScrollPane1.getVerticalScrollBar().setUnitIncrement( new JLabel("X").getPreferredSize().height );
    jScrollPane1.getVerticalScrollBar().setBlockIncrement( new JLabel("X").getPreferredSize().height*10 );
    
    if (data.variants.length > 0 ) {
    
        int row = 0;

        combos = new JComboBox[data.variants.length];

        Font monoSpaced = new Font( "Monospaced", Font.PLAIN, new JLabel().getFont().getSize() );
        FocusListener focusListener = new FocusListener() {
            public void focusGained(FocusEvent e) {
                Component c = e.getComponent();
                Rectangle r = c.getBounds();
                contentPanel.scrollRectToVisible( r );
            }
            public void focusLost(FocusEvent arg0) {
            }
        };
        for (int i=0; i < data.variants.length; i++){
            combos[i] = createComboBox(data.variants[i], data.defaults[i], monoSpaced, focusListener );

            JLabel lblSimpleName = new JLabel(data.simpleNames[i]);
            lblSimpleName.setOpaque( false );
            lblSimpleName.setFont( monoSpaced );
            lblSimpleName.setLabelFor( combos[i] );

            contentPanel.add( lblSimpleName, new GridBagConstraints(0,row,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(3,5,2,5),0,0) );
            contentPanel.add( combos[i], new GridBagConstraints(1,row++,1,1,1.0,0.0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(3,5,2,5),0,0) );
        }

        contentPanel.add( new JLabel(), new GridBagConstraints(2,row,2,1,0.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0) );

        Dimension d = contentPanel.getPreferredSize();
        d.height = getRowHeight() * Math.min(combos.length, 6);
        jScrollPane1.getViewport().setPreferredSize( d );
    } else {
        contentPanel.add( new JLabel(getBundleString("FixDupImportStmts_NothingToFix")), new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(20,20,20,20),0,0) );
    }
    
    // load localized text into widgets:
    lblTitle.setText(getBundleString("FixDupImportStmts_IntroLbl")); //NOI18N
    lblHeader.setText(getBundleString("FixDupImportStmts_Header")); //NOI18N
    
    checkUnusedImports = new JCheckBox();
    Mnemonics.setLocalizedText(checkUnusedImports, getBundleString("FixDupImportStmts_UnusedImports")); //NOI18N
    bottomPanel.add( checkUnusedImports, BorderLayout.WEST );
    checkUnusedImports.setEnabled(true);
    checkUnusedImports.setSelected(removeUnusedImports);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:FixDuplicateImportStmts.java

示例15: FirstContactDialog

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Create an FirstContactDialog.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param player The {@code Player} making contact.
 * @param other The {@code Player} to contact.
 * @param tile An optional {@code Tile} on offer.
 * @param settlementCount The number of settlements the other
 *     player has.
 */
public FirstContactDialog(FreeColClient freeColClient, JFrame frame,
        Player player, Player other, Tile tile, int settlementCount) {
    super(freeColClient, frame);

    MigPanel panel
        = new MigPanel(new MigLayout("wrap 1", "[center]", "[]20"));
    panel.setOpaque(false);

    String headerKey = BASE_KEY + other.getNation().getSuffix();
    String imageKey = IMAGE_BASE_KEY + other.getNationResourceKey();
    if (!Messages.containsKey(headerKey)) {
        headerKey = BASE_KEY + NATIVES_KEY;
        imageKey = IMAGE_BASE_KEY + NATIVES_KEY;
    }
    JLabel header = Utility.localizedHeaderLabel(headerKey,
        SwingConstants.LEADING, FontLibrary.FontSize.MEDIUM);
    JLabel image
        = new JLabel(new ImageIcon(ResourceManager.getImage(imageKey)));
    image.setOpaque(false);

    JTextArea tutorial = null;
    if (!player.hasContactedIndians() && freeColClient.tutorialMode()) {
        tutorial = Utility.localizedTextArea(TUTORIAL_KEY);
    }

    String messageId = (tile != null)
        ? "firstContactDialog.welcomeOffer.text"
        : "firstContactDialog.welcomeSimple.text";
    String type = ((IndianNationType)other.getNationType())
        .getSettlementTypeKey(true);
    JTextArea text = Utility.localizedTextArea(StringTemplate
        .template(messageId)
        .addStringTemplate("%nation%", other.getNationLabel())
        .addName("%camps%", Integer.toString(settlementCount))
        .add("%settlementType%", type));

    // Resize the text areas to better match the image.
    int columns = (int)Math.floor(text.getColumns()
        * image.getPreferredSize().getWidth()
        / text.getPreferredSize().getWidth());
    text.setColumns(columns);
    text.setSize(text.getPreferredSize());
    if (tutorial != null) {
        tutorial.setColumns(columns);
        tutorial.setSize(tutorial.getPreferredSize());
    }

    panel.add(header);
    panel.add(image);
    if (tutorial != null) panel.add(tutorial);
    panel.add(text);
    panel.setSize(panel.getPreferredSize());

    ImageIcon icon = new ImageIcon(
        getImageLibrary().getMiscIconImage(other.getNation()));
    initializeConfirmDialog(frame, false, panel, icon, "yes", "no");
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:69,代码来源:FirstContactDialog.java


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