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

Recommended Answers

All 30 Replies

Member Avatar for hfx642

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.

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.

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

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

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.

commented: 20th century babies learn to walk just the same way as the third century babies :) +14

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.

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

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.

commented: you make it sound like it's just a walk in the park ;) +8

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

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?

JPanel myPanel = new JPanel();

onButtonPressed
myPanel = new JPanel();

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

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)

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
}
}

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...

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.

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

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.

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

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

but my problem is:-
i want to view a specific panel with a button with cardLayout.
i know i need to use the show() method.
and all examples according to my requirements are too complicated.
so please help me.

I don't mean this in an unkind way, but zeroliken's reference is to a very simple example. You're not going to find anything easier.
But here (from memory, so maybe slight errors) is a very short crib sheet:
Create your Cards as ordinary JPanels with whatever content
Set the frame's layout manager to new CardLayout() Add your cards to the JFrame, giving each a name, eg frame.add(card1, "C1"); In your button's response handler show the appropriate card frame.getLayout().show(frame, "C2");

Yes! That is exactly what I meant. But is there a way that instead of a JFrame as the main pane, there is a JPanel like this? -

JPanel mainPanel = new JPanel();
frame.setContentPane(mainPanel);

Yes, put the cards in a JPanel and put that in the frame. That's exectly how zeroliken's reference does it. Maybe time to re-visit that?

Thanks! I came to my senses! Sorry for irritating ya! So, back to the main topic - any ideas?

Like I said before: Tic-tac-toe
If you want to get more serious the file manager suggestion is good too, in a very different way. Maybe do both!

Text adventure, nim, battleships, english->french translator

They are all common assignments.

My son has started working on...


GUI version of text adventure.

But he is going to be doing a smaller project regarding BufferedReader s and BufferedWriter s first.

Ok, as Thines01 said:-

or in an applet like at the link above.

My son has never made an applet. He never even knew command-line apps could be converted to applets. How to?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.