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


Java JLabel.addMouseListener方法代码示例

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


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

示例1: init

import javax.swing.JLabel; //导入方法依赖的package包/类
private void init() {
    this.setLayout(new FlowLayout(
            FlowLayout.LEADING, 0, 0));
    setLinkLikeButton(button);
    leftParenthesis = new JLabel("(");                              //NOI18N
    rightParenthesis = new JLabel(")");                             //NOI18N
    add(leftParenthesis);
    add(button);
    add(rightParenthesis);
    MouseListener ml = createLabelMouseListener();
    leftParenthesis.addMouseListener(ml);
    rightParenthesis.addMouseListener(ml);
    button.setEnabled(false);
    this.setMaximumSize(
            this.getPreferredSize());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:LinkButtonPanel.java

示例2: initReferenceLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private void initReferenceLabel() {
    imageChooser.setFileFilter(new FileNameExtensionFilter("Image", "jpg", "png", "gif", "bmp"));
    referenceLabel = new JLabel() {
        @Override
        public void paint(Graphics grphcs) {
            super.paint(grphcs);
            paintPage(grphcs);
        }

    };
    referenceLabel.setHorizontalAlignment(SwingConstants.CENTER);
    referenceLabel.setComponentPopupMenu(referencePopup);
    jScrollPane2.setViewportView(referenceLabel);
    offsetAdapter = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            setOffsetMarker(e);
        }
    };
    referenceLabel.addMouseListener(offsetAdapter);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:PropertyEditor.java

示例3: initComponents

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Metodo para inicializar componentes.
 */
 public void initComponents(){
    
    volverMenu = new JLabel();
    volverMenu.setBounds(680, 410, 100, 100);
    volverMenu.setIcon(AsignLabelDimension(new ImageIcon(pathBaseLabel+"Flecha-1.png"), volverMenu));
    volverMenu.addMouseListener(new MouseEvents());
    Position = new JLabel[10];
    Score = new JLabel[10];
    Name = new JLabel[10]; 
    Nombres = new String[10];
    Puntos = new int[10];
    StarJedi = cargarFuente("../Starjedi.ttf");
   
    
}
 
开发者ID:Uminks,项目名称:Star-Ride--RiverRaid,代码行数:19,代码来源:Top10.java

示例4: Logo

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Creates a new instance of RecentProjects */
public Logo( String img, String url ) {
    super( new BorderLayout() );
    Icon image = new ImageIcon( ImageUtilities.loadImage(img, true) );
    JLabel label = new JLabel( image );
    label.setBorder( BorderFactory.createEmptyBorder() );
    label.setOpaque( false );
    label.addMouseListener( this );
    setOpaque( false );
    add( label, BorderLayout.CENTER );
    setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
    this.url = url;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:Logo.java

示例5: createRestartNotificationDetails

import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent createRestartNotificationDetails() {
    JPanel res = new JPanel( new BorderLayout( 10, 10) );
    res.setOpaque( false );
    JLabel lbl = new JLabel( NbBundle.getMessage( LafPanel.class, "Descr_Restart") ); //NOI18N
    lbl.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
    res.add( lbl, BorderLayout.CENTER );
    final JCheckBox checkEditorColors = new JCheckBox( NbBundle.getMessage( LafPanel.class, "Hint_ChangeEditorColors" ) ); //NOI18N
    if( isChangeEditorColorsPossible() ) {
        checkEditorColors.setSelected( true );
        checkEditorColors.setOpaque( false );
        res.add( checkEditorColors, BorderLayout.SOUTH );
    }
    lbl.addMouseListener( new MouseAdapter() {
        @Override
        public void mouseClicked( MouseEvent e ) {
            if( null != restartNotification ) {
                restartNotification.clear();
                restartNotification = null;
            }
            if( checkEditorColors.isSelected() ) {
                switchEditorColorsProfile();
            }
            LifecycleManager.getDefault().markForRestart();
            LifecycleManager.getDefault().exit();
        }
    });
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:LafPanel.java

示例6: addMouseHandler

import javax.swing.JLabel; //导入方法依赖的package包/类
private void addMouseHandler(final JLabel website) {
	website.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			try {
				Desktop.getDesktop().browse(
						new URI(parseHREF(website.getText())));
			} catch (Exception ex) {
			}
		}
	});
}
 
