FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programming-Exercises/SimpleGui1B.java at master · RoyTien/Java-Programming-Exercises · GitHub
RoyTien
/
Java-Programming-Exercises
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programming-Exercises
/
SimpleGui1B.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (34 loc) · 955 Bytes
Breadcrumbs
Java-Programming-Exercises
/
SimpleGui1B.java
Copy path
File metadata and controls
41 lines (34 loc) · 955 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import
javax
.
swing
.*;
import
java
.
awt
.
event
.*;
import
java
.
awt
.*;
public
class
SimpleGui1B
implements
ActionListener
{
//JButton button;
public
static
void
main
(
String
[]
args
){
SimpleGui1B
gui
=
new
SimpleGui1B
();
//gui.go();
}
/*
public void go(){
JFrame frame = new JFrame();
button = new JButton("click me");
button.addActionListener(this);
frame.getContentPane().add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event){
button.setText("I've been clicked");
}
*/
public
void
paintComponent
(
Graphics
g
){
//g.setColor(Color.blue);
g
.
fillRect
(
0
,
0
,
this
.
getWidth
(),
this
.
getHeight
());
int
red
= (
int
)(
Math
.
random
()*
255
);
int
green
= (
int
)(
Math
.
random
()*
255
);
int
blue
= (
int
)(
Math
.
random
()*
255
);
Color
randomColor
=
new
Color
(
red
,
green
,
blue
);
g
.
setColor
(
randomColor
);
g
.
fillOval
(
70
,
70
,
100
,
100
);
}
}
Back
|
FazBrowse Home
|
New Git URL