public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("abcdefghijklm",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
setSize(400,200);
CallbackTestInterface = new ITest()
{@Override public void ResultHandlerTest(TestEnum myenum,Vector<byte[]> vrgubData){
ResultHandlerTestCallback(myenum,vrgubData);
}};
if (null != CallbackTestInterface)
add(okButton);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void destroy()
{
CallbackTestInterface = null;
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions. public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method if (evt.getSource() == okButton)
{
// So it was the okButton, then let's perform his actions
// reader.SyncGetEPCs();
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
}
// Actions of the wrongButton else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
// Here we will show the results of our actions public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
}
public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("abcdefghijklm",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
setSize(400,200);
CallbackTestInterface = new ITest()
{@Override public void ResultHandlerTest(TestEnum myenum,Vector<byte[]> vrgubData){
ResultHandlerTestCallback(myenum,vrgubData);
}};
if (null != CallbackTestInterface)
add(okButton);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void destroy()
{
CallbackTestInterface = null;
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions. public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method if (evt.getSource() == okButton)
{
// So it was the okButton, then let's perform his actions
// reader.SyncGetEPCs();
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
}
// Actions of the wrongButton else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
// Here we will show the results of our actions public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
}
public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("abcdefghijklm",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
setSize(400,200);
CallbackTestInterface = new ITest()
{@Override public void ResultHandlerTest(TestEnum myenum,Vector<byte[]> vrgubData){
ResultHandlerTestCallback(myenum,vrgubData);
}};
if (null != CallbackTestInterface)
add(okButton);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void destroy()
{
CallbackTestInterface = null;
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions. public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method if (evt.getSource() == okButton)
{
// So it was the okButton, then let's perform his actions
// reader.SyncGetEPCs();
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
}
// Actions of the wrongButton else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
// Here we will show the results of our actions public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
}
dazu ein Interface und eine Enum definiert:
Java Code:
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
package TestPackage;
import java.util.Vector;
public interface ITest
{
public abstract void ResultHandlerTest(TestEnum myenum,Vector<byte[]> vrgubData);
}
Java Code:
1 2 3 4 5 6 7 8
package TestPackage;
import java.util.Vector;
public interface ITest
{
public abstract void ResultHandlerTest(TestEnum myenum,Vector<byte[]> vrgubData);
}
Java Code:
1 2 3 4 5 6 7 8
package TestPackage;
import java.util.Vector;
public interface ITest
{
public abstract void ResultHandlerTest(TestEnum myenum,Vector<byte[]> vrgubData);
}
static public TestEnum Set(byte value)
{
for (TestEnum e : TestEnum.values())
if (value == e.Get())
return e;
return null;
}
}
Wenn ich mein Applet mit Eclipse im Debugger Starte klappt alles wunderbar. Sobald ich es vom Webspace aus probiere geht es nicht. Es kommt keine Fehlermeldung. Wenn ich Zeile 48-51 auskommentiere bekomme ich das Applet angezeigt.
Woran könnte dies liegen?
MfG
Edit: Fehlermeldungen gelöscht, die sind nicht wirklich aufgetreten der Braowser hatte die seite nicht aktualisisert.
Zuletzt bearbeitet von Destiniy am 09:13:25 30.08.2010, insgesamt 3-mal bearbeitet
Dieses Programm ist nur ein Sample, dass ich im Netz gefunden habe. Und es geht nur darum ob der eine Button angezeigt wird oder nicht. (Zeile 53)
Das Problem ist das mit dem Interface. Wenn ich dies nutze Stürzt das ganze Applet ohne Fehlermeldung ab, d.h. ich sehe auch keine Textausgaben (wie in Zeile 40), die immer da sein müßte.
Blödsinn, ein Applet "stürzt" nicht "ab" und schon gar nicht ohne Fehlermeldung, guck in die Konsole und poste die Fehlermeldung falls eine auftritt.
Entweder du denkst das Applet sollte irgendwas machen, was aber einfach nicht macht, oder der _gelöschte_ Post der hier vorher stand hatte recht und du hast es einfach nicht geschafft das Applet richtig zu deployen.
Natürlich, es kommt eine ClassNotFoundException ...
Übrigens stand das schon vor 3 Wochen hier in dem Post von dem anderen Gast, der gelöscht wurde, glückwunsch...
public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("abcdefghijklm",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
setSize(400,200);
add(okButton);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void destroy()
{
CallbackTestInterface = null;
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions. public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method if (evt.getSource() == okButton)
{
// So it was the okButton, then let's perform his actions
// reader.SyncGetEPCs();
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
}
// Actions of the wrongButton else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
// Here we will show the results of our actions public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
@Override
public void ResultHandlerTest(TestEnum myenum, Vector<byte[]> vrgubData) {
// TODO Auto-generated method stub
public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("abcdefghijklm",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
setSize(400,200);
add(okButton);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void destroy()
{
CallbackTestInterface = null;
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions. public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method if (evt.getSource() == okButton)
{
// So it was the okButton, then let's perform his actions
// reader.SyncGetEPCs();
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
}
// Actions of the wrongButton else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
// Here we will show the results of our actions public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
@Override
public void ResultHandlerTest(TestEnum myenum, Vector<byte[]> vrgubData) {
// TODO Auto-generated method stub
public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("abcdefghijklm",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
setSize(400,200);
add(okButton);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void destroy()
{
CallbackTestInterface = null;
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions. public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method if (evt.getSource() == okButton)
{
// So it was the okButton, then let's perform his actions
// reader.SyncGetEPCs();
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
}
// Actions of the wrongButton else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
// Here we will show the results of our actions public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
@Override
public void ResultHandlerTest(TestEnum myenum, Vector<byte[]> vrgubData) {
// TODO Auto-generated method stub
Nächstes Thema anzeigen Vorheriges Thema anzeigen
Sie können Beiträge in dieses Forum schreiben. Sie können auf Beiträge in diesem Forum antworten. Sie können Ihre Beiträge in diesem Forum nicht bearbeiten. Sie können Ihre Beiträge in diesem Forum nicht löschen. Sie können an Umfragen in diesem Forum nicht mitmachen.
c++.de ist Teilnehmer des Partnerprogramms von Amazon Europe S.à.r.l. und Partner des Werbeprogramms, das zur Bereitstellung eines Mediums
für Websites konzipiert wurde, mittels dessen durch die Platzierung von Werbeanzeigen und Links zu amazon.de
Werbekostenerstattung verdient werden kann.
Die Vervielfältigung der auf den Seiten www.c-plusplus.de, www.c-plusplus.info, www.c-sar.de, www.c-plusplus.net und www.baeckmann.de
enthaltenen Informationen ohne eine schriftliche Genehmigung des Seitenbetreibers ist untersagt
(vgl. §4 Urheberrechtsgesetz). Die Nutzung und Änderung der vorgestellten Strukturen und Verfahren in
privaten und kommerziellen Softwareanwendungen ist ausdrücklich erlaubt, soweit keine Rechte Dritter verletzt werden.
Der Seitenbetreiber übernimmt keine Gewähr für die Funktion einzelner Beiträge oder Programmfragmente, insbesondere
übernimmt er keine Haftung für eventuelle aus dem Gebrauch entstehenden Folgeschäden.