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:
danke schonmal für die Hilfe
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:
Java:
/*
* 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