Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Bouncing ball
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nouman.ashraf
Bouncing ball
Commits
e7b9ac28
Commit
e7b9ac28
authored
Mar 15, 2019
by
Dell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
message
parents
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
0 deletions
+111
-0
.classpath
.classpath
+6
-0
.gitignore
.gitignore
+1
-0
.project
.project
+17
-0
org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+11
-0
BouncingBall.java
src/BouncingBall.java
+76
-0
No files found.
.classpath
0 → 100644
View file @
e7b9ac28
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
/>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
.gitignore
0 → 100644
View file @
e7b9ac28
/bin/
.project
0 → 100644
View file @
e7b9ac28
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
project Ak
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
e7b9ac28
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
src/BouncingBall.java
0 → 100644
View file @
e7b9ac28
import
java.awt.*
;
import
javax.swing.*
;
public
class
BouncingBall
extends
JPanel
{
// Box height and width
int
w
;
int
h
;
// Ball Size
float
r
=
20
;
float
diameter
=
r
*
2
;
// Center of Call
float
X
=
r
+
50
;
float
Y
=
r
+
20
;
// Direction
float
dx
=
3
;
float
dy
=
3
;
public
BouncingBall
()
{
Thread
thread
=
new
Thread
()
{
public
void
run
()
{
while
(
true
)
{
w
=
getWidth
();
h
=
getHeight
();
X
=
X
+
dx
;
Y
=
Y
+
dy
;
if
(
X
-
r
<
0
)
{
dx
=
-
dx
;
X
=
r
;
}
else
if
(
X
+
r
>
w
)
{
dx
=
-
dx
;
X
=
w
-
r
;
}
if
(
Y
-
r
<
0
)
{
dy
=
-
dy
;
Y
=
r
;
}
else
if
(
Y
+
r
>
h
)
{
dy
=
-
dy
;
Y
=
h
-
r
;
}
repaint
();
try
{
Thread
.
sleep
(
50
);
}
catch
(
InterruptedException
ex
)
{
}
}
}
};
thread
.
start
();
}
public
void
paintComponent
(
Graphics
g
)
{
super
.
paintComponent
(
g
);
g
.
setColor
(
Color
.
BLUE
);
g
.
fillOval
((
int
)(
X
-
r
),
(
int
)(
Y
-
r
),
(
int
)
diameter
,
(
int
)
diameter
);
}
public
static
void
main
(
String
[]
args
)
{
JFrame
.
setDefaultLookAndFeelDecorated
(
true
);
JFrame
frame
=
new
JFrame
(
"Bouncing Ball"
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setSize
(
300
,
200
);
frame
.
setContentPane
(
new
BouncingBall
());
frame
.
setVisible
(
true
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment