We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,344 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Any projects for the java beginner?

My ten year old has learnt quite a lot of java and wants a few BEGINNER projects. Any ideas?

9
Contributors
30
Replies
5 Days
Discussion Span
1 Year Ago
Last Updated
31
Views
jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

Okay...

Get your (son/daughter?) to write a control component.
It should have the following buttons; Stop, Rewind (or Previous), Play/Pause, Fast Forward (or Next), Record.
It should have a display panel above the buttons to display time.
There should be a toggle to display either Time Elasped, or Time Remaining.

The reason that I suggested this project is...
I plan on doing the same thing on my vacation (in two weeks).
I am willing (after my vacation, I'm not going to steal their work) to critique the work.

hfx642
Posting Pro
515 posts since Nov 2009
Reputation Points: 248
Solved Threads: 105
Skill Endorsements: 1

Son.

Thanks, but that is far too advanced for him. He knows all of this:-
Objects
Instance variables
Bit of swing File io
Threads and networking(well, a little)
and more...
He DOES NOT KNOW user io.

jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

user io is a lot easier to learn/code than File io

just let him take a look at the Scanner class and JOptionPane.

stultuske
Industrious Poster
4,379 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24

I know this sounds antiquated, but I learned a lot by writing a text adventure game -- like a Scott Adams text adventure game back in the early 1980s.

Something like that would expand his knowledge of user interaction and could be great for learning code re-use.

It could be done on the console or graphically or in an applet like at the link above.

thines01
Postaholic
Team Colleague
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7

I know this sounds antiquated

why would this sound antiquated?
no matter in what century they were born, all Olympic medal sprinters learned to crawl, then walk.

every one has to get to know the basics before going 'expert', so it's a good advice that 'll probably stay just that (good and solid advice) as long as people try to start learning java coding.

stultuske
Industrious Poster
4,379 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24

Tic-tac-toe - some Swing, some arrays, some logic... but nothing too hard.

JamesCherrill
... trying to help
Moderator
8,525 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30

I'd personally recommend a file/directory copy utility. This way, he'll get more acquainted with how the CLI clients work and get a taste of implementing a fun utility from scratch. The good thing is that this project can be beefed up if required by adding more options like the way a real copy command works. Bonus points for progress bar etc.

~s.o.s~
Failure as a human
Administrator
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 55

I gave him these ideas and here is his response.
7:30 pm : "Yay! Learnt Scanner!"
7:45 pm : Checked out the Scott Adams game
8:00 pm : Scott Adams--Hmm... how could I do that?
8:15 pm : tic-tac-toe:"EUREKA!!!! JLabels..."
8:30 pm : file copy-way too complicated

jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

Hey, not hijacking this thread, (my son's doubt) if a jframe's content pane is set to a jpanel and a button is pressed. When it is pressed, can a new panel be made in the button's code and the NEW panel be set as the jframe's content pane?

jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

JPanel myPanel = new JPanel();

onButtonPressed
myPanel = new JPanel();

something like that? seems possible to me, never actually coded it myself, though.

stultuske
Industrious Poster
4,379 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24

Hey, not hijacking this thread, (my son's doubt) if a jframe's content pane is set to a jpanel and a button is pressed. When it is pressed, can a new panel be made in the button's code and the NEW panel be set as the jframe's content pane?

Yes. But of you explain why, there may be a better approach (eg CardLayout)

JamesCherrill
... trying to help
Moderator
8,525 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30

no, this is what i meant:-

import java.io.*;
import java.awt.event.*;
public class --- implements Serializable, ActionListener {
JFrame frame;
public static void main(String[] args) {
new ---().go();
}
public void go() {
JPanel panelone = new JPanel();
frame = new JFrame("Double panel swing test");
frame.setContentPane(panelone);
JButton button = new JButton("Click me");
button.addActionListener(this);
panelone.add(button);
//other swing-related code...now for the actionPerformed()
}
public void actionPerformed(ActionEvent ev) {
//all...or...nothing...
JPanel panel2 = new JPanel();
frame.setContentPane(panel2);//THIS is what i meant
}
}
jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

Yes, I understood that. You skeleton code is OK. But if you want to switch between multiple sets of content in the same frame, there are Swing classes to handle that for you, that's all. It just depends on where you-re going next with this...

JamesCherrill
... trying to help
Moderator
8,525 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30

8:00 pm : Scott Adams--Hmm... how could I do that?

Rock on!

One of the great benefits of something like that is also USER RESPONSE.
People evaluate what the program does rather than how it is written.

I sometimes get more excitement out of the coolness factor of the code more than what the code produces.

Getting feedback from users will serve him well.

thines01
Postaholic
Team Colleague
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7

A simple hangman game should be easy enough :) Find some simple games which can keep him excited

tungnk1993
Junior Poster in Training
95 posts since May 2010
Reputation Points: 6
Solved Threads: 7
Skill Endorsements: 0

But if you want to switch between multiple sets of content in the same frame, there are Swing classes to handle that for you

import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Jpaneltest implements ActionListener {
JFrame frame;
JPanel panelone;
public static void main(String[] args) {
new Jpaneltest().go();
}
public void go() {
panelone = new JPanel();
frame = new JFrame("Double panel swing test");
frame.setContentPane(panelone);
JButton button = new JButton("Click me");
button.addActionListener(this);
panelone.add(button);
frame.setVisible(true);
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ev) {
    JPanel pe = new JPanel();
    frame.setContentPane(pe);
}
}

How?
When I tested my code, all that happened:-
1. Click the button.
2. Went out of the button.
3. It still looks as if it has just been clicked, nothing happens either.

jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

If you want to have multiple Jpanels and use a Button to show one at a time
the I think you should use CardLayout

zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14

can a cardLayout use a JButton instead of a JComboBox to navigate?

jackbauer24
Posting Whiz in Training
244 posts since Oct 2011
Reputation Points: 21
Solved Threads: 3
Skill Endorsements: 0

yes, here's a link for an example
http://www.javaswing.org/java-cardlayout.aspx

zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1136 seconds using 2.68MB