For my master work, i need to implement a feedback system. The good thing is that what the programm do, does not need to interest, there are only 2 events where i must give the feedback when they occur.
user work something push the "save" Button and ...here comes my issue:
i need give a feedback about the number of his clicks. On the push "save" event it must happen: 1) update variable with click number 2) give a feedback
To get a idea, here the very simple simulation:
Code:
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.*;
import java.awt.image.ImageObserver;
public class fensterTest2 implements ActionListener{
JButton button;
private int anzahlLocClicks = 10;
private int anzahlGlobalClicks = 10;
private int prozentAnzeige;
public static void main(String args[]){
fensterTest2 gui = new fensterTest2();
gui.startEvent();
}
public void startEvent(){
JFrame displayFenster = new JFrame(); // hier definiere ich mein fenster, unten die eigenschaften
button = new JButton("Start Mein Event");
button.addActionListener(this); //registriere bei Button, werde in Liste aufgenommen ->
// Argument MUSS objekt Klasse die ActionListener implementiert
displayFenster.getContentPane().add(button);
displayFenster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
displayFenster.setSize(600,300);
displayFenster.setVisible(true);
}
public void actionPerformed(ActionEvent event){
button.setText("You are "+ prozentAnzeige + "% better as the Rest!!!!");
prozentAnzeige = (anzahlLocClicks*100)/anzahlGlobalClicks;
anzahlLocClicks++;
anzahlGlobalClicks = anzahlGlobalClicks+3;
button.revalidate();
}

