Windows Azure Cloud Storage ermöglicht es Ihnen bereits ab 0,10€ pro GB/Monat die Vorteile der Cloud zu nutzen.
Hypercell ein ] Hypercell aus ] Zeige Navigation ] Verstecke Navigation ]
c++.de  
   
Advanced Developers Conference     
Bücher-Shop mit Amazon (Buchkategorien)C++ : Referenzen zu C++ : C++ Builder : Visual C++ : C# : Java : Spieleprogrammierung : Systemprogrammierung Linux : Software-Entwicklung : .NET : Compilertechnik : Algorithmen & Datenstrukturen : Objektorientierung : Entwurfsmuster : UML : eXtreme Programming : Scrum : Projektmanagement : Software-Testing : Datenbanken : Tom DeMarco : Dilbert : User Friendly
C/C++ Forum :: Java ::  Java Applet hat Probleme mit Callback ***gelöst***     Zeige alle Beiträge auf einer Seite Auf Beitrag antworten
Autor Nachricht
Destiniy
Mitglied

Benutzerprofil
Anmeldungsdatum: 24.09.2007
Beiträge: 403
Beitrag Destiniy Mitglied 12:12:35 06.08.2010   Titel:   Java Applet hat Probleme mit Callback ***gelöst***            Zitieren

HAllo Leute,

ich habe mir eine Applet geschrieben:

Java Code:
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
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
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;

import TestPackage.ITest;
import TestPackage.TestEnum;

public class TestApplet extends Applet implements ActionListener
{
    private static final long serialVersionUID = 1L;

    Button okButton;
    Button wrongButton;
    TextField nameField;
    CheckboxGroup radioGroup;
    Checkbox radio1;
    Checkbox radio2;
    Checkbox radio3;
   
    ITest CallbackTestInterface;

    public String getAppletInfo()
    {
        return "TestApplet Version 1.0.0";
    }
   
    void ResultHandlerTestCallback(TestEnum myenum,Vector<byte[]> vrgubData)
    {
        nameField.setText("Read");
        repaint();
    }
   
    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);
    }
}
Java Code:
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
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;

import TestPackage.ITest;
import TestPackage.TestEnum;

public class TestApplet extends Applet implements ActionListener
{
private static final long serialVersionUID = 1L;

Button okButton;
Button wrongButton;
TextField nameField;
CheckboxGroup radioGroup;
Checkbox radio1;
Checkbox radio2;
Checkbox radio3;

ITest CallbackTestInterface;

public String getAppletInfo()
{
return "TestApplet Version 1.0.0";
}

void ResultHandlerTestCallback(TestEnum myenum,Vector<byte[]> vrgubData)
{
nameField.setText("Read");
repaint();
}

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);
}
}
Java Code:
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
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;

import TestPackage.ITest;
import TestPackage.TestEnum;

public class TestApplet extends Applet implements ActionListener
{
    private static final long serialVersionUID = 1L;

    Button okButton;
    Button wrongButton;
    TextField nameField;
    CheckboxGroup radioGroup;
    Checkbox radio1;
    Checkbox radio2;
    Checkbox radio3;
   
    ITest CallbackTestInterface;

    public String getAppletInfo()
    {
        return "TestApplet Version 1.0.0";
    }
   
    void ResultHandlerTestCallback(TestEnum myenum,Vector<byte[]> vrgubData)
    {
        nameField.setText("Read");
        repaint();
    }
   
    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);
}

Java Code:
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
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
package TestPackage;

public enum TestEnum {
    NOERROR((byte)0x00),                        // 0x00
    NODATA((byte)0x01);                            // 0x01
   
    private byte value;
   
    private TestEnum(byte value)
    {
        this.value = value;
    }

    public byte Get()
    {
        return value;
    }
   
    static public TestEnum Set(byte value)
    {
        for (TestEnum e : TestEnum.values())
            if (value == e.Get())
                return e;
        return null;
    }   
}
Java Code:
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
package TestPackage;

public enum TestEnum {
NOERROR((byte)0x00), // 0x00
NODATA((byte)0x01); // 0x01

private byte value;

private TestEnum(byte value)
{
this.value = value;
}

public byte Get()
{
return value;
}

static public TestEnum Set(byte value)
{
for (TestEnum e : TestEnum.values())
if (value == e.Get())
return e;
return null;
}
}
Java Code:
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
package TestPackage;

public enum TestEnum {
    NOERROR((byte)0x00),                        // 0x00
    NODATA((byte)0x01);                            // 0x01
   
    private byte value;
   
    private TestEnum(byte value)
    {
        this.value = value;
    }

