1,105,456 Community Members

Any projects for the java beginner?

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
hfx642
Posting Pro
515 posts since Nov 2009
Reputation Points: 164 [?]
Q&As Helped to Solve: 105 [?]
Skill Endorsements: 1 [?]
 
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.

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
stultuske
Posting Expert
5,326 posts since Jan 2007
Reputation Points: 938 [?]
Q&As Helped to Solve: 776 [?]
Skill Endorsements: 35 [?]
Featured
 
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.

Member Avatar
thines01
Postaholic
2,420 posts since Oct 2009
Reputation Points: 389 [?]
Q&As Helped to Solve: 413 [?]
Skill Endorsements: 10 [?]
Team Colleague
Featured
 
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.

Member Avatar
stultuske
Posting Expert
5,326 posts since Jan 2007
Reputation Points: 938 [?]
Q&As Helped to Solve: 776 [?]
Skill Endorsements: 35 [?]
Featured
 
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.

Member Avatar
JamesCherrill
... trying to help
10,386 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,752 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

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

Member Avatar
~s.o.s~
Failure as a human
10,399 posts since Jun 2006
Reputation Points: 2,496 [?]
Q&As Helped to Solve: 992 [?]
Skill Endorsements: 72 [?]
Administrator
Featured
 
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.

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
stultuske
Posting Expert
5,326 posts since Jan 2007
Reputation Points: 938 [?]
Q&As Helped to Solve: 776 [?]
Skill Endorsements: 35 [?]
Featured
 
0
 

JPanel myPanel = new JPanel();

onButtonPressed
myPanel = new JPanel();

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

Member Avatar
JamesCherrill
... trying to help
10,386 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,752 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
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)

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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
}
}
Member Avatar
JamesCherrill
... trying to help
10,386 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,752 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
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...

Member Avatar
thines01
Postaholic
2,420 posts since Oct 2009
Reputation Points: 389 [?]
Q&As Helped to Solve: 413 [?]
Skill Endorsements: 10 [?]
Team Colleague
Featured
 
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.

Member Avatar
tungnk1993
Junior Poster in Training
95 posts since May 2010
Reputation Points: -4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
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

Member Avatar
jackbauer24
Posting Whiz in Training
243 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: