Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / диалог always on top к родителю / 4 сообщений из 4, страница 1 из 1
06.04.2006, 02:00
    #33647734
Looking
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
диалог always on top к родителю
Нужно создать диалог(не модальный), который бы always on top к родителю, т.е. диалог на переднем плане, а в основном окне можно что-нить менять.
...
Рейтинг: 0 / 0
06.04.2006, 11:39
    #33648472
yelena
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
диалог always on top к родителю
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
 package  test_dialog;

 import  java.awt.Toolkit;
 import  javax.swing.SwingUtilities;
 import  javax.swing.UIManager;
 import  java.awt.Dimension;

 public   class  Application1 {
     boolean  packFrame = false;

    /**
     * Construct and show the application.
     */
     public  Application1() {
        Frame1 frame =  new  Frame1();
        // Validate frames that have preset sizes
        // Pack frames that have useful preferred size info, e.g. from their layout
         if  (packFrame) {
            frame.pack();
        }  else  {
            frame.validate();
        }

        // Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
         if  (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
         if  (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        frame.setLocation((screenSize.width - frameSize.width) /  2 ,
                          (screenSize.height - frameSize.height) /  2 );
        frame.setVisible(true);
    }

    /**
     * Application entry point.
     *
     * @param args String[]
     */
     public   static   void  main(String[] args) {
        SwingUtilities.invokeLater( new  Runnable() {
             public   void  run() {
                 try  {
                    UIManager.setLookAndFeel(UIManager.
                                             getSystemLookAndFeelClassName());
                }  catch  (Exception exception) {
                    exception.printStackTrace();
                }

                 new  Application1();
            }
        });
    }
}

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
 package  test_dialog;

 import  java.awt.BorderLayout;
 import  java.awt.Dimension;

 import  javax.swing.JFrame;
 import  javax.swing.JPanel;
 import  javax.swing.JTextField;
 import  javax.swing.JButton;
 import  java.awt.event.ActionEvent;
 import  java.awt.event.ActionListener;

 public   class  Frame1  extends  JFrame {
    JPanel contentPane;
    BorderLayout borderLayout1 =  new  BorderLayout();
    JTextField jTextField1 =  new  JTextField();
    JButton jButton1 =  new  JButton();

     public  Frame1() {
         try  {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        }  catch  (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
     private   void  jbInit()  throws  Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(borderLayout1);
        setSize( new  Dimension( 400 ,  300 ));
        setTitle("Frame Title");
        jTextField1.setText("jTextField1");
        jButton1.setText("jButton1");
        jButton1.addActionListener( new  Frame1_jButton1_actionAdapter( this ));
        contentPane.add(jTextField1, java.awt.BorderLayout.NORTH);
        contentPane.add(jButton1, java.awt.BorderLayout.SOUTH);
    }

     public   void  jButton1_actionPerformed(ActionEvent e) {
        Dialog1 d =  new  Dialog1( this , "", false);
        d.setAlwaysOnTop(true);
        d.setVisible(true);
    }
}


 class  Frame1_jButton1_actionAdapter  implements  ActionListener {
     private  Frame1 adaptee;
    Frame1_jButton1_actionAdapter(Frame1 adaptee) {
         this .adaptee = adaptee;
    }

     public   void  actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
 package  test_dialog;

 import  java.awt.BorderLayout;
 import  java.awt.Frame;

 import  javax.swing.JDialog;
 import  javax.swing.JPanel;

 public   class  Dialog1  extends  JDialog {
    JPanel panel1 =  new  JPanel();
    BorderLayout borderLayout1 =  new  BorderLayout();

     public  Dialog1(Frame owner, String title,  boolean  modal) {
         super (owner, title, modal);
         try  {
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        }  catch  (Exception exception) {
            exception.printStackTrace();
        }
    }

     public  Dialog1() {
         this ( new  Frame(), "Dialog1", false);
    }

     private   void  jbInit()  throws  Exception {
        panel1.setLayout(borderLayout1);
        getContentPane().add(panel1);
    }
}
...
Рейтинг: 0 / 0
06.04.2006, 17:04
    #33649885
Jozic
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
диалог always on top к родителю
JDK 5.0 API setAlwaysOnTop
public final void setAlwaysOnTop(boolean alwaysOnTop)
throws SecurityException
Changes the always-on-top window state. An always-on-top window is a window that stays above all other windows except maybe other always-on-top windows. If there are several always-on-top windows the order in which they stay relative to each other is not specified and is platform dependent.
If some other window already is always-on-top then the relative order between these windows is unspecified (depends on platform). No window can be brought to be over always-on-top window except maybe another always-on-top window.

All owned windows of an always-on-top window automatically become always-on-top windows. If a window ceases to be always-on-top its owned windows cease to be always-on-top.

When an always-on-top window is sent toBack its always-on-top state is set to false.

This method makes the window always-on-top if alwaysOnTop is true. If the window is visible, this includes bringing window toFront, then "sticking" it to the top-most position. If the window is not visible it does nothing other than setting the always-on-top property. If later the window is shown, it will be always-on-top. If the Window is already always-on-top, this call does nothing.

If alwaysOnTop is false this method changes the state from always-on-top to normal. The window remains top-most but its z-order can be changed in the normal way as for any other window. Does nothing if this Window is not always-on-top. Has no effect on relative z-order of windows if there are no other always-on-top windows.

Note: some platforms might not support always-on-top windows. There is no public API to detect if the platform supports always-on-top at runtime.

If a SecurityManager is installed, the calling thread must be granted the AWTPermission "setWindowAlwaysOnTop" in order to set the value of this property. If this permission is not granted, this method will throw a SecurityException, and the current value of the property will be left unchanged.


Parameters:
alwaysOnTop - new value of always-on-top state of the window
Throws:
SecurityException - if the calling thread does not have permission to set the value of always-on-top property
Since:
1.5
See Also:
isAlwaysOnTop(), toFront(), toBack(), AWTPermission
...
Рейтинг: 0 / 0
06.04.2006, 17:23
    #33649982
Looking
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
диалог always on top к родителю
Всем спасибо. Вопрос снят. Тема раскрыта.
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / диалог always on top к родителю / 4 сообщений из 4, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]