Created
November 13, 2014 20:36
-
-
Save lukaspj/7e86ffb4f528e52ed8fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import javax.swing.event.ChangeListener; | |
import javax.swing.event.ChangeEvent; | |
import java.awt.*; | |
import javax.swing.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
/** | |
* Lav en beskrivelse af klassen RoadGUI her. | |
* | |
* @author (dit navn her) | |
* @version (versions nummer eller dato her) | |
*/ | |
public class RoadGUI | |
{ | |
public static JFrame frame = new JFrame(); | |
private ArrayList<ChangeListener> listeners; | |
public static Counter counter = new Counter(0); | |
public static JTextArea skærm = new JTextArea("0 frie P-pladser"); | |
public RoadGUI(Counter c){ | |
this.counter = c; | |
} | |
public static ActionListener createButtonListener() | |
{ | |
return new ChangeListener() { | |
public void stateChanged(ChangeEvent event) | |
{ | |
skærm.setText(String.valueOf(counter.getValue()) + " P-pladser"); | |
frame.repaint(); | |
} | |
}; | |
} | |
public static void main(String[] args) | |
{ | |
frame.setLayout(new FlowLayout()); | |
frame.add(skærm); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.pack(); | |
frame.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment