用java怎么编写一个图形界面应用程序,其中包含一个按钮。当鼠标移到按钮上时,隐藏按钮

来源:百度知道 编辑:UC知道 时间:2024/06/17 03:23:10
希望把代码写下,思路我也知道,就是不知道怎么写,可以的话最好用awt包下的....swing包下的弄得不是很清楚

import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.Rectangle;

public class HideButton extends JFrame {

private JPanel jPanel = null;
private JButton jButton = null;

/**
* This method initializes
*
*/
public HideButton() {
super();
initialize();
}

/**
* This method initializes this
*
*/
private void initialize() {
this.setSize(new Dimension(239, 129));
this.setContentPane(getJPanel());
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}

/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel();
jPanel.setLayo