javax.swing.JLabel.addMouseListener()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(256)

本文整理了Java中javax.swing.JLabel.addMouseListener()方法的一些代码示例,展示了JLabel.addMouseListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.addMouseListener()方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:addMouseListener

JLabel.addMouseListener介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

for (int i = 1; i < label.length; i++) {
  final JLabel currentLabel =new JLabel("label " + i); 
  currentLabel.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me) {
      currentLabel.setVisible(false);   // No more compilation error here
    }
  });
  label[i] = currentLabel;
}

代码示例来源:origin: libgdx/libgdx

public void addValue (final Value value) {
  JLabel valueNameLabel = new JLabel(value.getName() + ":");
  valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
    GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  final JLabel valueValueLabel = new JLabel();
  valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
    GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
  valueValueLabel.setOpaque(true);
  if (value.getObject() instanceof java.awt.Color)
    valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
  else
    valueValueLabel.setText(value.toString());
  valueValueLabel.addMouseListener(new MouseAdapter() {
    public void mouseEntered (MouseEvent evt) {
      valueValueLabel.setBackground(selectedColor);
    }
    public void mouseExited (MouseEvent evt) {
      valueValueLabel.setBackground(null);
    }
    public void mouseClicked (MouseEvent evt) {
      Object oldObject = value.getObject();
      value.showDialog();
      if (!value.getObject().equals(oldObject)) {
        effect.setValues(values);
        updateValues();
        updateFont();
      }
    }
  });
}

代码示例来源:origin: libgdx/libgdx

public void addValue (final Value value) {
  JLabel valueNameLabel = new JLabel(value.getName() + ":");
  valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
    GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  final JLabel valueValueLabel = new JLabel();
  valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
    GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
  valueValueLabel.setOpaque(true);
  if (value.getObject() instanceof java.awt.Color)
    valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
  else
    valueValueLabel.setText(value.toString());
  valueValueLabel.addMouseListener(new MouseAdapter() {
    public void mouseEntered (MouseEvent evt) {
      valueValueLabel.setBackground(selectedColor);
    }
    public void mouseExited (MouseEvent evt) {
      valueValueLabel.setBackground(null);
    }
    public void mouseClicked (MouseEvent evt) {
      Object oldObject = value.getObject();
      value.showDialog();
      if (!value.getObject().equals(oldObject)) {
        effect.setValues(values);
        updateValues();
        updateFont();
      }
    }
  });
}

代码示例来源:origin: deathmarine/Luyten

JPanel pane = new JPanel();
pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS));
JLabel title = new JLabel("Luyten " + Luyten.getVersion());
title.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 18));
pane.add(title);
pane.add(new JLabel("by Deathmarine"));
String project = "https://github.com/deathmarine/Luyten/";
JLabel link = new JLabel("<HTML><FONT color=\"#000099\"><U>" + project + "</U></FONT></HTML>");
link.setCursor(new Cursor(Cursor.HAND_CURSOR));
link.addMouseListener(new LinkListener(project, link));
pane.add(link);
pane.add(new JLabel("Contributions By:"));
link = new JLabel("<HTML><FONT color=\"#000099\"><U>" + procyon + "</U></FONT></HTML>");
link.setCursor(new Cursor(Cursor.HAND_CURSOR));
link.addMouseListener(new LinkListener(procyon, link));
pane.add(link);
pane.add(new JLabel("Version: " + Procyon.version()));
link = new JLabel("<HTML><FONT color=\"#000099\"><U>" + rsyntax + "</U></FONT></HTML>");
link.setCursor(new Cursor(Cursor.HAND_CURSOR));
link.addMouseListener(new LinkListener(rsyntax, link));
pane.add(link);
pane.add(new JLabel("Version: 2.6.1"));

代码示例来源:origin: gocd/gocd

