0

マウスがホバーされたときにパネルを展開してボタンなどを表示したいのですが、マウスがパネルを出ると元のサイズに戻る必要があります。これまでのところ、メッセージを印刷することしかできません:

public JPanel GUI()
{
     final JPanel totalGUI = new JPanel();
     totalGUI.setBackground(Color.blue);
     totalGUI.setLayout(null);


    //+++++++++++++++
    //  -   -   -   -   -   -   PANEL 1!
    //+++++++++++++++       

    JPanel SearchPanel = new JPanel();  //Create new grid bag layout
    SearchPanel.setLocation(5, 5);
    SearchPanel.setSize(420, 120);
    totalGUI.add(SearchPanel);

    SearchPanel.addMouseListener(this);


    return totalGUI;
}

public void mouseEntered(MouseEvent e) {
       System.out.print("Mouse entered");
    }
public void mouseExited(MouseEvent e) {
        System.out.print("Mouse exited");
    }

private static void createAndShowGUI()
{
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("RWB");

    gay3 demo = new gay3();
    frame.setContentPane(demo.GUI());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setSize(650, 500);    
    frame.setVisible(true);

}

public static void main(String[] args)
{
    createAndShowGUI();
}
4

1 に答える 1