creating a component somewhere else.

A

atilagunes

Hi,

i'll try to tell you what i need to learn..

I have a special panel class extends from JPanel, i'm calling this
class from my application class which runs main JFrame and i send image
list to my panel class. it creates buttons with images as icon and it
assings handler for mouse clicking to these buttons.. i want to write a
code for this listener. when pushing to one of these buttons, it will
create a jInternalFrame and image will be showed as thumpnails in this
jInternalFrame. .. this JInternal frame will be out of bounds of JPanel
and will be undependent from Jpanel. it will belong to main JFrame..

i wrote a method in main application to create JInternalFrame but i
cant reach it from JPanel class.. what should i do, can you give me
some hints ? at least, can you write some words for googling..

Thanks in advance.
Atila Gunes
 
O

Oliver Wong

Hi,

i'll try to tell you what i need to learn..

I have a special panel class extends from JPanel, i'm calling this
class from my application class which runs main JFrame and i send image
list to my panel class. it creates buttons with images as icon and it
assings handler for mouse clicking to these buttons.. i want to write a
code for this listener. when pushing to one of these buttons, it will
create a jInternalFrame and image will be showed as thumpnails in this
jInternalFrame. .. this JInternal frame will be out of bounds of JPanel
and will be undependent from Jpanel. it will belong to main JFrame..

i wrote a method in main application to create JInternalFrame but i
cant reach it from JPanel class.. what should i do, can you give me
some hints ? at least, can you write some words for googling..

If I understand correctly, you want to create an instance of
JInternalFrame (call it I for Internal) in your action listener (call it L
for Listener), and then have this instance be visible from some JFrame (call
it F for Frame) than the listener L.

If you can pass an instance of F to L, then you could add a field to F
to store the instance of I, and add some setters and getters. Then, when the
listener code in L executes, it calls the setter on F to pass a reference to
I.

<pseudoCode>
class F extends JFrame {
private JInternalFrame myInternalFrame;

public void setInternalFrame(JInternalFrame value) {
this.myInternalFrame = value;
}
}

class L implements SomeListener {
public final F myF;

public L(F myF) {
this.myF = myF;
}

public void fireEvent() {
myF.setInternalFrame(new JInternalFrame());
}
}
</pseudoCode>

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top