开发者ID:mvetsch,项目名称:JWT4B,代码行数:13,代码来源:JLabelLink.java

示例7: IOObjectCacheEntryPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Creates a new {@link IOObjectCacheEntryPanel}.
 *
 * @param icon
 *            The {@link Icon} associated with the entry's type.
 * @param entryType
 *            Human readable representation of the entry's type (e.g., 'Data Table').
 * @param openAction
 *            The action to be performed when clicking in the entry.
 * @param removeAction
 *            An action triggering the removal of the entry.
 */
public IOObjectCacheEntryPanel(Icon icon, String entryType, Action openAction, Action removeAction) {
	super(ENTRY_LAYOUT);

	this.openAction = openAction;

	// add icon label
	JLabel iconLabel = new JLabel(icon);
	add(iconLabel, ICON_CONSTRAINTS);

	// add object type label
	JLabel typeLabel = new JLabel(entryType);
	typeLabel.setMaximumSize(new Dimension(MAX_TYPE_WIDTH, 24));
	typeLabel.setPreferredSize(typeLabel.getMaximumSize());
	typeLabel.setToolTipText(entryType);
	add(typeLabel, TYPE_CONSTRAINTS);

	// add link button performing the specified action, the label displays the entry's key name
	LinkLocalButton openButton = new LinkLocalButton(openAction);
	openButton.setMargin(new Insets(0, 0, 0, 0));
	add(openButton, KEY_CONSTRAINTS);

	// add removal button
	JButton removeButton = new JButton(removeAction);
	removeButton.setBorderPainted(false);
	removeButton.setOpaque(false);
	removeButton.setMinimumSize(buttonSize);
	removeButton.setPreferredSize(buttonSize);
	removeButton.setContentAreaFilled(false);
	removeButton.setText(null);
	add(removeButton, REMOVE_BUTTON_CONSTRAINTS);

	// register mouse listeners
	addMouseListener(hoverMouseListener);
	iconLabel.addMouseListener(dispatchMouseListener);
	typeLabel.addMouseListener(dispatchMouseListener);
	openButton.addMouseListener(dispatchMouseListener);
	removeButton.addMouseListener(dispatchMouseListener);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:51,代码来源:IOObjectCacheEntryPanel.java

示例8: newtab

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Create a new tab with the given filename (if filename==null, we'll create a blank tab instead)
 * <p> If a text buffer with that filename already exists, we will just switch to it; else we'll read that file into a new tab.
 * @return false iff an error occurred
 */
public boolean newtab(String filename) {
   if (filename!=null) {
      filename = Util.canon(filename);
      for(int i=0; i<tabs.size(); i++) if (tabs.get(i).getFilename().equals(filename)) { if (i!=me) select(i); return true; }
   }
   final JLabel lb = OurUtil.label("", OurUtil.getVizFont().deriveFont(Font.BOLD), Color.BLACK, Color.WHITE);
   lb.setBorder(new OurBorder(BORDER, BORDER, Color.WHITE, BORDER));
   lb.addMouseListener(new MouseAdapter() {
      @Override public void mousePressed(MouseEvent e) { for(int i=0; i<tabs.size(); i++) if (tabs.get(i).obj1 == lb) select(i); }
   });
   JPanel h1 = OurUtil.makeH(4); h1.setBorder(new OurBorder(null, null, BORDER, null));
   JPanel h2 = OurUtil.makeH(3); h2.setBorder(new OurBorder(null, null, BORDER, null));
   JPanel pan = Util.onMac() ? OurUtil.makeVL(null, 2, OurUtil.makeHB(h1, lb, h2))
                             : OurUtil.makeVL(null, 2, OurUtil.makeHB(h1, lb, h2, GRAY), GRAY);
   pan.setAlignmentX(0.0f);
   pan.setAlignmentY(1.0f);
   OurSyntaxWidget text = new OurSyntaxWidget(syntaxHighlighting, "", fontName, fontSize, tabSize, lb, pan);
   tabBar.add(pan, tabs.size());
   tabs.add(text);
   text.listeners.add(listener); // add listener AFTER we've updated this.tabs and this.tabBar
   if (filename==null) {
      text.discard(false, getFilenames()); // forces the tab to re-derive a suitable fresh name
   } else {
      if (!text.load(filename)) return false;
      for(int i=tabs.size()-1; i>=0; i--) if (!tabs.get(i).isFile() && tabs.get(i).getText().length()==0) {
         tabs.get(i).discard(false, getFilenames()); close(i); break; // Remove the rightmost untitled empty tab
      }
   }
   select(tabs.size() - 1); // Must call this to switch to the new tab; and it will fire STATUS_CHANGE message which is important
   return true;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:36,代码来源:OurTabbedSyntaxWidget.java

示例9: initTitlePanel

import javax.swing.JLabel; //导入方法依赖的package包/类
private void initTitlePanel(){
    preYear = new JLabel("<<", JLabel.CENTER);
    preMonth = new JLabel("<", JLabel.CENTER);
    center = new JLabel("", JLabel.CENTER);
    centercontainer = new JLabel("", JLabel.CENTER);
    nextMonth = new JLabel(">", JLabel.CENTER);
    nextYear = new JLabel(">>", JLabel.CENTER);
    
    preYear.setToolTipText("Last Year");
    preMonth.setToolTipText("Last Month");
    nextMonth.setToolTipText("Next Month");
    nextYear.setToolTipText("Next Year");
    
    preYear.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 10, 0, 0));
    preMonth.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 15, 0, 0));
    nextMonth.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 0, 0, 15));
    nextYear.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 0, 0, 10));
    
    centercontainer.setLayout(new java.awt.BorderLayout());
    centercontainer.add(preMonth,java.awt.BorderLayout.WEST);
    centercontainer.add(center,java.awt.BorderLayout.CENTER);
    centercontainer.add(nextMonth,java.awt.BorderLayout.EAST);
    
    this.add(preYear,java.awt.BorderLayout.WEST);
    this.add(centercontainer,java.awt.BorderLayout.CENTER);
    this.add(nextYear,java.awt.BorderLayout.EAST);
    this.setPreferredSize(new java.awt.Dimension(210, 25));
    
    updateDate();
    
    preYear.addMouseListener(new MyMouseAdapter(preYear, Calendar.YEAR, -1));
    preMonth.addMouseListener(new MyMouseAdapter(preMonth, Calendar.MONTH, -1));
    nextMonth.addMouseListener(new MyMouseAdapter(nextMonth, Calendar.MONTH, 1));
    nextYear.addMouseListener(new MyMouseAdapter(nextYear, Calendar.YEAR, 1));
}
 
