Kristjan Toots

Ranch Hand
+ Follow
since Jun 03, 2011
Kristjan likes ...
Eclipse IDE Firefox Browser Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kristjan Toots

Someone taught me that when a method is pure, meaning that it doesn't depend on some external state it's a candidate for being static.



I've found this article as-well: StackOverflow: When to use static methods
7 years ago
Thank you, Rob Camick, your responses are always useful.

I have an understanding that JOptionPane is used to create simple quick & easy modal dialog's. I would really like to know why one would choose one over another in this case. Which one is more preferable to use: JOptionPane vs. JDialog

I am asking this because I would like to know how one should do this correctly.

8 years ago
Hello fellow Ranchers.
I'm working on a personal project where I'm trying to create simple swing/database application. I am certainly not professional developer and I do not even consider myself as a moderate at this point of time. Therefore I turn to community to ask how should I approach this kind of problem.

I imagine alot of dialog boxes jumping around to fetch user input. Would need to present labels, textfields, passwordfields, combobxes, checkboxes etc in various dialog windows.
For example: creating the database firsthand, creating the first admin account, adding users, changing user accounts etc.



Can I somehow use OptionPane to present all those dialog's?
I suppose that creating separate classes which extends JDialog for every dialog I need wouldn't be optimal?

I'm not looking for full solution but rather I would like to know where to look for. Or how should I think about this problem.

Thank you.
8 years ago
Thank you for your response Paul.
I am able to access JTextFields when I am dealing with single component. I'd do something like this. .



But when I have to add more components dynamically it gets tricky for me. I'll try to make an simple analog example. I'll use code found in stackoverflow.

The analog of the problem is that when I have dynamically added 5 JLabels saying "Bla". How would I approach when I need to say to the third JLabel object .setText("Changing third JLabel text");


8 years ago
Hello.
I'm trying to create simple swing application by using MVC pattern. I had it all figured out until stumbled upon problem where I had to add another panels dynamically on runtime.

I've created frame where I applied BoxLayout aligned to Y-axis. In that layout I have two different panels. First one of them I use to collect data from 2 JTextfields and second one to display something else in JTable.



Now let's say that until certain condition is met every time when user submits (click's the button) I add dynamically another JPanel identical to the first one except the button.



So far I have defined components private and used getter/setters in Controller class and it makes everything even more confusing.

What I can't figure out is how I dynamically add another JPanels and still be able to access those JTextfield values.

Thank you.
8 years ago
Paul Clapham, thank you for your time and effort.
I don't know why I overlooked SimpleDateFormat, maybe because I was so excited doing something my own instead...

I looked into it, and with only couple of minutes I was able to create the code needed to produce the current date, formatting following the very same signature of genitive form.
I am certain that reversing this step can't be much more difficult.

Since now we know that I tried to re-invent the bicycle and the code i submitted doesn't matter much anymore, still everybody are welcomed to come criticise my code.
9 years ago
Hello fellow Ranchers!
I am self-learnt "pre-junior" programmer who hasn't done much except some console practice exercises from Java books. I tend to be quite strict about my code and I definitely do not want to pick up some bad habits along the way.
I like constructive criticism because only then I'm able to learn from my mistakes.
If you have some time, I would welcome you to take a quick look on my code.

Thank you. : )

TASK: I have a string where I get a date in the following format: "Since 21.november 2011" and it applyes for the whole week. Next week it will be: "Since 28.november 2011".
I have to get the week number out of this data.



9 years ago
Hello.
Since I know I'm going to have a lot of questions before I ever finish my project I kept this topic subject generic, so I can post my future questions here as well.
I am working on my project, which is available here Guidance appreciated: Designing a board game
I've started this project over and over couple of times now. Since I'm quite inexperienced I think I have been taking too big bites and that's the reason for all my troubles.

Quick introduction, to save you from reading my other thread:
I am trying to "computerize" a board game with different monsters and objects which reacts to one another on the battlefield. Took, Stephan van Hulst, advice and I'm trying to get the basics done. Representing the game in it's simplest form in some console representation before going to mess around with the GUI.

