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


Java JLabel类代码示例

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


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

示例1: createStatsTable

import javax.swing.JLabel; //导入依赖的package包/类
private JPanel createStatsTable(String title, Map<String, String> data) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(new JLabel(title), BorderLayout.PAGE_START);
    StatisticsModel model = new StatisticsModel();
    model.setData(data);
    JTable table = new JTable(model);
    table.setAutoCreateColumnsFromModel(true);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setAutoCreateRowSorter(true);
    JScrollPane scrollPane = new JScrollPane(table);
    table.addNotify();
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getColumnHeader().setOpaque(false);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(300, (data.size()+2)*17));
    return panel;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:19,代码来源:StatisticsPanel.java

示例2: getListCellRendererComponent

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

    cr.setIcon( DocSearchIcons.getIcon( ((DocIndexItem)value).getIconIndex() ) );

    try {
        if (  ((DocIndexItem)value).getURL() == null )
            setForeground (java.awt.SystemColor.textInactiveText);
    }
    catch ( java.net.MalformedURLException e ) {
        setForeground (java.awt.SystemColor.textInactiveText);
    }
    return cr;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:IndexListCellRenderer.java

示例3: switchCard

import javax.swing.JLabel; //导入依赖的package包/类
/**
 * If a card has the choosen attribute(so it is among the choosen ones) it
 * removes it from the list of the choosen cards and it adds it to the
 * selectable one. If the card hasn't that attribute it removes it from the
 * selectable ones and ot adds it to the choosen one; if the choosen cards
 * form a tris it is a valid one, it sets true the visibility of the button
 * <code>playTris</code>.
 *
 * @param label
 */
public void switchCard(JLabel label) {
    boolean chosen = (boolean) label.getClientProperty("chosen");
    if (chosen) {
        chosenCards.remove(label);
        cards.add(label);
        cardsPane.setLayer(label, -(getNrCards() - 1));

    } else {

        chosenCards.add(label);
        cards.remove(label);
        cardsPane.setLayer(label, -(getNrChosenCards() - 1));
    }
    if (checkOnTris(chosenCards)) {
        int bonus = game.getBonusForTris(getTrisAsString(chosenCards));
        playTris.setText("Gioca il tris. (" + bonus + ")");
        playTris.setVisible(true);
    } else {
        playTris.setVisible(false);
    }

    label.putClientProperty("chosen", !chosen);

}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:35,代码来源:CardPanel.java

示例4: getTableCellEditorComponent

import javax.swing.JLabel; //导入依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {

	Component editComponent = null;
	
	this.domainVector = ctsDialog.getDomainVector();
	this.domainName = (String) value;
	if (this.domainName!=null && this.domainName.equals(GeneralGraphSettings4MAS.DEFAULT_DOMAIN_SETTINGS_NAME)==true) {
		JLabel jLabel = new JLabel(this.domainName);
		editComponent = jLabel;
		
	} else {
		JTextField jTextField = new JTextField(this.domainName);
        jTextField.setBorder(BorderFactory.createEmptyBorder());
        jTextField.getDocument().addDocumentListener(this.getTextFieldDocumentListener());
        editComponent = jTextField;
        
	}
	return editComponent;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:21,代码来源:TableCellEditor4Domains.java

示例5: initComponents