开发者ID:sivanWu0222,项目名称:SimpleERP,代码行数:36,代码来源:Chooser.java

示例10: telinha

import javax.swing.JLabel; //导入方法依赖的package包/类
public void telinha() {	
	janela = new JFrame();
	//janela.addMouseListener(this);
	//janela.setSize(img.getWidth(null), img.getHeight(null));
	JLabel background = new JLabel();
	ImageIcon icone = new ImageIcon(img);
	background.addMouseListener(this);
	background.setSize(img.getWidth(null), img.getHeight(null));
	background.setIcon(icone);
	janela.add(background);
	janela.setVisible(true);
	janela.setFocusable(true);
	janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:15,代码来源:Mouse.java

示例11: createServerList

import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent createServerList()
{
	JLabel profileLabel = new JLabel("Choose a Server:");

	configureLink = new JLabel("Configure...");
	configureLink.setForeground(Color.BLUE);
	configureLink.addMouseListener(this);

	profileChoice = new JComboBox();
	profileChoice.addActionListener(this);
	profileChoice.setRenderer(new DefaultListCellRenderer()
	{
		@Override
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
			boolean cellHasFocus)
		{
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
			ServerProfile p = (ServerProfile) value;
			if( p != null )
			{
				setText(p.getName() + " - " + p.getServer());
			}
			return this;
		}
	});

	final int height1 = profileChoice.getPreferredSize().height;
	final int width1 = configureLink.getPreferredSize().width;

	final int[] rows = {height1, height1,};
	final int[] cols = {TableLayout.FILL, width1,};

	JPanel all = new JPanel(new TableLayout(rows, cols));
	all.add(profileLabel, new Rectangle(0, 0, 1, 1));
	all.add(configureLink, new Rectangle(1, 0, 1, 1));
	all.add(profileChoice, new Rectangle(0, 1, 2, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:ClientLauncher.java

示例12: preencher

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Preenche o painel com os cards para seleção
 */
private void preencher() {
    for (int index = 0; index < ids.length; index++) {
        final int i = index;
        JLabel label = new JLabel(Images.getCardIcon(Images.CARD_ORIGINAL, ids[index]));
        label.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent evt) {
                selecionado(ids[i]);
            }
        });
        jPanelCards.add(label);
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:EscolherCard.java

示例13: preencher

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * preenche o painel com a lista de cards disponíveis para muligar
 */
private void preencher() {
    for (int index = 0; index < labelX.length; index++) {
        JPanel panel = new JPanel(new AbsoluteLayout());
        panel.setBackground(new Color(0, 0, 0, 0));
        JLabel label_card = new JLabel(Images.getCardIcon(Images.CARD_ORIGINAL, deck.get(index).getId()));
        labelX[index] = new JLabel();
        label_card.addMouseListener(eventoClicarNoCard(index));
        labelX[index].addMouseListener(eventoClicarNaImagemX(index));
        panel.add(labelX[index], new AbsoluteConstraints(20, 125));
        panel.add(label_card, new AbsoluteConstraints(0, 0));
        jPanelCards.add(panel);
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:Muligar.java

示例14: CornerMapControls

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * The basic constructor.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public CornerMapControls(final FreeColClient freeColClient) {
    super(freeColClient, true);

    compassRose = new JLabel(new ImageIcon(ResourceManager.getImage("image.skin.compass")));
    compassRose.setFocusable(false);
    compassRose.setSize(compassRose.getPreferredSize());
    compassRose.addMouseListener(new MouseAdapter() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void mouseClicked(MouseEvent e) {
                Unit unit = getGUI().getActiveUnit();
                if (unit == null) return;
                int x = e.getX() - compassRose.getWidth()/2;
                int y = e.getY() - compassRose.getHeight()/2;
                double theta = Math.atan2(y, x) + Math.PI/2 + Math.PI/8;
                if (theta < 0) {
                    theta += 2*Math.PI;
                }
                igc().moveUnit(unit, Direction.angleToDirection(theta));
            }
        });

    miniMapPanel = new MiniMapPanel();
    miniMapPanel.setFocusable(false);
    
    /**
     * In order to make the setLocation setup work, we need to set
     * the layout to null first, then set the size of the minimap,
     * and then its location.
     */
    miniMapPanel.setLayout(null);
    miniMap.setSize(MAP_WIDTH, MAP_HEIGHT);
    // Add buttons:
    miniMapPanel.add(miniMapToggleBorders);
    miniMapPanel.add(miniMapToggleFogOfWarButton);
    miniMapPanel.add(miniMapZoomInButton);
    miniMapPanel.add(miniMapZoomOutButton);
    miniMapPanel.add(miniMap);

    String miniMapSkinKey = "image.skin.MiniMap";
    if (ResourceManager.hasImageResource(miniMapSkinKey)) {
        miniMapSkin = ResourceManager.getImage(miniMapSkinKey);
        miniMapPanel.setBorder(null);
        miniMapPanel.setSize(miniMapSkin.getWidth(null),
                             miniMapSkin.getHeight(null));
        miniMapPanel.setOpaque(false);
        // FIXME: LATER: The values below should be specified by a
        // skin-configuration-file.
        miniMap.setLocation(38, 75);
        miniMapToggleBorders.setLocation(4,114);
        miniMapToggleFogOfWarButton.setLocation(4, 144);
        miniMapZoomInButton.setLocation(4, 174);
        miniMapZoomOutButton.setLocation(264, 174);
    } else {
        miniMapSkin = null;
        int width = miniMapZoomOutButton.getWidth()
            + miniMapZoomInButton.getWidth() + 4 * GAP;
        miniMapPanel.setOpaque(true);
        miniMap.setBorder(new BevelBorder(BevelBorder.RAISED));
        miniMap.setLocation(width/2, GAP);
        miniMapZoomInButton.setLocation(GAP, 
            MAP_HEIGHT + GAP - miniMapZoomInButton.getHeight());
        miniMapZoomOutButton.setLocation(
            miniMapZoomInButton.getWidth() + MAP_WIDTH + 3 * GAP,
            MAP_HEIGHT + GAP - miniMapZoomOutButton.getHeight());
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:76,代码来源:CornerMapControls.java

示例15: createLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private void createLabel() {
    discardLabel();
    label = new JLabel();
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    label.addMouseListener(mouseListener);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:StatusLineComponent.java


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