What I have so far:
Character class with fields for name, id and co-ordinates in the field
Battlefield class which is responsible for building an array (trying to represent the grid) and printing it out to the console like: [][][]
Controller class which should be responsible for adding different elements to the grid and moving them around in the field.

Now I have stumbled upon some questions I would like to clarify before going any further.

* I have a Game class to use it as a point where I kick everything off. I have something like this in there. For some reason, approaching like this doesn't feel right. Should I solve this somehow differently?

* I define some standard parameters for player in the Character class constructor. My Field and Controller class constructors are empty. Should I try to call some methods or to set something in them?
Example:
* At the moment I am using an array int[][] to represent the battlefield [][][] format. Where should I define this array and how should I go about doing different things with it (ex. adding new players to it). I have defined it in the Field class, as a static array.
To add players I grab the array reference by getter and pass it to the method in the Controller class which doesn't return anything. Am I going to the right direction by passing it around? Should I approach this somehow differently?


Thank for your time.
9 years ago
Hello,
First of all, before I continue I must pay my gratitude to Stephan van Hulst, I shall thank you for your time and your useful reply.

I have tried couple of times, all the time I fell into some stupid traps. I don't mean to say that I haven't got anything done. Suppose I tend to make things more complicated than they have to be, I'm trying to make everything perfect as possible on my first try and I overwhelm myself.
After couple of hours I'm more or less at the same place where I started, just have re-writed couple of methods and staring stupidly at the screen.

I feel that my personality doesn't allow me to come to the forums and ask every single question I have, it's just not me. I'm looking for someone who can guide me, someone to talk to, someone who is willing to spare some of he's/she's free time to point me to the correct direction - like a programming friend.

Maybe there is someone out there who feels that he/she might want to go trough something like this.

Thank you Javaranch. : )
9 years ago
Hello.
I am a self-learned (beginner) programmer who don't have a lot of experience but I'm working hard to get bit better every day. I am familiar with Java SE and currently going through Core Java series & learnnowjava materials.

This project will become my thesis what I do have to present in April 2012. (Background info: programming & software design is not a part of my curriculum).

What I am trying to achieve:
We have a board game I like to play with my friends. It's a grid based battleground, where you can move your characters around and do different stuff with different objects/monsters.
At the moment we're using a white-board as our field, but I would like to replace it with 17" touchscreen.

At this planning phase, I look up to fellow Javaranchers who could give out basic guidelines, directions, pointers and things to look for. How should I approach?

I have drawn a little picture to explain my final goal. I hope, it contains enough information for the start.

Thank you.

9 years ago
The error is quite straightforward: Insert another "}" to complete class body.
You have to have brackets in pairs - if there is "{" you'll need "}" as-well to end the block.

The bracket you have in the end will pair up with the main "{". Insert another one to pair up with the class "{".
9 years ago

Parveen thakur wrote:


but i till not getting any result and idea ?


Because you haven't tried hard enough.
At least I haven't seen any effort in this topic except for asking already built code.

Like I said, start from beginning and with very simple tasks - with a couple of elements only.
9 years ago

Ketan Borkar wrote:try miglayout it's very easy to use and very flexible


Like Ketan said, you could try out MigLayout

I would suggest trying to achieve your goal on a smaller scale. There is absolutely no point of rewriting your GUI to fit your requirements without understanding how different layouts work. You would end up frustrated and disappointed.

Instead you could divide your goal to a smaller and do-able steps. You could try out different layouts on a single button. Then you could add few components here and there to try them out. Afterwards you could go on and try to preserve the look of a group of elements (like: login screen for example).

But unfortunately there is always a one prerequisite: You would have to have the will to learn...
9 years ago
There has been some discussion on that topic: https://coderanch.com/t/546694/Ranch-Office/Reviews-http-www-learnnowjava-com
EDIT: Sorry, I kind of missed the previous poster.
9 years ago