0

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

9
Contributors
30
Replies
35
Views
5 Years
Discussion Span
Last Post by zeroliken
Featured Replies
  • 2

    [QUOTE=thines01;1760466]I know this sounds antiquated[/QUOTE] 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 … Read More

  • 1
    ~s.o.s~ 2,560   5 Years Ago

    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 … Read More

  • 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 … Read More

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.

0

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.

Edited by jackbauer24: n/a

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.

1

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.

Votes + Comments
20th century babies learn to walk just the same way as the third century babies :)
2

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.

1

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.

Votes + Comments
you make it sound like it's just a walk in the park ;)
0

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

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?

0

JPanel myPanel = new JPanel();

onButtonPressed
myPanel = new JPanel();

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

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?

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

0

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

Edited by jackbauer24: n/a

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

0

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.

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.

0

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.

1

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");

0

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);

Edited by jackbauer24: n/a

0

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?

0

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

0

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!

0

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

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.