tutorials.de Buch-Aktion 05/2012
ERLEDIGT
JA
ANTWORTEN
13
ZUGRIFFE
193
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Hallo!

    Ich hab das Forum schon durchforstet und nicht wirklich was hilfreiches gefunden, daher mach ich ein neues Thema auf:

    Ich habe ein Applet geschrieben, dass über ein HTTP-Request ein XML zurückbekommt dieses auswertet und dann Elemente zeichnet.

    Mein Problem ist jetzt: Wenn ich den Browser starte und die Seite des Applets aufrufe, funktionierts einwandfrei, wenn ich jetzt die Seite neu Lade ohne den Browser neu zu starten, dann funktionierts nicht mehr richtig.

    Ich hab den Verdacht, dass ich was mit der init(), start(), stop() oder destroy() machen muss bzw dass das ganze mit dem Cache vom Browser zusammenhängt.

    Witzigerweise funktioniert das unter RuntimeEnvironment jre1.6.0_07 einwandfrei, nur neuere Environments spinnen herum.

    Folgend der Code von meiner Appletklasse:

    Code java:
    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
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package main;
     
     
    //own Packages
    import GUI.*;
    import GUI.LISTENER.*;
    import GUI.PAINT.*;
     
    //java Packages
    import HTTP.HttpRequestor;
    import XML.buildObject;
    import java.awt.Color;
    import java.awt.Cursor;
    import javax.swing.*;
    import javax.swing.plaf.ColorUIResource;
     
     
    /**
     *
     * @author Mario Santner
     */
    public class applet extends JApplet
    {
        public Cache cache;
        public Functions functions;
        public buildObject xml;
        public HttpRequestor httpRequestor;
        public SaveDialog saveDialog;
        
        /*      SWING ELEMENTS      */
        //Swing Elements for Search
        private JLabel l_search;
        private JTextField tf_search;
        
        //Swing Elements for Zoom
        private JLabel l_zoomLeft;
        private JLabel l_zoomRight;
        private JTextField tf_zoomLeft;
        private JTextField tf_zoomRight;
        
        //Swing Elements for Age
        private JLabel l_from;
        private JLabel l_to;
        private JTextField tf_from;
        private JTextField tf_to;
        
        //Swing Elements for System
        public JRadioButton rb_production;
        public JRadioButton rb_acceptance;
        public ButtonGroup gr_system;
        
        //Swing Elements for applet
        private MainTable t_Main;
        private JScrollPane s_tMain;
        private JLabel l_picBox;
        private PictureBox p_picBox;
        private JScrollPane s_ppicBox;
        private int object;
        //0 nothing is set
        //1 table is set (also the startTable)
        //2 picBox is set
        
        //Swing Elements for Information
        private JLabel l_Info;
        private MainTable t_Info;
        private JScrollPane s_tInfo;
        
        //Swing Elements for Path
        private JLabel l_path;
        private JTextField tf_path;
        
        //Buttons
        private JButton b_search;
        private JButton b_edit;
        private JButton b_back;
        private JButton b_next;
        private JButton b_center;
        private JButton b_copyClipBoard;
        private JButton b_save;
        private JButton b_link;
        
        //ActionListener
        private ButtonListener listen_button;
        private keyListener listen_key;
        
        //Other
        private String link;
     
        
        /*      GETTER      */
        /**
         * Method to get Buttons <br />
         * Parameter search, edit, back, next, center, clipboard, save
         * @param String _type 
         * @return JButton
         */
        public JButton getButton(String _type)
        {
            if(_type.equals("search"))
                return this.b_search;
            else if(_type.equals("edit"))
                return this.b_edit;
            else if(_type.equals("back"))
                return this.b_back;
            else if(_type.equals("next"))
                return this.b_next;
            else if(_type.equals("center"))
                return this.b_center;
            else if(_type.equals("clipboard"))
                return this.b_copyClipBoard;
            else if(_type.equals("save"))
                return this.b_save;
     
            return null;
        }
     
        /**
         * Method to get TextFields <br />
         * Parameter: search, zoomLeft, zoomRight, from, to, path
         * @param String _type
         * @return JTextField
         */
        public JTextField getTextField(String _type)
        {
            if(_type.equals("search"))
                return this.tf_search;
            else if(_type.equals("zoomLeft"))
                return this.tf_zoomLeft;
            else if(_type.equals("zoomRight"))
                return this.tf_zoomRight;
            else if(_type.equals("to"))
                return this.tf_to;
            else if(_type.equals("from"))
                return this.tf_from;
            else if(_type.equals("path"))
                return this.tf_path;
            
            return null;
        }
        
        /**
         * Method to get Tables <br />
         * Parameter: main, Info
         * @param String _type
         * @return JTable
         */
        public JTable getTable(String _type)
        {
            if(_type.equals("main"))
                return this.t_Main;
            else if(_type.equals("info"))
                return this.t_Info;
            
            return null;
        }
        
        /**
         * Method to get ScrollPanes <br />
         * Parameter: main, info, picBox
         * @param String _type
         * @return JTable
         */
        public JScrollPane getScrollbar(String _type)
        {
            if(_type.equals("main"))
                return this.s_tMain;
            else if(_type.equals("info"))
                return this.s_tInfo;
            else if(_type.equals("picBox"))
                return this.s_ppicBox;
            
            return null;
        }
        
        /**
         * Method to get Labels <br />
         * Parameter: picBox
         * @param String _type
         * @return JLabel
         */
        public JLabel getLabel(String _type)
        {
            if(_type.equals("picBox"))
                return this.l_picBox;
            
            return null;
        }
        
        public PictureBox getPicBox()
        { return this.p_picBox; }
        
        public int getObject()
        { return this.object; }
        
        /**
         * Method to get RadioButtons <br />
         * Parameter: production, acceptance
         * @param String _type
         * @return JRadioButton
         */
        public JRadioButton getRadioButton(String _type)
        { 
            if(_type.equals("production"))
                return this.rb_production;
            else if(_type.equals("acceptance"))
                return this.rb_acceptance;
            
            return null;
        }
        
        public ButtonGroup getButtonGroup()
        { return this.gr_system; }
        
        public String getLink()
        { return this.link; }
        
        /*      SETTER      */
        /**
         * Method to set Tables <br />
         * Parameter: main, Info
         * @param String _type, JTable _table
         * @return void
         */
        public void setTable(String _type, MainTable _table)
        {
            if(_type.equals("main"))
                this.t_Main = _table;
            else if(_type.equals("info"))
                this.t_Info = _table;
        }
        
        /**
         * Method to set ScrollPanes <br />
         * Parameter: main, info, picBox
         * @param String _type, JScrollPane _scroll
         * @return void
         */
        public void setScrollPane(String _type, JScrollPane _scroll)
        {
            if(_type.equals("main"))
                this.s_tMain = _scroll;
            else if(_type.equals("info"))
                this.s_tInfo = _scroll;
            else if(_type.equals("picBox"))
                this.s_ppicBox = _scroll;
        }
        
        public void setPicBox(PictureBox _picBox)
        { this.p_picBox = _picBox; }
        
        public void setObject(int _obj)
        { this.object = _obj; }
        
        /**
         * Method to set RadioButtons <br />
         * Parameter: production, reduction
         * @param String _type, JRadioButton _button
         * @return void
         */
        public void setRadioButton(String _type, JRadioButton _button)
        { 
            if(_type.equals("production"))
                this.rb_production = _button;
            else if(_type.equals("reduction"))
                this.rb_acceptance = _button;
        }
        
        
        /*      JavaScript METHODS      */
        public void setLink(String _link)
        { 
            /*
            this.link = _link;
     
            if(this.link.indexOf("?") != -1)
            {
                System.out.println("NICHT LEER");
                
                
                try
                { this.tf_search.setText(this.link.substring(this.link.indexOf("&ok")+4, this.link.indexOf("&zl"))); }
                catch (NullPointerException ex)
                { this.tf_search.setText(this.link.substring(this.link.indexOf("&sk")+4, this.link.indexOf("&zl"))); }
                
                this.tf_zoomLeft.setText(this.link.substring(this.link.indexOf("&zl")+4, this.link.indexOf("&zr")));
                this.tf_zoomRight.setText(this.link.substring(this.link.indexOf("&zr")+4, this.link.indexOf("&to")));
                this.tf_from.setText(this.link.substring(this.link.indexOf("&fo")+4, this.link.length()));
                this.tf_to.setText(this.link.substring(this.link.indexOf("&to")+4, this.link.indexOf("&fo")));
            }*/
        }
        
        
        @Override
        public void init()
        {
            super.init();
            
            //alle klassen die nur einmal gebraucht werden initialisieren und
            //referenzen zu den jeweiligen klassen machen
            this.cache = new Cache(this);
            this.functions = new Functions(this);
            this.xml = new buildObject(this);
            this.httpRequestor = new HttpRequestor(this);
            this.saveDialog = new SaveDialog(this);
            
            this.functions.setReferences(this.cache, this.xml, this.httpRequestor, this.saveDialog);
            this.xml.setReferences(this.cache, this.functions);
            this.httpRequestor.setReferences(this.cache, this.functions);
            
            
            
            
            //ToolTipManager
            ToolTipManager ttm = ToolTipManager.sharedInstance();
            ttm.setDismissDelay(this.cache.toolTipTime);
            UIManager.put("ToolTip.background", new ColorUIResource(255, 255, 255)); 
            
            /*      WINDOW      */
            this.setName("Show Flow");
            //this.setTitle("Show Flow");
            this.setLayout(null);
            this.setVisible(true);
            this.setSize(930, 650);
            //this.setLocationRelativeTo(null);
            //this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            //this.setResizable(false);
            
            
            /*      SEARCH      */
            //label
            this.l_search = new JLabel("Search");
            this.l_search.setVisible(true);
            this.l_search.setLocation(11, 10);
            this.l_search.setSize(100, 15);
            this.add(this.l_search); 
            
            //textfield
            this.tf_search = new JTextField("");
            this.tf_search.setEditable(true);
            this.tf_search.setVisible(true);
            this.tf_search.setLocation(10, 30);
            this.tf_search.setSize(300, 25);
            this.add(this.tf_search);
            
            
            /*      ZOOM      */
            ////ZOOM LEFT
            //label
            this.l_zoomLeft = new JLabel("Elements left");
            this.l_zoomLeft.setVisible(true);
            this.l_zoomLeft.setLocation(330, 10);
            this.l_zoomLeft.setSize(82, 15);
            this.add(this.l_zoomLeft);
            
            //textfield
            this.tf_zoomLeft = new JTextField("3");
            this.tf_zoomLeft.setEditable(true);
            this.tf_zoomLeft.setVisible(true);
            this.tf_zoomLeft.setLocation(330, 30);
            this.tf_zoomLeft.setSize(82, 25);
            this.add(this.tf_zoomLeft);
            
            ////ZOOM RIGHT
            //label
            this.l_zoomRight= new JLabel("Elements right");
            this.l_zoomRight.setVisible(true);
            this.l_zoomRight.setLocation(422, 10);
            this.l_zoomRight.setSize(82, 15);
            this.add(this.l_zoomRight);
            
            //textfield
            this.tf_zoomRight = new JTextField("3");
            this.tf_zoomRight.setEditable(true);
            this.tf_zoomRight.setVisible(true);
            this.tf_zoomRight.setLocation(422, 30);
            this.tf_zoomRight.setSize(82, 25);
            this.add(this.tf_zoomRight);
            
            
            /*      AGE      */
            ////FROM
            //textfield
            this.tf_from = new JTextField("1990-01-01");
            this.tf_from.setEditable(true);
            this.tf_from.setVisible(true);
            this.tf_from.setLocation(580, 10);
            this.tf_from.setSize(80, 20);
            this.add(this.tf_from);
            
            //label
            this.l_from = new JLabel("days");
            this.l_from.setVisible(true);
            this.l_from.setLocation(668, 11);
            this.l_from.setSize(30, 15);
            this.add(this.l_from);
            
            ////TO
            //textfield
            this.tf_to = new JTextField(this.functions.getToday());
            this.tf_to.setEditable(true);
            this.tf_to.setVisible(true);
            this.tf_to.setLocation(580, 35);
            this.tf_to.setSize(80, 20);
            this.add(this.tf_to);
            
            //label
            this.l_to = new JLabel("days");
            this.l_to.setVisible(true);
            this.l_to.setLocation(668, 37);
            this.l_to.setSize(30, 15);
            this.add(this.l_to);
            
            
            /*      SYSTEM      */
            this.gr_system = new ButtonGroup();
            
            ////REDUCTION
            this.rb_acceptance = new JRadioButton("Reduction");
            this.rb_acceptance.setVisible(true);
            this.rb_acceptance.setLocation(715, 10);
            this.rb_acceptance.setSize(100, 18);
            this.rb_acceptance.setSelected(true);
            this.gr_system.add(this.rb_acceptance);
            this.add(this.rb_acceptance);
            
            ////PRODUCTION (Produktion)
            this.rb_production = new JRadioButton("Production");
            this.rb_production.setVisible(true);
            this.rb_production.setLocation(715, 36);
            this.rb_production.setSize(100, 18);
            this.rb_production.setSelected(false);
            this.gr_system.add(this.rb_production);
            this.add(this.rb_production);
     
            
            /*      BUTTONS      */
            //ok
            this.b_search = new JButton("search");
            this.b_search.setVisible(true);
            this.b_search.setLocation(822, 10);
            this.b_search.setSize(90, 20);
            this.b_search.setFocusable(false);
            this.add(this.b_search);
            
            //edit
            this.b_edit = new JButton("edit View");
            this.b_edit.setEnabled(false);
            this.b_edit.setVisible(true);
            this.b_edit.setLocation(822, 35);
            this.b_edit.setSize(90, 20);
            this.b_edit.setFocusable(false);
            this.add(this.b_edit);
            
            //save
            this.b_save = new JButton("save as JPG");
            this.b_save.setVisible(true);
            this.b_save.setEnabled(false);
            this.b_save.setLocation(85, 455);
            this.b_save.setSize(110, 20);
            this.b_save.setFocusable(false);
            this.add(this.b_save);
            
            //link
            this.b_link = new JButton("Link to Tracking");
            this.b_link.setVisible(true);
            this.b_link.setEnabled(false);
            this.b_link.setLocation(330, 455);
            this.b_link.setSize(130, 20);
            this.b_link.setFocusable(false);
            this.add(this.b_link);
            
            //center
            this.b_center = new JButton("center");
            this.b_center.setVisible(true);
            this.b_center.setEnabled(false);
            this.b_center.setLocation(600, 455);
            this.b_center.setSize(80, 20);
            this.b_center.setFocusable(false);
            this.add(this.b_center);
            
            //back
            this.b_back = new JButton("back");
            this.b_back.setVisible(true);
            this.b_back.setEnabled(false);
            this.b_back.setLocation(741, 455);
            this.b_back.setSize(80, 20);
            this.b_back.setFocusable(false);
            this.add(this.b_back);
            
            //next
            this.b_next = new JButton("next");
            this.b_next.setVisible(true);
            this.b_next.setEnabled(false);
            this.b_next.setLocation(832, 455);
            this.b_next.setSize(80, 20);
            this.b_next.setFocusable(false);
            this.add(this.b_next);
            
            //copyClipBoard
            this.b_copyClipBoard = new JButton("Copy to Clipboard");
            this.b_copyClipBoard.setVisible(true);
            this.b_copyClipBoard.setEnabled(true);
            this.b_copyClipBoard.setLocation(775, 568);
            this.b_copyClipBoard.setSize(135, 20);
            this.b_copyClipBoard.setFocusable(false);
            this.add(this.b_copyClipBoard);
            
            
            /*      PATH      */
            //label
            this.l_path = new JLabel("Link to this item:");
            this.l_path.setVisible(true);
            this.l_path.setLocation(10, 570);
            this.l_path.setSize(100, 15);
            this.add(this.l_path);
            
            //textfield
            this.tf_path = new JTextField("");
            this.tf_path.setEditable(false);
            this.tf_path.setVisible(true);
            this.tf_path.setLocation(110, 565);
            this.tf_path.setSize(655, 25);
            this.tf_path.setBackground(Color.WHITE);
            this.tf_path.setCursor(new Cursor(Cursor.TEXT_CURSOR));
            this.add(this.tf_path);
            
            
            /*      INFO      */
            //label
            this.l_Info = new JLabel("Information");
            this.l_Info.setVisible(true);
            this.l_Info.setLocation(11, 473);
            this.l_Info.setSize(80, 15);
            this.add(this.l_Info);
            
            //table + scrollpane
            this.cache.blankInfoTable = this.functions.createInfoTable(this.cache.info_title, null);
            
            
             /*      MAIN FRAME      */
            ////PICTURE BOX
            //label
            this.l_picBox = new JLabel(this.cache.picBox_title);
            this.l_picBox.setVisible(false);
            this.l_picBox.setLocation(430, 62);
            this.l_picBox.setSize(100, 15);
            this.add(this.l_picBox);
            
            
            ////SEARCH
            //table + scrollpane
            this.functions.createMainTable(this.cache.main_title, null);
            this.functions.addObjectCache(this.t_Main);
        
            
            //setting focus for start
            this.tf_search.requestFocus();
            
            this.repaint();
             
            
            /*      LISTENER      */
            //BUTTONS
            this.listen_button = new ButtonListener(this);
            this.b_search.addActionListener(this.listen_button);
            this.b_edit.addActionListener(this.listen_button);
            this.b_back.addActionListener(this.listen_button);
            this.b_next.addActionListener(this.listen_button);
            this.b_center.addActionListener(this.listen_button);
            this.b_copyClipBoard.addActionListener(this.listen_button);
            this.b_save.addActionListener(this.listen_button);
            
            //SEARCH
            this.listen_key = new keyListener(this);
            this.tf_search.addKeyListener(this.listen_key);
            this.tf_zoomLeft.addKeyListener(this.listen_key);
            this.tf_zoomRight.addKeyListener(this.listen_key);
            this.tf_from.addKeyListener(this.listen_key);
            this.tf_to.addKeyListener(this.listen_key);
            
            //SEARCH WITH PATH
            this.tf_path.addKeyListener(new keyListener(this));
     
            //JOptionPane.showMessageDialog(this, System.getProperty("java.version"));
        }
        
        @Override
        public void start()
        {
            super.start();
        }
        
        @Override
        public void stop()
        {
            super.stop();
        }
        
        @Override
        public void destroy()
        {
            super.destroy();
        }
    }

    danke schonmal für die Hilfe
     

  2. #2
    Avatar von Fabio Hellmann
    Fabio Hellmann Fabio Hellmann ist offline Mitglied Brokat
    Registriert seit
    Aug 2011
    Ort
    München
    Beiträge
    494
    Hi,
    vielleicht hilft dir das erstmal weiter.
    init() – wird genau einmal aufgerufen, wenn das Applet erstmals in den Browser geladen wird.
    start() – wird jedes Mal aufgerufen, wenn das Applet sichtbar wird.
    paint(…) – Zeichenmethode für die Anzeigefunktionen des Applet
    stop() – wird jedes Mal aufgerufen, wenn das Applet verdeckt wird, z. B. weil das Browser-Fenster von einem anderen Fenster überdeckt wird.
    destroy() – wird aufgerufen, wenn das Applet aus dem Hauptspeicher entladen wird.
    Gruß

    Fabio
     
    Bitte die Code-Tags verwenden. Bei Java-Code: [java]...[/java]

    Tutorials:
    Automatisches erzeugen eines Inhaltsverzeichnisses (Javascript)
    JAnimationPanel - Animationen für Swing/AWT
    SWTRatingBar (Bewertungs-Composite) selbst programmieren
    ____________________________________________________________________________
    Über eine Bewertung (Stern links unter dem Beitrag) oder ein Danke freue ich mich sehr.

  3. #3
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Danke erstmal. Hab mir die Funktionen auch schon angeschaut, nur leider blick ich da nicht ganz durch
     

  4. #4
    Avatar von Fabio Hellmann
    Fabio Hellmann Fabio Hellmann ist offline Mitglied Brokat
    Registriert seit
    Aug 2011
    Ort
    München
    Beiträge
    494
    Ich sags mal so, alles was nach einem Refresh im Browser neu geladen werden muss, sollte in die start()-Methode.
     
    Bitte die Code-Tags verwenden. Bei Java-Code: [java]...[/java]

    Tutorials:
    Automatisches erzeugen eines Inhaltsverzeichnisses (Javascript)
    JAnimationPanel - Animationen für Swing/AWT
    SWTRatingBar (Bewertungs-Composite) selbst programmieren
    ____________________________________________________________________________
    Über eine Bewertung (Stern links unter dem Beitrag) oder ein Danke freue ich mich sehr.

  5. #5
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Hmm, hab ich auch schon versucht, ich habe alles, was in der init() Funktion steht, schon in die start() reingeworfen. Kein Unterschied.

    Hab auch schon versucht mit verschiedenen mitteln das Caching direkt selbst zu Unterdrücken (also mit Mitteln die ich hier im Forum gefunden habe) hat auch keinen Erfolg gebracht (wobei ich nicht kontrollieren kann, ob er das Caching wirklich deaktiviert hat).

    Wie schon gesagt ist es auch interessant dass es mit einer älteren JavaVersion (jre1.6.0_07) einwandfrei funktioniert.
     

  6. #6
    Avatar von Fabio Hellmann
    Fabio Hellmann Fabio Hellmann ist offline Mitglied Brokat
    Registriert seit
    Aug 2011
    Ort
    München
    Beiträge
    494
    Was für einen Browser verwendest du denn zum Testen?
     
    Bitte die Code-Tags verwenden. Bei Java-Code: [java]...[/java]

    Tutorials:
    Automatisches erzeugen eines Inhaltsverzeichnisses (Javascript)
    JAnimationPanel - Animationen für Swing/AWT
    SWTRatingBar (Bewertungs-Composite) selbst programmieren
    ____________________________________________________________________________
    Über eine Bewertung (Stern links unter dem Beitrag) oder ein Danke freue ich mich sehr.

  7. #7
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Internet Explorer 8

    aber bei Firefox ist das Selbe Phänomen
     

  8. #8
    Avatar von Fabio Hellmann
    Fabio Hellmann Fabio Hellmann ist offline Mitglied Brokat
    Registriert seit
    Aug 2011
    Ort
    München
    Beiträge
    494
    Was genau tritt denn bei dem Neuladen von der Seite für ein Problem auf? Deine Formulierung hilft mir da nicht wirklich weiter. Vielleicht kannst du mal ein Screenshot (vorher, nachher) machen.
     
    Bitte die Code-Tags verwenden. Bei Java-Code: [java]...[/java]

    Tutorials:
    Automatisches erzeugen eines Inhaltsverzeichnisses (Javascript)
    JAnimationPanel - Animationen für Swing/AWT
    SWTRatingBar (Bewertungs-Composite) selbst programmieren
    ____________________________________________________________________________
    Über eine Bewertung (Stern links unter dem Beitrag) oder ein Danke freue ich mich sehr.

  9. #9
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Hallo!

    Ich komm den Problem näher und kann es eingrenzen:

    Ich habe den Großteil der ganzen Koordinaten in einer eigenen Cache-Klasse. Beim reload scheint er die Referenz auf diese Klasse bei manchen Variablen (besonders bei den Bounds die benötigt werden für die Scrollbars) zu verlieren.

    Cache

    Code java:
    1
    2
    3
    4
    5
    
    this.mainTableBounds = new int[4];
            this.mainTableBounds[0] = 10;
            this.mainTableBounds[1] = 60;
            this.mainTableBounds[2] = 901;
            this.mainTableBounds[3] = 385;

    Funktion zum Tabelle setzen:

    Code java:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    //configuration
            table.setVisible(true);
            table.setEnabled(false);
            table.setShowHorizontalLines(true);
            table.setShowVerticalLines(true);
            table.setLocation(this.cache.mainTableLocation);
            table.setSize(this.cache.mainTableDimension);
            int[] bounds = this.cache.mainTableBounds;
            table.setBounds
            (
                bounds[0], bounds[1], bounds[2], bounds[3]
            );

    Was ich wiederum interessant finde: Wenn ich mir die Variablen ausgeben lasse, dann schreibt er sie mir ganz normal in die JavaKonsole raus.

    Wenn ich die Koordinaten direkt reinschreibe, dann nimmt er sie ohne wenn und aber an (hab ich Versuchweise gemacht)

    wenn ich die Cacheklasse im start() neu instanziere dann mag er's auch nicht.

    Wenn noch Screenys zur weiteren Erklärung benötigt werden, dann kann ich sonst welche nachliefern.
     

  10. #10
    Avatar von Fabio Hellmann
    Fabio Hellmann Fabio Hellmann ist offline Mitglied Brokat
    Registriert seit
    Aug 2011
    Ort
    München
    Beiträge
    494
    Heißt das jetzt, das die Bounds von dem Table-Objekt geändert werden, oder stehen immer die gleichen Werte in diesem int[]? Wenn sie immer gleichbleibend sind, kannst du sie auch als Constante deklarieren. Dadurch können dir die Variablen nicht mal eben verloren gehen.
     
    Bitte die Code-Tags verwenden. Bei Java-Code: [java]...[/java]

    Tutorials:
    Automatisches erzeugen eines Inhaltsverzeichnisses (Javascript)
    JAnimationPanel - Animationen für Swing/AWT
    SWTRatingBar (Bewertungs-Composite) selbst programmieren
    ____________________________________________________________________________
    Über eine Bewertung (Stern links unter dem Beitrag) oder ein Danke freue ich mich sehr.

  11. #11
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Soweit hab ich mir das auch schon überlegt gehabt, geht auch nicht

    was ich jetzt auch noch versucht habe, ist alle Elemente bei stop() auf null setzen und bei start neu zu instanzieren --> fail

    ich hab mir auch auch mal gecheckt wie er die vier funktionen aufruft:

    Erster Aufruf (also Browserneustart)
    init()
    start()

    Fenster wegklicken
    stop()
    destroy()


    Fenster wieder aufrufen:
    init()
    start()


    das kommt mir auch spanisch vor, vor allem da er init() und destroy() nur einmal aufrufen sollte bzw. wenn er es so aufruft wie ich es jetzt geschrieben habe, müsste er das applet normalerweise jedesmal neu instanzieren und somit wäre das problem auch gegessen...
     

  12. #12
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Ok, habs jetzt auf mehreren PC's mit unterschiedlichen JRE's ausprobiert: ab Update 20 gehts nicht mehr, ich hab echt ne Vermutung, dass die da irgendwo nen Bug in der VM haben. Ich lass das jetzt so und gib nen Hinweis mit, dass der Browser neu gestartet werden sollte bei neuem Aufruf.

    Danke dir Fabio für deine Hilfe, ich hoffe ich kann mich hier in diesem Forum bald mal revanchieren.

    Somit: Erledigt (vorerst)
     

  13. #13
    genodeftest genodeftest ist offline Mitglied Brillant
    Registriert seit
    Jun 2009
    Beiträge
    870
    Bist du dir sicher, dass es am Update 20 liegt? Probier mal OpenJDK oder Java7, ob der Fehler dort auch auftritt...
     
    Code bitte so einfügen: [java]System.out.println("Hallo");[/java] (Analog für andere Programmiersprachen)
    Code java:
    1
    
    System.out.println("Hallo");
    hilfreich zu Java: Really Big Index, Java ist auch eine Insel Band 1 und Band 2.
    ___________
    Ubuntu Bug #1: Microsoft has a majority market share
    Casecon: Projekt leiser Käse

  14. #14
    sognix sognix ist offline Mitglied
    Registriert seit
    Jul 2011
    Beiträge
    15
    Hallo!

    Die Versionen kann ich leider nicht testen, da das ganze Firmenintern abläuft und da OpenJDK nicht und Java7 (noch) nicht verwendet wird, kann ich es soweit nicht sagen. Ich post aber hier einen Eintrag wenn ich es mit Java 7 testen konnte, bzw wenn eine andere Problemlösung auftaucht. Vl hat ja jemand irgendwann mal dasselbe Problem.

    Danke.
     

Ähnliche Themen

  1. Antworten: 5
    Letzter Beitrag: 03.06.11, 23:23
  2. Antworten: 27
    Letzter Beitrag: 24.05.10, 20:04
  3. Antworten: 6
    Letzter Beitrag: 20.12.09, 20:24
  4. Applet funktioniert nicht im Browser !! AccessControlException ORACLE
    Von Dadu2006 im Forum Swing, Java2D/3D, SWT, JFace
    Antworten: 2
    Letzter Beitrag: 10.07.07, 12:10
  5. Antworten: 4
    Letzter Beitrag: 09.04.05, 14:25