Лесен начин за добавяне на прозорец към системната област

Възможен дубликат:
Как мога да поставя моята Java програма в системната област?

Правя система за уведомяване в java, искам програмата да се показва в системната област, вместо в лентата на задачите, опитах:

notification.setExtendedState(JFrame.ICONIFIED);

Това не само не работи, но изостава по дяволите от моя компютър Текущ код:

public static void notify(String line1, String line2, String imagepath, int style){
        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int width = gd.getDisplayMode().getWidth();
        int swidth = width - 320;

        JFrame notification = new JFrame();
        JPanel main = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        main.setLayout( new GridLayout( 2 , 1 ) );



        JLabel notifyline1 = new JLabel();
        notifyline1.setText(line1);
        notifyline1.setFont(new Font("Minecraft",1 , 16));
        notifyline1.setForeground(new Color(242, 238, 17));
        main.add(notifyline1);

        JLabel notifyline2 = new JLabel();
        notifyline2.setText(line2);
        notifyline1.setFont(new Font("Minecraft",1 , 12));
        notifyline1.setForeground(Color.black);
        main.add(notifyline1);

        notification.add(main);
        notification.setExtendedState(JFrame.ICONIFIED);
        notification.setSize(new Dimension(320,64));
        notification.setLocation(swidth, 0);
        notification.setUndecorated(true);
        notification.setVisible(true);
    }

СЪЩО ТО, за да убиете 2 заека с един камък, има ли начин да оцветите jlabel, опитах

label1.setForegroundColor(new Color(100, 100, 100));

person user1631686    schedule 13.01.2013    source източник


Отговори (1)


Java има TrayIcon клас, който може да се използва за минимизиране на приложението до SystemTray. Можете да видите работния пример тук.

person kaysush    schedule 13.01.2013