summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java
diff options
context:
space:
mode:
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java
new file mode 100644
index 0000000..0e8ba2b
--- /dev/null
+++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java
@@ -0,0 +1,49 @@
+/* Listing2502.java */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class Listing2502
+extends Frame
+{
+ public static void main(String[] args)
+ {
+ Listing2502 wnd = new Listing2502();
+ }
+
+ public Listing2502()
+ {
+ super("Systemfarben");
+ setBackground(SystemColor.desktop);
+ setSize(200,100);
+ setVisible(true);
+ addWindowListener(new WindowClosingAdapter(true));
+ }
+
+ public void paint(Graphics g)
+ {
+ g.setFont(new Font("Serif",Font.PLAIN,36));
+ FontMetrics fm = g.getFontMetrics();
+ int sheight = fm.getHeight();
+ int curx = 10;
+ int cury = getInsets().top + 10;
+ //"Tag" in normaler Textfarbe
+ int swidth = fm.stringWidth("Tag");
+ g.setColor(SystemColor.text);
+ g.fillRect(curx,cury,swidth,sheight);
+ g.setColor(SystemColor.textText);
+ g.drawString("Tag",curx,cury+fm.getAscent());
+ //"&" in Blau auf normalem Hintergrund
+ curx += swidth + 5;
+ swidth = fm.stringWidth("&");
+ g.setColor(Color.blue);
+ g.drawString("&",curx,cury+fm.getAscent());
+ //"Nacht" in hervorgehobener Textfarbe
+ curx += swidth + 5;
+ swidth = fm.stringWidth("Nacht");
+ g.setColor(SystemColor.textHighlight);
+ g.fillRect(curx,cury,swidth,sheight);
+ g.setColor(SystemColor.textHighlightText);
+ g.drawString("Nacht",curx,cury+fm.getAscent());
+ }
+} \ No newline at end of file