Click to See Complete Forum and Search --> : Graphics in Java.URGENT...
Jitendran
March 15th, 1999, 10:03 PM
Hi All,
I am using Jdk 1.1.6 on Solaris V2.6
My problem is I am drawing graphics using java on a window. I am drawing
triangles and rectangles randomly. Now when i execute this the window on
which i am drawing pops up. I am executing this from a frame. that is when i
click on the menu item inside the frame this window pops up. Now I want to
actually go back to the frame in between. What happens is when this window
gets activated it takes all the controls. I tried using FocusListeners but they
are not working.
Can anyone say me how to go about it. Its urgent and i request u all to
give suggestions.
Bye,
Jitu.
thiru
March 17th, 1999, 04:04 AM
Hi jitendran,
I have tried with some test code about ur problem.But it works fine for me on
windows95.if u need more help,pl rehrase ur question or send me the code.
Here is a part of it..
class Frame1 extends Frame
{
// controls added here
// inner class for events form menuitems
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == open)
open_Action(event);// open is a button to invoke the other frame
else if (object == OpenDilaog)
OpenDilaog_Action(event);// opendialog is a menuitem to invoke the other frame
}
}
void open_Action(java.awt.event.ActionEvent event)
{
// to do: code goes here.
Frame2 f = new Frame2();
f.setSize(200,200);
f.show();
f.repaint();
}
public static void main(String args[])
{
Frame1 f = new Frame1();
f.show();
}
void OpenDilaog_Action(java.awt.event.ActionEvent event)
{
// to do: code goes here.
Frame2 f = new Frame2();
f.setSize(200,200);
f.show();
f.repaint();
}
}// class Frame1 ends here
// another window(frame) where the rectangle is drawn
class Frame2 extends Frame
{
public void paint(Graphics g)
{
g.drawRect(100,100,20,20);
}
}
Jitu
March 17th, 1999, 02:04 PM
Dear Thiru,
Thanks for the prompt response. What u said is correct because the code which
I have written also works on Windows. The problem comes in Solaris. I suppose
Focus Listeners work in a hapazard manner on Solaris.
Regarding the question it is that i have a main frame(parent). In this frame
I have a menu on a menu bar. when i click the menu the graphics window pops up.
It is not a frame. It is a window. The reason why i needed a window is we don't
want the borders. In the case of a frame it is not possible to remove the
borders.
Currently I have deviced a solution. What i am doing now is on the right click of mouse i am calling back to so that i can go to the frame.
Bye,
Jitu.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.