当前位置: 技术问答>java相关
**在线等待**怎样实现鼠标带提示信息
来源: 互联网 发布时间:2015-09-02
本文导语: 当鼠标进入某一个区域,要求鼠标变成手形,且随鼠标显示提示信息,请问,如何处理; | Label lab = new Label(); ... 通过鼠标事件 lab.setText("提示内容"); lab.setLocation(x,y); | 对不起,要加上cursor package ...
当鼠标进入某一个区域,要求鼠标变成手形,且随鼠标显示提示信息,请问,如何处理;
|
Label lab = new Label();
...
通过鼠标事件
lab.setText("提示内容");
lab.setLocation(x,y);
...
通过鼠标事件
lab.setText("提示内容");
lab.setLocation(x,y);
|
对不起,要加上cursor
package helloworld;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import javax.swing.border.*;
public class Frame3 extends JFrame
{
private JLayeredPane jPanel1 = new JLayeredPane();
private XYLayout xYLayout1 = new XYLayout();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
private JButton jButton3 = new JButton();
private Border border1;
private JTextField jTextField1 = new JTextField();
private Border border2;
public Frame3()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
Frame3 frame3 = new Frame3();
frame3.setSize(400,300);
frame3.show() ;
}
private void jbInit() throws Exception
{
border1 = BorderFactory.createLineBorder(Color.black,2);
border2 = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(255, 250, 250),1),BorderFactory.createEmptyBorder(1,1,1,1));
jPanel1.setLayout(xYLayout1);
jButton1.setText("jButton1");
jButton2.setText("jButton2");
jButton3.setText("jButton3");
jTextField1.setBackground(Color.yellow);
jTextField1.setBorder(border2);
jTextField1.setCaretColor(Color.pink);
jTextField1.setText("jTextField1");
jPanel1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseExited(MouseEvent e)
{
jPanel1_mouseExited(e);
}
});
jPanel1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseEntered(MouseEvent e)
{
jPanel1_mouseEntered(e);
}
public void mouseExited(MouseEvent e)
{
jPanel1_mouseExited(e);
}
});
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, new XYConstraints(57, 69, -1, -1));
jPanel1.add(jButton2, new XYConstraints(229, 84, -1, -1));
jPanel1.add(jButton3, new XYConstraints(116, 153, -1, -1));
jPanel1.add(jTextField1, new XYConstraints(183, 220, 106, -1));
}
public boolean isInBounds(int x, int y) {
Component component = null;
for(int i=0;i
package helloworld;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import javax.swing.border.*;
public class Frame3 extends JFrame
{
private JLayeredPane jPanel1 = new JLayeredPane();
private XYLayout xYLayout1 = new XYLayout();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
private JButton jButton3 = new JButton();
private Border border1;
private JTextField jTextField1 = new JTextField();
private Border border2;
public Frame3()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
Frame3 frame3 = new Frame3();
frame3.setSize(400,300);
frame3.show() ;
}
private void jbInit() throws Exception
{
border1 = BorderFactory.createLineBorder(Color.black,2);
border2 = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(255, 250, 250),1),BorderFactory.createEmptyBorder(1,1,1,1));
jPanel1.setLayout(xYLayout1);
jButton1.setText("jButton1");
jButton2.setText("jButton2");
jButton3.setText("jButton3");
jTextField1.setBackground(Color.yellow);
jTextField1.setBorder(border2);
jTextField1.setCaretColor(Color.pink);
jTextField1.setText("jTextField1");
jPanel1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseExited(MouseEvent e)
{
jPanel1_mouseExited(e);
}
});
jPanel1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseEntered(MouseEvent e)
{
jPanel1_mouseEntered(e);
}
public void mouseExited(MouseEvent e)
{
jPanel1_mouseExited(e);
}
});
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, new XYConstraints(57, 69, -1, -1));
jPanel1.add(jButton2, new XYConstraints(229, 84, -1, -1));
jPanel1.add(jButton3, new XYConstraints(116, 153, -1, -1));
jPanel1.add(jTextField1, new XYConstraints(183, 220, 106, -1));
}
public boolean isInBounds(int x, int y) {
Component component = null;
for(int i=0;i