File tree Expand file tree Collapse file tree 3 files changed +42
-10
lines changed Expand file tree Collapse file tree 3 files changed +42
-10
lines changed Original file line number Diff line number Diff line change
1
+ package simplejavacalculator ;
2
+
3
+ import java .io .*;
4
+ import java .awt .image .BufferedImage ;
5
+ import javax .imageio .ImageIO ;
6
+ import java .awt .*;
7
+
8
+ /**
9
+ *This class will return an image
10
+ *from a binary data.
11
+ */
12
+ class BufferedImageCustom {
13
+ public Image imageReturn ()
14
+ throws IOException {
15
+ Image image ;
16
+
17
+ InputStream bis = getClass ().getResourceAsStream ("/icon/icon.png" );
18
+ BufferedImage bImage2 = ImageIO .read (bis );
19
+ image = bImage2 ;
20
+
21
+ return image ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change 17
17
package simplejavacalculator ;
18
18
19
19
public class SimpleJavaCalculator {
20
-
21
- public static void main (String [] args ) {
22
- UI uiCal = new UI ();
23
- uiCal .init ();
24
- }
25
-
20
+
21
+ public static void main (String [] args ) {
22
+ try {
23
+ UI uiCal = new UI ();
24
+ uiCal .init ();
25
+ }
26
+ catch (Exception e ) {
27
+ System .out .println (e .getMessage ());
28
+ }
29
+
30
+ }
26
31
}
Original file line number Diff line number Diff line change 29
29
import java .awt .Font ;
30
30
import javax .swing .Box ;
31
31
import javax .swing .BoxLayout ;
32
- import java . awt . Toolkit ;
32
+
33
33
import java .awt .Image ;
34
34
import javax .swing .ImageIcon ;
35
+ import java .io .*;
35
36
36
37
public class UI implements ActionListener {
37
38
@@ -58,12 +59,14 @@ public class UI implements ActionListener {
58
59
59
60
private final Font font ;
60
61
private final Font textFont ;
61
- ImageIcon image ;
62
+ private ImageIcon image ;
63
+ private BufferedImageCustom imageReturn ;
62
64
63
- public UI () {
65
+ public UI () throws IOException {
64
66
frame = new JFrame ("Calculator PH" );
65
67
66
- image = new ImageIcon ("icon/icon.png" );
68
+ imageReturn = new BufferedImageCustom ();
69
+ image = new ImageIcon (imageReturn .imageReturn ());
67
70
68
71
panel = new JPanel ();
69
72
panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
@@ -114,6 +117,7 @@ public void init() {
114
117
frame .setLocationRelativeTo (null );
115
118
frame .setResizable (false );
116
119
frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
120
+
117
121
frame .setIconImage (image .getImage ());
118
122
119
123
text .setFont (textFont );
You can’t perform that action at this time.
0 commit comments