aboutLabel[0] = new JLabel("");
aboutLabel[1] = new JLabel("Go Server");
aboutLabel[1].setFont(titleFont);
aboutLabel[2] = new JLabel(
    "Server Version " + getClass().getPackage().getImplementationVersion());
aboutLabel[2].setFont(bodyFont);
aboutLabel[3].setFont(bodyFont);
aboutLabel[3].setSize(aboutLabel[3].getPreferredSize());
aboutLabel[3].addMouseListener(new LinkMouseListener());
aboutLabel[4] = new JLabel("");
aboutLabel[5] = new JLabel("Java Version " + System.getProperty("java.version"));

代码示例来源:origin: deathmarine/Luyten

if (message.contains("\n")) {
  for (String s : message.split("\n")) {
    pane.add(new JLabel(s));
  pane.add(new JLabel(message));
pane.add(new JLabel(" \n")); // Whitespace
final JTextArea exception = new JTextArea(25, 100);
exception.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
final JLabel link = new JLabel("<HTML>Submit to <FONT color=\"#000099\"><U>" + issue + "</U></FONT></HTML>");
link.setCursor(new Cursor(Cursor.HAND_CURSOR));
link.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseClicked(MouseEvent e) {

代码示例来源:origin: redwarp/9-Patch-Resizer

new FileDrop<Container>(outputPanel, null, dropListener);
this.instructionLabel = new JLabel("");
this.instructionLabel.setIcon(this.blueArrowSmall);
this.instructionLabel.setBorder(new EmptyBorder(4, 4, 4, 4));
this.instructionLabel.addMouseListener(new MouseAdapter() {
 @Override
 public void mouseClicked(MouseEvent e) {

代码示例来源:origin: wiztools/rest-client

jp_form_label.add(new JLabel("<html>Host: </html>"));
jp_form_label.add(new JLabel("<html>Realm: </html>"));
jp_form_label.add(new JLabel("<html>Username: <font color=red>*</font></html>"));
jp_form_label.add(new JLabel("<html>Password: </html>"));
JLabel jl_premptive = new JLabel("Preemptive?");
jcb_preemptive.setToolTipText(toolTipText);
jl_premptive.setLabelFor(jcb_preemptive);
jl_premptive.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseClicked(MouseEvent me) {

代码示例来源:origin: kevin-wayne/algs4

JLabel draw = new JLabel(icon);
draw.addMouseListener(std);
draw.addMouseMotionListener(std);

代码示例来源:origin: runelite/runelite

confirmLabel.addMouseListener(new MouseAdapter()
JLabel cancelLabel = new JLabel(CANCEL_ICON);
cancelLabel.setToolTipText("Cancel");
cancelLabel.addMouseListener(new MouseAdapter()

代码示例来源:origin: kevin-wayne/algs4

draw = new JLabel(icon);
draw.addMouseListener(this);
draw.addMouseMotionListener(this);

代码示例来源:origin: stackoverflow.com

contentPane.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel label = new JLabel(LABEL_TEXT);
contentPane.add(label);
label = new JLabel(A_VALID_LINK);
contentPane.add(label);
if (isBrowsingSupported()) {
c.setText(htmlIfy(linkIfy(c.getText())));
c.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
c.addMouseListener(ml);

代码示例来源:origin: marytts/marytts

jTextPane_PromptDisplay = new javax.swing.JTextPane();
jTextPane_nextSentence = new javax.swing.JTextPane();
jLabel_SessionStatus = new javax.swing.JLabel();
jPanel_AdminControls = new javax.swing.JPanel();
jScrollPane_PromptSet = new javax.swing.JScrollPane();
jButton_Play = new javax.swing.JButton();
jSeparator_MessageBar = new javax.swing.JSeparator();
jLabel_MessageBar = new javax.swing.JLabel();
jCheckBox_PlayClosingBeep = new javax.swing.JCheckBox();
jLabel_MessageBarIcon = new javax.swing.JLabel();
jButton_Display = new javax.swing.JButton();
jMenuBar_AdminWindow = new javax.swing.JMenuBar();
jLabel_SessionStatus.addMouseListener(new java.awt.event.MouseAdapter() {
  public void mouseClicked(java.awt.event.MouseEvent evt) {
    jLabel_SessionStatusMouseClicked(evt);

代码示例来源:origin: stackoverflow.com

final JLabel label = new JLabel("some label with a nice text");
 label.setBackground(Color.YELLOW);
 MouseAdapter adapter = new MouseAdapter() {
   /** 
    * @inherited <p>
    */
   @Override
   public void mouseEntered(MouseEvent e) {
     label.setOpaque(true);
     label.repaint();
   }
   /** 
    * @inherited <p>
    */
   @Override
   public void mouseExited(MouseEvent e) {
     label.setOpaque(false);
     label.repaint();
   }
 };
 label.addMouseListener(adapter);

代码示例来源:origin: magefree/mage

final JLabel jLabel = new JLabel();
jLabel.setIcon(new ImageIcon(resized));
if (selected) {
jPanel.add(jLabel);
if (!locked) {
  jLabel.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {

代码示例来源:origin: apache/pdfbox

private void initUI()
{
  panel = new JPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
  String pageLabelText = pageIndex < 0 ? "Page number not found" : "Page " + (pageIndex + 1);
  // append PDF page label, if available
  String lbl = PDFDebugger.getPageLabel(document, pageIndex);
  if (lbl != null)
  {
    pageLabelText += " - " + lbl;
  }
  JLabel pageLabel = new JLabel(pageLabelText);
  pageLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
  pageLabel.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 20));
  pageLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));
  panel.add(pageLabel);
  
  label = new JLabel();
  label.addMouseMotionListener(this);
  label.addMouseListener(this);
  label.setAlignmentX(Component.CENTER_ALIGNMENT);
  panel.add(label);
  panel.addAncestorListener(this);
  zoomMenu = ZoomMenu.getInstance();
  zoomMenu.changeZoomSelection(zoomMenu.getPageZoomScale());
  startRendering();
}

代码示例来源:origin: apache/pdfbox

public ReaderBottomPanel()
{
  BorderLayout layout = new BorderLayout();
  this.setLayout(layout);
  
  statusLabel = new JLabel();
  statusLabel.setText("Ready");
  this.add(statusLabel, BorderLayout.WEST);
  logLabel = new JLabel();
  logLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
  logLabel.addMouseListener(new MouseAdapter()
  {
    @Override
    public void mouseClicked(MouseEvent e)
    {
      Window viewer = LogDialog.instance().getOwner();
      
      // show the log window
      LogDialog.instance().setSize(800, 400);
      LogDialog.instance().setVisible(true);
      LogDialog.instance().setLocation(viewer.getLocationOnScreen().x + viewer.getWidth() / 2,
                       viewer.getLocationOnScreen().y + viewer.getHeight() / 2);
    }
  });
  this.add(logLabel, BorderLayout.EAST);
  this.setBorder(new EmptyBorder(0, 5, 0, 5));
  this.setPreferredSize(new Dimension(1000, 24));
}

代码示例来源:origin: org.netbeans.api/org-openide-awt

final JLabel lbl;
if (popupMenu != null) {
  lbl = new JLabel(org.openide.util.ImageUtilities.loadImageIcon(ICON_FIND_WITH_MENU, false));
  lbl.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
  lbl = new JLabel(org.openide.util.ImageUtilities.loadImageIcon(ICON_FIND, false));

代码示例来源:origin: stackoverflow.com

protected JLabel makeLabel(String text) {
  JLabel label = new JLabel(text);
  label.addMouseListener(someInstanceOfAMouseListener);
  return label;
}

代码示例来源:origin: stackoverflow.com

for (String header : headers) {
   JLabel lbl = new JLabel(header);
   lbl.addMouseListener(add ur listner);
   add(lbl);
}

相关文章

JLabel类方法