本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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();
}
}
});
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}