import javax.swing.JLabel; //导入依赖的package包/类
private void initComponents() {
	this.setLayout(new BorderLayout());
	epochs = new JSpinner(new SpinnerNumberModel(10, 10, 50, 1));
	JPanel epochOption = new JPanel(new BorderLayout());
	JPanel flowTemp = new JPanel(new FlowLayout(FlowLayout.LEFT));
	epochs.setPreferredSize(new Dimension(70, 40));
	epochs.setFont(new Font(epochs.getFont().getName(), epochs.getFont().getStyle(), epochs.getFont().getSize() + 4));
	flowTemp.add(new JLabel("<html><body><h3>Select the maximum number of epochs: </h3></body></html> "));
	flowTemp.add(epochs);
	JButton setEpoch = new JButton(this.setEpoch);
	setEpoch.setPreferredSize(new Dimension(85, 35));
	flowTemp.add(setEpoch);
	epochOption.add(flowTemp, BorderLayout.CENTER);
	//JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	//btnPanel.add(setEpoch);
	//epochOption.add(btnPanel,BorderLayout.SOUTH);
	this.add(epochOption, BorderLayout.NORTH);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:EpochPanel.java

示例6: ProgressPanel

import javax.swing.JLabel; //导入依赖的package包/类
public ProgressPanel() {
    setLayout(null);

    progressBar = new ProgressBar();
    progressBar.setLocation(PROGRESS_X_OFFSET, PROGRESS_Y_OFFSET);
    progressBar.setSize(440, 10);
    progressBar.setForeground(Color.blue);
    add(progressBar);

    textLabel = new JLabel();
    textLabel.setLocation(X_TEXT_OFFSET, Y_TEXT_OFFSET);
    textLabel.setSize(X_SIZE - X_TEXT_OFFSET - ADDITIONAL_X_SIZE, 20);
    add(textLabel);

    additionalLabel = new JLabel();
    additionalLabel.setLocation(X_SIZE - ADDITIONAL_X_SIZE, Y_TEXT_OFFSET);
    additionalLabel.setSize(ADDITIONAL_X_SIZE, 20);
    add(additionalLabel);
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:20,代码来源:ProgressWindow.java

示例7: createBottom

import javax.swing.JLabel; //导入依赖的package包/类
protected void createBottom()
{
	userHelp = new JLabel(CurrentLocale.get(
		"com.dytech.edge.admin.wizard.editor.rawhtmleditor.select", "\"{/xpath/to/my/data}\"")); //$NON-NLS-1$ //$NON-NLS-2$
	userRadio = new JRadioButton(CurrentLocale.get("com.dytech.edge.admin.wizard.editor.rawhtmleditor.userdefined")); //$NON-NLS-1$
	userText = new I18nTextArea(BundleCache.getLanguages());

	Dimension d = new Dimension(0, 300);
	userText.setMinimumSize(d);
	userText.setPreferredSize(d);

	userText.setEnabled(false);
	userText.setEnabled(false);
	userHelp.setEnabled(false);
	userRadio.addActionListener(new RawHtmlEditor.RadioHandler(true));

	userPanel = new JPanel(new BorderLayout(5, 5));

	userPanel.add(userRadio, BorderLayout.NORTH);
	userPanel.add(userText, BorderLayout.CENTER);
	userPanel.add(userHelp, BorderLayout.SOUTH);
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:RawHtmlEditor.java

示例8: contrutorPanelNff

import javax.swing.JLabel; //导入依赖的package包/类
private void contrutorPanelNff(){
	
	JPanel cadastroPanelNff1 = new JPanel();
	cadastroPanelNff1.setLayout(new BoxLayout(cadastroPanelNff1, BoxLayout.X_AXIS));
	cadastroPanelNff1.add(new JLabel("   Quantidade de itens: "));
	cadastroPanelNff1.add(quantidadeItens);
	cadastroPanelNff1.add(new JLabel("   Valor Total: "));
	cadastroPanelNff1.add(valorTotal);
	
	
	JPanel cadastroPanelNff2 = new JPanel();
	cadastroPanelNff2.setLayout(new BorderLayout());
	cadastroPanelNff2.add(new JLabel("   Informações: "));
	
	
	cadastroPanelNff.setLayout(new BoxLayout(cadastroPanelNff, BoxLayout.Y_AXIS));
	cadastroPanelNff.add(new JLabel(" "));
	cadastroPanelNff.add(cadastroPanelNff1);
	cadastroPanelNff.add(cadastroPanelNff2);
	cadastroPanelNff.add(informacoes);
	
}
 
开发者ID:matheusPeresDeAraujo,项目名称:20170612-NotaFIscalEletronica,代码行数:23,代码来源:FrameCadastroNf.java

示例9: getControls

import javax.swing.JLabel; //导入依赖的package包/类
public Component getControls() {

      final JSlider slider = new JSlider(JSlider.HORIZONTAL,0,100,opacity);

      final HashMap<Integer,JLabel> labelTable = new HashMap<Integer,JLabel>();
      labelTable.put(0, new JLabel("Transparent"));
      labelTable.put(100, new JLabel("Opaque"));

      slider.setMajorTickSpacing(10);
      slider.setPaintTicks(true);
      // Note: JSlider uses the outdated Hashtable. Eventually Hashtable
      // will be deprecated and we'll be able to use the HashMap directly.
      slider.setLabelTable(new Hashtable<Integer,JLabel>(labelTable));
      slider.setPaintLabels(true);
      slider.setBorder(javax.swing.BorderFactory.createTitledBorder(name));
      slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
          final JSlider source = (JSlider) e.getSource();
          if (!source.getValueIsAdjusting()) {
            opacity = source.getValue();
          }
        }});

      return slider;
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:ZoneHighlight.java

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

示例11: ExpandablePanel

import javax.swing.JLabel; //导入依赖的package包/类
public ExpandablePanel(JLabel l, JPanel p, final Icon ei, final Icon ci) {
    this.panel = p;
    this.label = l;
    this.ci = ci;
    this.ei = ei;
    this.label.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if(panel.isVisible()) {
                colapse();
            } else {
                expand();
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:QueryPanel.java

示例12: showSplash

import javax.swing.JLabel; //导入依赖的package包/类
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel jl = new JLabel();
	jl.setSize(400, 300);
	jl.setIcon(spl);
	splash.getContentPane().add(jl);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:20,代码来源:App.java

示例13: prepareRenderer

import javax.swing.JLabel; //导入依赖的package包/类
/**
 * Prepares the renderer by querying the data model for the
 * value and selection state
 * of the cell at <code>row</code>, <code>column</code>.
 * Returns the component (may be a <code>Component</code>
 * or a <code>JComponent</code>) under the event location.
 * <p/>
 *
 * This paints in red elements of selected classes
 *
 * @param renderer the <code>TableCellRenderer</code> to prepare
 * @param row      the row of the cell to render, where 0 is the first row
 * @param column   the column of the cell to render,
 *                 where 0 is the first column
 * @return the <code>Component</code> under the event location
 */
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
	Component comp = super.prepareRenderer(renderer, row, column);
	if (comp instanceof JLabel) {
		((JLabel) comp).setHorizontalAlignment(SwingConstants.CENTER);
	}
	String name = (String) className.getSelectedItem();
	// Sets color of selected elements
	if ((name.equals(ALL_CLASSES) || getColumnName(column).equals(name)) && column != 0) {
		comp.setForeground(Color.RED);
	} else {
		comp.setForeground(getForeground());
	}
	// Changes background and font of headers
	if (column == 0 || row == 0) {
		comp.setBackground(this.getTableHeader().getBackground());
		comp.setFont(comp.getFont().deriveFont(Font.BOLD));
	} else {
		comp.setBackground(Color.WHITE);
		comp.setFont(comp.getFont().deriveFont(Font.PLAIN));
	}
	return comp;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:40,代码来源:WhatIfPanel.java

示例14: SammonMappingDemo

import javax.swing.JLabel; //导入依赖的package包/类
/**
 * Constructor.
 */
public SammonMappingDemo() {
    startButton = new JButton("Start");
    startButton.setActionCommand("startButton");
    startButton.addActionListener(this);

    datasetBox = new JComboBox<>();
    for (int i = 0; i < datasetName.length; i++) {
        datasetBox.addItem(datasetName[i]);
    }
    datasetBox.setSelectedIndex(0);
    datasetBox.setActionCommand("datasetBox");
    datasetBox.addActionListener(this);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(startButton);
    optionPane.add(new JLabel("Dataset:"));
    optionPane.add(datasetBox);

    setLayout(new BorderLayout());
    add(optionPane, BorderLayout.NORTH);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:26,代码来源:SammonMappingDemo.java

示例15: ApproximateStringSearchDemo

import javax.swing.JLabel; //导入依赖的package包/类
public ApproximateStringSearchDemo() {
    super(new BorderLayout());

    startButton = new JButton("Start");
    startButton.setActionCommand("startButton");
    startButton.addActionListener(this);

    knnField = new JTextField(Integer.toString(knn), 5);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(startButton);
    optionPane.add(new JLabel("K:"));
    optionPane.add(knnField);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(1, 2));
    canvas.setBackground(Color.WHITE);
    add(canvas, BorderLayout.CENTER);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:22,代码来源:ApproximateStringSearchDemo.java


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