1 | !636 |
2 | !actionListener { |
3 | |
4 | static boolean showPicture = true; // global switch. if false, you get the normal text display instead of the smiley |
5 | |
6 | static L<S> emotions = litlist( |
7 | "#1001283", "happy", |
8 | "#1001284", "unhappy", |
9 | "#1001285", "oh", |
10 | "#1001286", "bored", |
11 | "#1001287", "wide mouth"); |
12 | |
13 | static int borderColor = 0xFFFFFFFF; |
14 | static S lastEmotion; |
15 | static JFrame emo_frame; |
16 | static ImageSurface img; |
17 | static JTextField textField; |
18 | |
19 | static void emo(S emotion) { |
20 | if (!showPicture) return; |
21 | if (emo_frame == null) { |
22 | emo_frame = new JFrame("Leo vx"); |
23 | |
24 | img = new ImageSurface(); |
25 | img.setImage(loadImage(emotions.get(0))); |
26 | textField = new JTextField(); |
27 | textField.addActionListener(actionListener { |
28 | textField.selectAll(); |
29 | handleText(textField.getText()); |
30 | }); |
31 | |
32 | emo_frame.getContentPane().setLayout(new BorderLayout); |
33 | emo_frame.getContentPane().add(BorderLayout.CENTER, img); |
34 | emo_frame.getContentPane().add(BorderLayout.SOUTH, textField); |
35 | |
36 | emo_frame.pack(); |
37 | centerFrame(emo_frame); |
38 | emo_frame.setVisible(true); |
39 | } |
40 | int i; |
41 | for (i = 0; i < emotions.size(); i += 2) |
42 | if (emotions.get(i+1).equalsIgnoreCase(emotion)) |
43 | break; |
44 | if (i >= emotions.size()) { |
45 | print("Emotion not found: " + emotion); |
46 | // use the last one from the list as default |
47 | i -= 2; |
48 | } |
49 | lastEmotion = emotions.get(i+1); |
50 | img.setImage(loadImage(emotions.get(i))); |
51 | } |
52 | |
53 | static void setBorderColor(int color) { |
54 | } |
55 | |
56 | static void happy() { emo("happy"); } |
57 | static void unhappy() { emo("unhappy"); } |
58 | static void oh() { emo("oh"); } |
59 | static void bored() { emo("bored"); } |
60 | static void wideMouth() { emo("wide mouth"); } |
61 | |
62 | static void disappear() { |
63 | happy(); |
64 | if (emo_frame != null) { |
65 | emo_frame.dispose(); |
66 | emo_frame = null; |
67 | } |
68 | swingLater(1000, runnable { |
69 | img.setImage((RGBImage) null); |
70 | swingLater(1000, runnable { |
71 | System.exit(0); |
72 | }); |
73 | }); |
74 | } |
Began life as a copy of #1001293
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001309 |
Snippet name: | Desktop: Leo's emoticons (include) |
Eternal ID of this version: | #1001309/1 |
Text MD5: | db43665b995a23e133537bcf49163400 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-09 17:24:19 |
Source code size: | 2143 bytes / 74 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 489 / 669 |
Referenced in: | [show references] |