0

java - 如何在鼠标光标指向Java文本区域后显示图像?

鼠标光标指向textarea MSR,MSSR ...我需要显示图像,鼠标光标释放后图像消失

public class Report extends JFrame{
    JPanel table = new JPanel();
    JPanel process = new JPanel();
    JPanel all = new JPanel();
    JPanel north = new JPanel();
    JPanel south = new JPanel();
    JTextField MSR = new JTextField("AAA");
    JTextField MSSR = new JTextField("BBB");
    JTextField AAR = new JTextField("CCC");
    JTextField T10PAR = new JTextField("DDD");
    JLabel title = new JLabel("<HTML><u>Types Of Books</u></HTML>");

    Font myFont = new Font("Serif", Font.BOLD, 14);
    Font myFont1 = new Font("Times New Roman", Font.BOLD , 16);


    public Report(){
        north.setLayout(new FlowLayout(FlowLayout.LEFT));
        north.add(title);
        title.setFont(myFont1);
        add(north);
        table.setLayout( new GridLayout( 4, 1,1,7));

        table.add(MSR);
        MSR.setHorizontalAlignment(JTextField.CENTER);
        MSR.setBackground(Color.WHITE);    
        MSR.setPreferredSize(new Dimension(218,20));   
        MSR.setFont(myFont);    
        MSR.setForeground(Color.BLACK);
        MSR.setEditable(false);
        table.add(MSSR);
        MSSR.setHorizontalAlignment(JTextField.CENTER);
        MSSR.setBackground(Color.WHITE);    
        MSSR.setFont(myFont);    
        MSSR.setForeground(Color.BLACK);
        MSSR.setEditable(false);
        table.add(AAR);
        AAR.setHorizontalAlignment(JTextField.CENTER);
        AAR.setBackground(Color.WHITE);    
        AAR.setFont(myFont);    
        AAR.setForeground(Color.BLACK);
        AAR.setEditable(false);
        table.add(T10PAR);
        T10PAR.setHorizontalAlignment(JTextField.CENTER);
        T10PAR.setBackground(Color.WHITE);    
        T10PAR.setFont(myFont);    
        T10PAR.setForeground(Color.BLACK);
        T10PAR.setEditable(false);

        add(north,BorderLayout.NORTH);
        add(south,BorderLayout.SOUTH);    
        add(table,BorderLayout.WEST);
        add(process,BorderLayout.EAST);
    }
}

需要帮助。谢谢。

4

1 回答 1

0

您可以将 MouseAdapter 作为 MouseListener 添加到 JFrame,然后覆盖所需的方法。

http://docs.oracle.com/javase/6/docs/api/java/awt/event/MouseAdapter.html

于 2013-09-23T21:28:33.673 回答