ramya narayanan

Ranch Hand
+ Follow
since Oct 06, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 ramya narayanan

Hi all,

When i'm trying to connect to www.javaranch.com, through TCP mon which is a utility to monitor the data flowing through a TCP connection, it is not working properly.

I want to know the server port of www.javaranch.com .

Kind regards
Ever-helping ranchers,
I've got a doubt on calculating window-size-ratio's accordance between panels.
I want to know generally how will they implement this or any useful links or tutorials on this.

I will try to picturise the scenario before you!

Consider there are two Windows Main Window & Child Window
Both of these windows extends Panel class




We need to calculate window-size ratio's between these Main Panel & Child Panel!
Why?
Follow me!

Main Panels features
1) These main panel is used to represent some time-duration say 10 min or 20 min. It is represented numerically .
But at any point of time the main panel will display 10 time-durations. If we scroll also, it will display 10 time-durations.
2) It has a vertical & horizontal scroll bar to scroll through these time-durations.
3) These main panel implements adjustmentlistener

Child Panel features
1) These child panel represents the main window components i.e. time-duration in rectangular bars.
2) It also has another broader white-color rectangle, which is used to move over these bars whose height we need to calculate. (rectheight)
Generally the 10 time-durations at any time in main panel, should be represented in Child Panel by covering those bars with these white-color rectangle.

Here p.x --> Point.x
p.y ---> Point.y

So now comes the crux of my question.
My child panel has a reference to the main panel, through which it can call the main panel's adjustment-listener's methods.
1) When we vertically scroll the time-duration in Main Window , (say at that time 5-15 time-duration representation) , the corresponding 10 time-durations in ChildPanel (which are represented in bars) should get highlighted in white-color rectangle(which moves over all the bars).

2) Also when I'm moving my white-color-rectangle over the bars in child panel, the corresponding time-duration only should get highlighted(should come in main window) in main panel.

For this size-accordance should be calculated between main panel & child panel right?
How that can be done!

I want to know generally how will they do this or atleast some idea or links is suffice!


My Best Regards!






15 years ago
It's ok Maneesh.
I'm able to manage.
Meanwhile thanks for your help upto this stage.
It was very useful.
Regards
15 years ago

Post SSCCE code like I mentioned in my previous post



SSCCE code means the code-snippets right(after going through the link you've given)

Regards
15 years ago
Dear Maneesh,
Now one of the challenge is surmounted.
Actually the requirement is
when we increase the panel width, the size of the bar ideally should not change(in which I confused myself & you. Sorry for that)

The barsize should change only when we re-size the height of the panel. So for that to happen I modified a previous line .



Now whenever I decrease or increase the height, the bar & the line gets aligned properly.

1) Now the other challenge to surmount is
When I'm maximizing the window height, the navigation-rectangle(white-color) cannot propagate further upto some default height i.e. it is not able to propagate over all the bars in this new height.
We need to enhance this code in paint method



I tried it out with

But no result.

Anyhow we'll see!

Regards
15 years ago
I've sent you the mail maneesh & please acknowledge.
Regards
15 years ago
Dear Maneesh,
I've sent you a private message.
Regards
15 years ago
Dear Maneesh,
Warm good morning & thanks for your reply.
I would like to clarify certain points you've made.

1) You are increasing the height and expect the width to be affected? Is there a typo or a misunderstanding here?



No there is no type or misunderstanding here maneesh.
What the challenge is
1)Initially there will be rectangle bars along a line in a panel in a default window size.
2) Now I'm reducing the size of the panel by clicking & dragging up the window. (through the window bottom )
3) Ideally the bar & the line, should understand that the height of the panel is reduced & should align itself in congruence with the new size of the panel which is not happening now!

To put it succinctly, when I re-size the window width, the bar & the line understands it & respond accordingly but whereas when I re-size the window height (suppose reduce the window height), the bar & line is not responding according to the new size.

Check out the API for Graphics#drawLine, especially the part what the 4 parameters mean ;)





so


will draw a line between the points(10,10) and (10,width) here width is the new panel width size.

Maneesh, I also tried with
where height=this.getHeight() of the panel but that keeps on increasing the height of the line when we increase or decrease the height.

Also we cannot do
as that would draw a slanting line between the width & height which we don't need.

How can we proceed further Maneesh?

MyBestRegards

15 years ago
As usual thanks Campbell!
Regards
Note: Wondering how you are knowing even the trivia of details. That's why you've been a bartender.

15 years ago
Dear Maneesh,
First of all I thank you for sharing your valuable expertise & understanding at this time.

You are almost there.
Instead if hard coding the values (210), pick out the width of the panel at runtime by calling getWidth() in your paint method.


So now this is my updated paint() method.


So after this, whenever I maximize or drag the window size, the width of the bar gets adjusted. That's part of my requirement & I thank you maneesh for this.

But still three challenges are there to surmount:

1) When I increase or decrease the width(by clicking & dragging the window right hand side), the width of the bar is re-sized properly. But when I increase or decrease the height(by clicking & dragging the window up), the width of the bar is not re-sizing.

2)The line along which the bar is positioned

In my case I'm a painting a rectangle bar along a line(using g.drawLine) inside the panel....


is not re-sizing when i resize the window. I mean I'm not able to find the end of the line when I re-size the window & I need to manually once again drag down the window to see other bars & end of this line.
Suppose when I reduce the size of the panel, by dragging up the window, this line & other bars are not aligning to the new size whereas the width is getting reduced.

3) I've a navigation rectangle which is white in color , which is used to cloud over the bars so as to help in navigation.
The code for which is written inside paint() method itself.

Consider there are some 12 bars totally. These navigation-rectangle will be implemented to cloud or cover over 6 bars at any time.
So when we are re-sizing ,the size of these navigation-rectangle should also change & they should be clouding or covering over the bars, which is not happening under current circumstances

As usual, eagerly looking forward for your valuable piece of information in harnessing this challenge.

MyBestRegards

15 years ago
Dear noble ranchers,
We know we can get the date from the Calendar using the method



Actually it is leading to ambiguity as I think it should have been getDate() method.
What do you think?
Regards
15 years ago

A combination of BorderLayout and no explicitly defined preferred size usually gives the desired results.


That's correct maneesh & thanks for that.

In my case I'm a painting a rectangle bar along a line(using g.drawLine) inside the panel, whose size should also change when I do
mouse drag or mouse click, which is not happening now(which was not happening earlier also & this is the crux of the challenge) but the panel's size is resizing when I maximize the window(with your advice). Note my panel implements MouseListener & MouseMotionListener.


Now we need to find out how the bars(components) size can be resized dynamically once we resize the window or drag the window to a new size.

MyBestRegards


15 years ago
First of all thanks maneesh for your understanding of the challenge.
I'm using flowlayout & adding components using setPreferredsize methods.
Note I'm using Jframe & Jpanel.
My panel is contained in JFrame & when I maximize the window the component is not resizing properly.

Consider




Since I'm working on a support project, I cannot change the classes i.e I mean JFrame & JPanel.
Regards



15 years ago
Dear All,
In my application I'm using GUI components inside a window & when I maximize the window , the GUI components does not respond to resizing the window.
What I should do ?
Any useful links or ideas or generally how they will solve this is suffice?
Regards
15 years ago