powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / dialog из апплета
2 сообщений из 2, страница 1 из 1
dialog из апплета
    #33807903
ex
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
создал диалог, который должен запускаться из апплета.. сам по себе дилог работает.. а когда запускаю из апплета, то компоненты не инициализируются? почему?

Код: 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.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
 import  javax.swing.JPanel;
 import  java.awt.HeadlessException;
 import  java.util.Timer;
 import  java.util.TimerTask;

 import  javax.swing.JDialog;
 import  javax.swing.JLabel;
 import  javax.swing.JProgressBar;
 import  javax.swing.SwingConstants;

 public   class  LoadingDialog  extends  JDialog
{

     private  JPanel jContentPane =  null ;
     private  JLabel labelCaption =  null ;
     private  JProgressBar progressBar =  null ;  //  @jve:decl-index=0:visual-constraint="265,10"
     private  Timer timer =  new  Timer();

     public  LoadingDialog()  throws  HeadlessException
    {
         super ();
        // TODO Auto-generated constructor stub
        
        initialize();
    }
    
    /**
     * This method initializes progressBar	
     * 	
     * @return javax.swing.JProgressBar	
     */
     private  JProgressBar getProgressBar()
    {
         if  (progressBar ==  null )
        {
                progressBar =  new  JProgressBar( 0 ,  1000 );
                progressBar.setSize( new  java.awt.Dimension( 164 , 14 ));
                progressBar =  new 
                JProgressBar(SwingConstants.HORIZONTAL,  0 ,  1000 );
                progressBar.setBounds( new  java.awt.Rectangle( 8 , 61 , 220 , 22 ));
        }       
         return  progressBar;
    }

    /**
     * This method initializes this
     * 
     * @return void
     */
     private   void  initialize()
    {
         this .setSize( 245 ,  150 );
         this .setResizable(false);
         this .setContentPane(getJContentPane());
         this .runProgressBar();
    }

    /**
     * This method initializes jContentPane
     * 
     * @return javax.swing.JPanel
     */
     private  JPanel getJContentPane()
    {
         if  (jContentPane ==  null )
        {
            labelCaption =  new  JLabel();
            labelCaption.setText("JLabel");
            labelCaption.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
            labelCaption.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            labelCaption.setBounds( new  java.awt.Rectangle( 2 , 18 , 231 , 16 ));
            jContentPane =  new  JPanel();
            jContentPane.setLayout( null );
            jContentPane.add(labelCaption,  null );
            jContentPane.add(getProgressBar(),  null );
        }
         return  jContentPane;
    }
    
     private   void  runProgressBar(){
        
        timer.schedule( new  TimerTask()
                {

                     public   void  run()
                    {
                         if  (getProgressBar().getValue() < getProgressBar().getMaximum()) 
                            getProgressBar().setValue(getProgressBar().getValue()+  10 );
                         else 
                            getProgressBar().setValue( 0 ); 
                    }

                },  0 ,  10 );
    }

} 
...
Рейтинг: 0 / 0
dialog из апплета
    #33808006
он же
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
ХорстманнApplication Conversion to Applets
It is easy to convert a graphical Java application (that is, an application that uses the AWT and that you can start with the java program launcher) into an applet that you can embed in a web page. Essentially, all of the user interface code can stay the same.

Here are the specific steps for converting an application to an applet.

1. Make an HTML page with the appropriate tag to load the applet code.


2. Supply a subclass of the JApplet class. Make this class public. Otherwise, the applet cannot be loaded.


3. Eliminate the main method in the application. Do not construct a frame window for the application. Your application will be displayed inside the browser.


4. Move any initialization code from the frame window constructor to the init method of the applet. You don't need to explicitly construct the applet object—the browser instantiates it for you and calls the init method.


5. Remove the call to setSize; for applets, sizing is done with the width and height parameters in the HTML file.


6. Remove the call to setDefaultCloseOperation. An applet cannot be closed; it terminates when the browser exits.


7. If the application calls setTitle, eliminate the call to the method. Applets cannot have title bars. (You can, of course, title the web page itself, using the HTML title tag.)


8. Don't call setVisible(true). The applet is displayed automatically.



Действуй.
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / dialog из апплета
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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