开发者

How to add a widget from the mac_widgets java api to HudWindow

Good day,

I recently came accross the mac_widgets api for java. I went through the docementation and exaples but 开发者_运维知识库i didn't find a way to add widgets to the HudWindow. I came accross an online solution

panel.setLayout(new BoxLayout?(panel, BoxLayout?.Y_AXIS)); panel.add(sourceList.getComponent());

This works if panel is a reference to a JPanel object and it is add to a JFrame window.

Is there a way i can add panel to the HudWindow in the mac_widgets api?


Try the following code, of course you wont get the transparency. But this is how you add a panel to a HUD window. Try extracting the MacWiget.jar file to view other classes. The components have different names, in this case a panel is called 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);
    }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