    public byte Get()
    {
        return value;
    }
   
    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
Destiniy
Mitglied

Benutzerprofil
Anmeldungsdatum: 24.09.2007
Beiträge: 403
Beitrag Destiniy Mitglied 12:29:00 25.08.2010   Titel:              Zitieren

Hi Leute,

das Problem besteht immer noch. Es kommt nur keine Fehlermeldung sondern das Applet wird einfach nicht angezeigt.

Woran könnte dies liegen.

MfG
asfsafqetdg124
Unregistrierter




Beitrag asfsafqetdg124 Unregistrierter 20:30:08 25.08.2010   Titel:              Zitieren

1. Wo sind die Antworten hin die hier vorher standen?
2. Lern wie man AWT benutzt.
Gregor
Moderator

Benutzerprofil
Anmeldungsdatum: 16.01.2002
Beiträge: 7442
Beitrag Gregor Moderator 21:00:29 25.08.2010   Titel:              Zitieren

asfsafqetdg124 schrieb:
1. Wo sind die Antworten hin die hier vorher standen?

Denk mal drüber nach. Vielleicht kommst Du drauf. ;)

_________________
"The problem with quotes on the Internet is that it is hard to verify their authenticity" - Abraham Lincoln
Destiniy
Mitglied

Benutzerprofil
Anmeldungsdatum: 24.09.2007
Beiträge: 403
Beitrag Destiniy Mitglied 08:24:39 26.08.2010   Titel:              Zitieren

Hallo

Zitat:

2. Lern wie man AWT benutzt.
das hilft mir jetzt ungemein weiter :)

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.

MfG
asfsafqetdg124
Unregistrierter




Beitrag asfsafqetdg124 Unregistrierter 13:59:50 26.08.2010   Titel:              Zitieren

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.
Destiniy
Mitglied

Benutzerprofil
Anmeldungsdatum: 24.09.2007
Beiträge: 403
Beitrag Destiniy Mitglied 09:13:06 30.08.2010   Titel:              Zitieren

OK hab das Problem gefunden

Ich hatte die Datei mit dem $1 nicht mit auf den server kopiert. Nur komisch das keine Fehlermeldung kam.

MfG
asfsafqetdg124
Unregistrierter




Beitrag asfsafqetdg124 Unregistrierter 00:31:56 31.08.2010   Titel:              Zitieren

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...
Destiniy
Mitglied

Benutzerprofil
Anmeldungsdatum: 24.09.2007
Beiträge: 403
Beitrag Destiniy Mitglied 10:33:01 31.08.2010   Titel:              Zitieren

Hallo,

du hattest recht es kam eine Fehlermeldung, ich hab sie nur nicht gesehen da die Java Konsole nicht aufging

MfG


Zuletzt bearbeitet von Destiniy am 10:51:18 01.09.2010, insgesamt 1-mal bearbeitet
Destiniy
Mitglied

Benutzerprofil
Anmeldungsdatum: 24.09.2007
Beiträge: 403
Beitrag Destiniy Mitglied 10:55:23 01.09.2010   Titel:              Zitieren

einfacher ist es natürlich alle Funktionen durch implements hinzuzufügen:

Java Code:
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
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
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;

import TestPackage.ITest;
import TestPackage.TestEnum;

public class TestApplet extends Applet implements ActionListener, ITest
{
    private static final long serialVersionUID = 1L;

    Button okButton;
    Button wrongButton;
    TextField nameField;
    CheckboxGroup radioGroup;
    Checkbox radio1;
    Checkbox radio2;
    Checkbox radio3;

    public String getAppletInfo()
    {
        return "TestApplet Version 1.0.0";
    }
   
    void ResultHandlerTestCallback(TestEnum myenum,Vector<byte[]> vrgubData)
    {
        nameField.setText("Read");
        repaint();
    }
   
    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
   
}
}
Java Code:
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
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;

import TestPackage.ITest;
import TestPackage.TestEnum;

public class TestApplet extends Applet implements ActionListener, ITest
{
private static final long serialVersionUID = 1L;

Button okButton;
Button wrongButton;
TextField nameField;
CheckboxGroup radioGroup;
Checkbox radio1;
Checkbox radio2;
Checkbox radio3;

public String getAppletInfo()
{
return "TestApplet Version 1.0.0";
}

void ResultHandlerTestCallback(TestEnum myenum,Vector<byte[]> vrgubData)
{
nameField.setText("Read");
repaint();
}

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

}
}
Java Code:
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
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;

import TestPackage.ITest;
import TestPackage.TestEnum;

public class TestApplet extends Applet implements ActionListener, ITest
{
    private static final long serialVersionUID = 1L;

    Button okButton;
    Button wrongButton;
    TextField nameField;
    CheckboxGroup radioGroup;
    Checkbox radio1;
    Checkbox radio2;
    Checkbox radio3;

    public String getAppletInfo()
    {
        return "TestApplet Version 1.0.0";
    }
   
    void ResultHandlerTestCallback(TestEnum myenum,Vector<byte[]> vrgubData)
    {
        nameField.setText("Read");
        repaint();
    }
   
    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
   
}
}
C/C++ Forum :: Java ::  Java Applet hat Probleme mit Callback ***gelöst***   Auf Beitrag antworten

Zeige alle Beiträge auf einer Seite




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.

Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme

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.