Help with GUI (calling one class from other class)

Hi everybody,
I am new at GUI and I need your help..
I have a JPanel, named "holdAll", layout of which is set to BorderLayout. I have implemented all other JPanels in different class files. For example, I have TopPanel, LeftPanel, etc. as shown below
LeftPanel myLeft = new LeftPanel();
holdAll.add(myLeft, BorderLayout.WEST);
RightPanel myRight = new RightPanel();
holdAll.add(myRight, BorderLayout.EAST);
TopPanel myTop = new TopPanel();
holdAll.add(myTop, BorderLayout.NORTH);
MiddlePanel myMiddle = new MiddlePanel();
holdAll.add(myMiddle, BorderLayout.CENTER);
BottomPanel myBottom = new BottomPanel();
holdAll.add(myBottom, BorderLayout.SOUTH);
That works well but I have difficulties in ActionListeners.. For example, in my TopPanel class I have the code below:
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnInsert) {
int returnVal = fc.showOpenDialog(fc);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
myImage newImage = new myImage(file);
Here, if I have upload new image, then I have to update the listImage in the LeftPanel class.. But, I could not access the lstImage object in the LeftPanel class from the actionListener event in the TopPanel class.
What should I do? Is my design poor?

public class TopPanel extends JPanel implements ActionListener { //it doesn't allow "extends JPanel, Observable"
JFileChooser fc;
JButton btnInsert;
JButton btnDelete;
public TopPanel() {
setLayout(new FlowLayout());
setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
btnInsert = new JButton("Insert");
btnDelete = new JButton("Delete");
JLabel myLabel = new JLabel(" Search : ");
JTextField txtSearch = new JTextField();
JToolBar searchToolBar = new JToolBar();
fc = new JFileChooser();
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnInsert) {
int returnVal = fc.showOpenDialog(fc);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
*//Here I want to send fc.GetName() to the JList in the LeftPanel*
my LeftPanel class is below:
public class LeftPanel extends JPanel{
public LeftPanel(){
this.setLayout(new BorderLayout());
setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
JPanel pnlButtons = new JPanel();
JButton btnName = new JButton("Name");
JButton btnSize = new JButton("Size");
JButton btnDate = new JButton("Date");
JPanel pnlImage = new JPanel();
JList lstImage = new JList();
pnlImage.add(new JScrollPane(lstImage));
add(pnlButtons, BorderLayout.NORTH);
add(pnlImage, BorderLayout.CENTER);
Is there any simple way?

Similar Messages

  • Calling one component from other

       I want to call a portal component,with in the event handling routine of cellClick.
    Actually what I need is,in cellClickEvent method,I need to store the clicked value in session and then redirect it to another component based on the clicked value.
    Can any one help me in achieving that?
              Thanks in Advance

    Hi Santhosh,
    You can do that using the EPCF service provided by the Portal.EFCF is used to communicate between Iviews and pass data between them.Exactly what you need.
    Please reward points, if helpfull.

  • I lost my ipod I really need help to find it. Im from other country and i cant buy another one. Is not connected to internet

    I lost my ipod I really need help to find it. Im from other country and i cant buy another one. Is not connected to internet

    There is nothing anyone can do.
    You will have to keep looking for it

  • Canu00B4t call an EJB from other EJB

    Hi developers,
    I need do the next task :
    I have a EJB in an EAR and i need call some functionality from other EJB in diferent EAR , when execute the code show the next message error:
    java.rmi.RemoteException: Exception in method generaMDMOutput.
         at Code))
         at Compiled Code))
         at Code))
         at Code))
         at Code))
         at Code))
         at Method)
         at Code))
         at Code))
         at Code))
    Caused by: java.lang.ClassCastException:
         ... 11 more
    the code to invoke the EJB is the next:
    ctx = new InitialContext();
    TestEJBLocalHome home = (TestEJBLocalHome) ctx.lookup("");
                   TestEJB servicio=(TestEJB)home.create();
    the EJB are in the same server , please help,

    Hi Siarhei,
    thank's for your answers , i'll explain the scenario , i think i copied wrong the code that i have ,
    i have two EAR's applications , i want to call one EJB from the other EJB in other EAR , the call have to be remote , my code is the next :
    ctx = new InitialContext();
    Object obj = ctx.lookup("");  
    TestEJBHome home = (TestEJBHome) PortableRemoteObject.narrow(obj,TestEJBHome.class);
    TestEJB servicio= home.create();
    i've confugured the ejb-xml.jar adding
    I've configured the  ejb-j2ee-jar.xml adding
    I've configured the application-j2ee-engine.xml adding a hard reference
    with all this configuration still send me the message java.lang.classcast ,
    something is missing????  ,

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE

  • CallerPrincipal when calling one sessionbean from another

    Hi all,
    I have a little problem when calling one sessionbean from another sessionbean. The problem is, that in the method, which is called, is used SessionContext's getCallerPrincipal().getName(). This works great from client, but from other sessionbeans getCallerPrincipal() retuns an "ANONYMOUS" principal. How can I set the correct principal (the principal from the first sessionbean)?
    Thank you
    My env: Glassfish 2.1.1, Netbeans 6.8, Eclipselink 2.0.0, Java
    My code:
    public class ABean implements ASessionRemote{
    SessionContext ctx;
    public void aMethod(){
    String name = ctx.getCallerPrincipal().getName(); // the name is ANONYMOUS, when the call is done from other sessionbean
    public class BBean implements BSessionRemote{
    SessionContext ctx;
    private ASessionRemote aSessionBean;
    public void bMethod(){

    "This works great from client"
    What do you mean by this, i.e what sort of client are you using (stand alone app, servlet) ?
    what shows up if you printout the caller principal in the calling bean ?
    are the two ejbs in the same ear ?
    what security meta-information are you using in ejb-jar.xml and sun-ejb-jar.xml, if any ?

  • How to call one .SWF from another?

    How do I call one .SWF from another. I built a very beefy
    base .SWF, and want to add music overlay, and an intro slide show
    to the exsting Flash animation, but put it in a second .FLA/.SWF
    file. How do I call one from the other?
    This will be embedded in an HTML file but I assume this is
    superfluous to my question.

    I think you should open that Another SWF (FLA),
    and add some actionscript..
    For example, you could create a movie clip, and write
    actionscript in the
    first keyframe:
    "FredZimmerman" <[email protected]> wrote in
    news:ftnjas$mj5$[email protected]..
    > How do I call one .SWF from another. I built a very
    beefy base .SWF, and
    > want
    > to add music overlay, and an intro slide show to the
    exsting Flash
    > animation,
    > but put it in a second .FLA/.SWF file. How do I call one
    from the other?
    > This will be embedded in an HTML file but I assume this
    is superfluous to
    > my
    > question.
    > F.Z.

  • I need help with controlling two .swf's from third.

    Hi, thanks for reading!
    I need help with controlling two .swf's from third.
    I have a problem where I need to use a corporate designed
    .swf in a digital signage solution, but have been told by the legal
    department that it can not be modified in any way, I also can't
    have the source file yada yada. I pulled the .swfs from their
    website and I decompiled them to see what I was up against.
    The main swf that I need to control is HCIC.swf and the
    problem is it starts w/ a preloader, which after loading stops on a
    frame that requires user input (button press) on a play button,
    before the movie will proceed and play through.
    What I have done so far is to create a container swf,
    HCIC_container.swf that will act as Target for the HCIC.swf, and
    allow me to send actionscript to the file I'm not allowed to
    I managed to get that done with the help of someone on
    another forum. It was my hope that the following script would just
    start HCIC.swf at a frame past the preloader and play button, and
    just play through.
    var container:MovieClip = createEmptyMovieClip("container",
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.loadClip("MCIC.swf", container);
    function onLoadInit(mc:MovieClip) {
    But unfortunately it didn't solve my problem. Because there
    is a media-controller.swf, that is being loaded by HCIC.swf that
    has the controls including the play button to start HCIC.swf.
    Here's a link to a .zip file with all 3 .swf files, and all 3
    .fla files.
    What I need to do is automatically start the HCIC.swf file
    bypassing the pre-loader and play button without editing it or the
    media-controller.swf in anyway. So all the scripting needs to be
    done in HCIC_container.swf.
    I know this is confusing, and its difficult to explain, but
    if you look at the files it should make sense.
    ActionScripting is far from my strong point, so I'm
    definitely over my head here.
    Thanks for your help.

    Got my solution on another forum.

  • Calling one variable to other variable ( alphanumeric)

    Hi All,
    I have scenario where I am calling one variable to other variable in ODI.
    For example.
    Lets say I have two variable V_SET1 & V_SET2
    V_SET1 :
    Variable type : alphanumeric , Historize,
    Refreshing : SELECT #V_SET1 FROM DUAL to historize value.
    Now I am using V_SET1 in V_SET2
    Variable type : alphanumeric , Historize,
    Refreshing :
    Both variables are inside scenario I am passing value of V_SET1 at run time as parameter 'TEST'
    V_SET1 is executed sucessfully & TEST is stored is historized
    BUT in V_SET2 V_SET1 value is getting passed in " quotes & i am geeting error of INVALID IDENTIFIER "TEST"
    select SOURCE_NAME from EXTRACT_PGSQL_DETAIL where OE_DETAILS = # V_SET1 ( "TEST") -- error inavlid identifier.
    How can I covert the value of TEST from "TEST" to 'TEST' in second Variable V_SET
    Edited by: neeraj_singh on Jun 24, 2011 3:15 AM

    Try this if not,

  • Can you help with Problems that one of our users i having with regiistration of Premiere Pro?

    Can you help with Problems that one of our users i having with registration of Premiere Pro?

    Link for Download & Install & Setup & Activation problems may help
    -Online Chat
    More information needed for someone to help... please click below and provide the requested information
    -Premiere Pro Video Editing Information FAQ

  • Calling one script from another

    InDesign has a nice mechanism for calling one script from another, so code can be made modular. What about FrameMaker ExtendScript? What methods are people using to call one script from another? Thanks for any suggestions.
    Rick Quatro

    Hi Trevor,
    Note that ExtendScript is Javascript plus FM objects and methods, so you need to stick to Javascript syntax rules. The right way to include another script source is as follows:
    #include "scriptname.jsx";
    If this works when running the main script from the ESTK, you know it finds the included script. When you then Export the script to Binary (from the File menu of the ESTK), the binary will include the embedded script as well. After this you have a jsxbin file, which you can drop into one of the two available startup folders to make it fire automatically when FM starts. Or you can move it anywhere else and run it via the File > Script > Run command. The main idea here is that when compiling a script into binary format, all include references are resolved and the script contains the complete code. If you run the jsx, the script is interpreted and requires a correct relative reference to any included script.
    I hope this clarifies things a little

  • 3 iphones in household.All use same apple ID.But all contacts get mixed between phones and facetime calls come in from other contacts.Ho can we change this so our phone information isn't visible to each other?

    3 iphones in household.All use same apple ID.But all contacts get mixed between phones and facetime calls come in from other contacts.How can we change this so our phone information isn't visible to each other?

    Use separate Apple IDs for each family member and use Family Sharing features of those things (if any) that you do want to share.

  • ABAP Objects : calling one method from another class

    Can you please tell me how to call method from one class or interfce to another class.The scenario is
    I have one class CL_WORKFLOW_TASK, this class have interface IF_WORKFLOW_TASK & this interface have method IF_WORKFLOW_TASK~CLOSE. Now my requirement is ,
    There is another class CL_WORKFLOW_CHAIN ,this class have interface IF_WORKFLOW_CHAIN & this interface have method IF_WORKFLOW_CHAINCLOSE_ALL_PREDECESSORS. Now i have to write my code in this method but i have to use IF_WORKFLOW_TASKCLOSE method for closing the task.
    Can you please give me the code for the above .
    Please waiting for reply.

    You can use the concept of INHERITANCE  in this scenario.By using this concept, you can call all the public and protected  methods of class CL_WORKFLOW_TASK  in the required calss CL_WORKFLOW_CHAIN as per your requirement.
    Go through the  Introdctory(INHERITANCE) programming from this SAPHELP link.
    I hope, it will help in you inresolving your problem.
    Prasad GVK.

  • Call proxy service from other proxy service with attachment

    I have got an email sending proxy service I would like to call this from an other proxy service and I want to send attachment in email. I can send email with attachment if i call this proxy as a webservice (e.g. from soapUI)
    But if i want to call this email proxy service from other proxy service, the attachment in email is empty. I put a log action (expression: $attachments) in the beginning of email proxy service, and I saw this in the log file:
    +<con:attachments xmlns:con=""/>+
    So the attachment is really empty...
    I use service callout. I put an insert action in request action of service callout:
    In Variable:
    as first child of
    +<con:attachment xmlns:con="">+
    +     <con:Content-Type>application/octet-stream</con:Content-Type>+
    +     <con:Content-Disposition>attachment; filename="{$v_fileName}"</con:Content-Disposition>+
    +     <con:Content-Transfer-Encoding>base64</con:Content-Transfer-Encoding>     +
    +     <con:body>{$attachments/ctx:attachment/ctx:body/*}</con:body>+
    Why cannot I call this email proxy service from other proxy service for sending email with attachment?
    I tried to solve this other. I called an email sending business service from this proxy service. But in this case I cannot set the body of email. If I put just one Transport Header action in publish action, I could send the email (with empty body). But If I put a replace action in publish action as well then the OSB didn't send the email and I couldn't find any error message in log file... How could I set the body of email in publish action?

    You should be able to get the current user id from the SPListItemEventProperties object. From here you should be able to create a Claim. For example get the user by using
    user = SPWeb.Users.GetByID(properties.CurrentUserId)
    SPClaim claim = SPClaimProviderManager.CreateUserClaim(, SPOriginalIssuerType.TrustedProvider, issuerIdentifier);
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • Help with GUI project.

    I need help with JcomboBox when I select the Exit in the File box it will open
    //inner class
    class exitListener implements ActionListener {
    I have the part of the parts of statement but I don't know how to assign the Keystoke. here is that part of the code
    filemenu.setMnemonic(KeyEvent.VK_X);Here is my code...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class MyFrame extends JFrame {
         String[] file = { "New", "Open", "Exit" };//items for file
        String[] edit = { "Cut", "Copy", "Paste" };//items for edit
        JComboBox filemenu = new JComboBox();
        JComboBox editmenu = new JComboBox();
         public MyFrame(String title) {
              this.setSize(250, 250); //sets the size for the frame
              this.setLocation(200, 200);//location where frame is at
              // setup contents
              // display
         private void makeComponents() {
              JPanel pane = new JPanel();
    //          file menu section
              filemenu = new JComboBox();
            JLabel fileLabel = new JLabel();
            for (int i = 0; i < file.length; i++)
    //edit menu section
    editmenu = new JComboBox();
    JLabel editLabel = new JLabel();
    for (int i = 0; i < edit.length; i++)
         private void initComponents() {
              filemenu.addActionListener(new exitListener());
         //inner class
    class exitListener implements ActionListener {
    public void actionPerformed(ActionEvent arg0) {
    int x = JOptionPane.showOptionDialog(MyFrame.this, "Exit Program?",
    "Exit Request", JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE, null, null,
    if (x == JOptionPane.YES_OPTION) {
         private void buildGUI() {
              Container cont = this.getContentPane();// set gui components into the frame
              this.setLayout(new FlowLayout(FlowLayout.LEFT));// Comp are added to the frame
         // / inner classes
    public class ButtonFrame {
         public static void main(String[] args) {
              MyFrame f1 = new MyFrame("This is my Project for GUI");

    One way is to
    1) pass a reference of the Window object to the USDListener class, and set a local Window variable say call it window, to this reference.
    2) Give the Window class a public method that returns a String and allows you to get the text from USDField. Same to allow you to set text on the euroField.
    3) Give the Listener class a Converter object.

Maybe you are looking for

  • "that clip needs to be optimized"

    I'm trying to add a clip to a movie trailer, and every time I select video, I get the "Alert - That clip needs to be optimized" window. I've optimized it multiple times, both "full" and "large" but it gives me the alert every time. I can't delete the

  • Sharepoint Designer hangs when saving in aspx page

    Hi all My self Arun Darly  I am using share point 2010  I am facing one issue that is share point designer is hanging at the time of saving file after any modification of that file  <o:p></o:p> currently we are working with JavaScript on share point

  • Can I make a function wait for a period of time?

    Hey everyone I just wanted some idea's on how best to tackle this problem in actionscript. All I want is that when a button is pressed it fades out the current page and then fades in the new page to be displayed. How ever when trying to fade out the

  • How to install iOS on MacBook Pro or VM

    I'm looking to install iOS on a MacBook (perhaps a 2nd partition?) or via VM. I've Googled but can't find anything, OS X constantly comes up. Is this possible?

  • SQL Discovery and 4001 Event ID

    Hello :) I see the following in the OpsMgr log DiscoverSQL2005DBEngineDiscovery.vbs : The Query 'select * from __NAMESPACE where Name ='ComputerManagement'' returned an invalid result set.  Please check to see if this is a valid WMI Query.. Object re