01: // Copyright (c) 2000, 2005 BlueJ Group, Deakin University
02: //
03: // This software is made available under the terms of the "MIT License"
04: // A copy of this license is included with this source distribution
05: // in "license.txt" and is also available at:
06: // http://www.opensource.org/licenses/mit-license.html
07: // Any queries should be directed to Michael Kolling mik@bluej.org
08:
09: package bluej.editor.moe;
10:
11: import bluej.Config;
12: import java.awt.*; // New Event model
13: import javax.swing.*;
14:
15: /**
16: ** @author Michael Kolling
17: **
18: **/
19:
20: public final class StatusLabel extends JLabel {
21: // ---------------- CONSTANTS -----------------
22:
23: public static Font statusFont = new Font("SansSerif", Font.BOLD
24: | Font.ITALIC, 11);
25:
26: // current save state
27: static final int READONLY = 0;
28: static final int SAVED = 1;
29: static final int CHANGED = 2;
30:
31: private final String[] stateString = {
32: Config.getString("editor.state.readOnly"),
33: Config.getString("editor.state.saved"),
34: Config.getString("editor.state.changed") };
35:
36: // ------------ INSTANCE VARIABLES ------------
37:
38: private int state;
39:
40: // -------------- CONSTRUCTORS ----------------
41:
42: public StatusLabel(int initialState) {
43: super ("", JLabel.CENTER);
44: setText(stateString[initialState]);
45: setFont(statusFont);
46: setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
47: state = initialState;
48: }
49:
50: // ------------- PUBLIC METHODS ---------------
51:
52: public boolean isSaved() {
53: return (state != CHANGED);
54: }
55:
56: public boolean isChanged() {
57: return (state == CHANGED);
58: }
59:
60: public boolean isReadOnly() {
61: return (state == READONLY);
62: }
63:
64: public void setState(int newState) {
65: state = newState;
66: setText(stateString[state]);
67: }
68:
69: } // end class StatusLabel
|