是的,我认为通过.getComponents()
在 Component 上使用这将相对简单,这将返回JPanel
of the并且他们通过再次使用该方法JOptionPane
检索s但是我遇到了困难。 JButton
JPanel
我想在JOptionPane
按钮上使用鼠标侦听器,以便可以在鼠标悬停时更改按钮的颜色。有没有更简单的方法来实现这一点?
到目前为止这是我的课..
package rsapp.gui;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
public class RSJPaneComponent extends JOptionPane {
/**
*
*/
private static final long serialVersionUID = 13453253L;
private JOptionPane j=this;
final Color WHITE = Color.WHITE;
public RSJPaneComponent(){
UIManager.put("OptionPane.background",WHITE);
UIManager.put("Panel.background",WHITE);
UIManager.put("Button.background",WHITE);
UIManager.put("Button.foreground",new Color(85,153,187));
UIManager.put("activeCaption", WHITE);
}
protected String initJPaneInput(final JFrame f, final String message){
return j.showInputDialog(f,message);
}
public int generateDialog(int error_code, String title_message, String message, final JFrame f){
return JOptionPane.showConfirmDialog(
f,
message,
"Error "+error_code+": "+title_message,
JOptionPane.YES_NO_OPTION);
}
}