试试下面的代码,当然你不会得到透明度。但这是您将面板添加到 HUD 窗口的方式。尝试提取 MacWiget.jar 文件以查看其他类。组件具有不同的名称,在这种情况下,面板称为 ActivePanel。
import javax.swing.JButton;
import com.explodingpixels.macwidgets.ActivePanel;
import com.explodingpixels.macwidgets.HudWidgetFactory;
import com.explodingpixels.macwidgets.HudWindow;
public class MacWidgetTest {
public static void main(String[] args) {
setGUI();
}
public static void setGUI() {
System.out.println("Starting GUI");
HudWindow hud = new HudWindow("Window");
hud.getJDialog().setSize(300, 350);
hud.getJDialog().setLocationRelativeTo(null);
ActivePanel panel = new ActivePanel();
JButton button = HudWidgetFactory.createHudButton("Button");
panel.add(button);
hud.setContentPane(panel);
hud.getJDialog().setVisible(true);
}
}