hi all
my teacher asked me to write a program about any thing,, and i have no idea what to write about, so if you through some ideas to me, i'll be grateful :)
by the way, i'm a beginner
and the deadline is Wednesday, so i want to do a small one.
Printable View
hi all
my teacher asked me to write a program about any thing,, and i have no idea what to write about, so if you through some ideas to me, i'll be grateful :)
by the way, i'm a beginner
and the deadline is Wednesday, so i want to do a small one.
How about tic-tac-toe?
Its the first program I wrote in java.
i was looking about it but i found some complex code :(
do you have a simple one???
It's hard to say without knowing exactly what the content of your course is, and how complex the teacher expects it to be. If you want to go simple but a little challenging, you could try making a text-based tic-tac-toe game. If you need something even simpler, maybe a simple calculator. If you want something more complex, you could try making a simple calendar (appointment scheduler of some kind), or even go into GUIs (maybe UI-based tic-tac-toe).
PS: berkeleybross beat me to the tic-tac-toe idea. :(
you are right zack i should explain more
ok, we did the simple calculator in class so i can't do that, and one of the students did a scientific one, so i can't do that either. i think my teacher like any thing with graphics, and i'm pretty sure he wants me to use swing much.
A simple GUI program that also uses file in/out is a basic Notepad. If you wanted to get fancy, you could allow the user to change the font face/size of the window (just like in Windows Notepad).
Sorry, I'm not handing over any source code if thats what your asking.
I will, however, help you correct any source code you write or point you in the write direction.
Doing a swing tic-tac-toe would be fairly easy.
Simply make a JPanel for each square and use GridBagConstraints to position them in a frame.
Each panel should have a JLabel in it which will contain the players piece.
You can then add a mouse listener to each JPanel and change the value of its JLabel.
From there, its mostly the logic behind the game, checking for winning moves etc.
@zack: hehe You got ninja'd ;P
Berkeleybross
thank you guys for your help, i prefer the basic notepad but it looks difficult to me.
i have some questions, what should i use to get the inputs from the user?? text area??? or is there any thing else??
Frankly any project with a GUI does get a little challenging; but if you always do easy stuff you will never progress in the language.
Honestly, you could go with the tic-tac-toe pretty easily as berkeley told you exactly how to do it (except the game logic itself; but we can help you there as well).
As for the notepad, I don't do a lot of Swing myself (I do mostly Applets), but you're probably best off with TextField: How to Use Text Fields (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
Of course, as is standard, anyone feel free to correct me here. ;)
look here, these lessons are for total beginners and during the lessons you will implement a library where you can store books and persons, who has borrow the book.
thanks j2, i already did this ;)
My way sounds more difficult but i believe it will actually be easier.
If you use a JTextArea you'll run into a whole load of difficulties - documents, parsing etc
Using a JTextField will be easier than a JTextArea but will be just as difficult as my way. And I think it wont look as good... :P
Up to you, Ill try and help either way.
Although I would go with JLabels inside JPanels.
You can then make different coloured backgrounds for your squares :)
berkeleybross
i think JTextField is only to get single line???
Yup, but you could have a 3*3 grid of them, one for each square.
berkeleybross
sorry, could you please explain this a little bit more??
EBBOOO
Well, you could make nine JTextFields, and arrange them in a grid
Each TextField will only take one character, '-', 'X' or 'O'.Code:- - -
- - -
- - -
The user will have to select a TextField and then type in there character. However, you will have to parse the input to make sure it is only one character long, and that it is the users character.
Alternatively, you could have exactly the same layout, except using JLabels.
When a user clicks on a square, then the label will automatically change to their character.
Not sure if i can make it clearer than that :S
Or did i miss the point of your question?
Berkeleybross
actually i was talking about the notpad
i found something call JTextPane,, is that what i need?
You could use that but id stick with JTextArea.
It only allows one font, but its much easier to use.
You'll also want a JMenuBar with JMenuItems.
what if i want to choose the font what should i use???
sorry too many questions :S