diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing2502.java | 49 |
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 |
