🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #573

Re: Path problems after doing a Rebuild

#573
From: Paul Furbacher TeamB
Date: Thu, 12 Jun 2003 15:14
212 lines
7476 bytes
In <3ee79a57@newsgroups.borland.com> Pete Antoniak wrote:
>  
>  However, I did notice a problem with the way JB relates to classes 
>  that reference other classes.  If  I have a JTabbedPane class and add 
>  JPanels to it.  And I want to have the JPanels relate back to the 
>  JTabbedPane, I can't do this directly.  ...

What do you mean by "relate back to"?  Do you want to maintain
a reference to the tab pane in each sub-panel?  If you
provide accessor/mutator (getter/setter) methods for 
doing this in your custom panel classes, you shouldn't 
have any problem.  The compiler should handle this just
fine, and the Property Inspector (UI Designer) should 
allow you to set that property.

>  I must create a compile the original JTabbedPane and 
>  dependent JPanels before I create a reference in the
>  dependent JPanels to the original JTabbedPane.  If 
>  you bring a project in from another IDE,  this can 
>  become problematic if all the classes are already 
>  referencing each other.  JB has a fit.

Though I don't doubt you are experiencing problems, I'm 
wondering whether you can solve this by writing your
custom panel classes so that they are more amenable to 
UI Designer tooling.  The following, ...

>  The work-around I use is to remark out all references 
>  first, then compile, then unremark them and compile again.

.. really shouldn't be necessary.  Something else
is going on which you should come to grips with.

Below my sig is an example of how you could approach this.


Paul Furbacher [TeamB]

  Save time, search the archives:
       http://info.borland.com/newsgroups/ngsearch.html
       
  Is it in Joi Ellis's Faq-O-Matic? 
       http://www.visi.com/~gyles19/fom-serve/cache/1.html
 
  Finally, please send responses to the newsgroup only.
  That means, do not send email directly to me.
  Thank you.

***** Place the following into two separate source code
files in a folder hierarchy:

   d:/myProjects
       /myProject
         /src
           /tabpane_pane_communication
             - Frame1.java
             - TabPaneReferencePanel.java

Create a new project which resides in the "myProjects/myProject"
folder.  JBuilder should auto-discover the source files.

Create a runtime config for tabpane_pane_communication.Frame1.

At this point, you are good to go.

*****

package tabpane_pane_communication;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

/**
 * <p> To demonstrate that custom panels can maintain a reference 
 *     to an owning tab pane without messing up the compiler.</p>
 * <p> </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author Paul Furbacher
 * @version 1.0
 */

public class TabPaneReferencerPanel extends JPanel {

  JTabbedPane tabPane = null;

  GridBagLayout gridBagLayout1 = new GridBagLayout();
  JButton button1 = new JButton();

  public TabPaneReferencerPanel() {
    try {
      jbInit();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  void jbInit() throws Exception {
    button1.setText("Press me to do something to the tab pane");
    button1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        button1_actionPerformed(e);
      }
    });
    this.setLayout(gridBagLayout1);
    this.add(button1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, 
            new Insets(0, 0, 0, 0), 0, 0));
  }

  public JTabbedPane getTabPane() {
    return tabPane;
  }

  public void setTabPane(JTabbedPane tabPane) {
    this.tabPane = tabPane;
  }

  /** Show that with the tabPane ivar (member variable) reference,
   * we can yank it around.
   */
  void button1_actionPerformed(ActionEvent e) {
    // randomly set the current tab's foreground color
    int val = (int)(Math.random() * 255.0);
    Color c = new Color(val, val, val);
    tabPane.setForegroundAt(tabPane.getSelectedIndex(), c);
    // randomly set the next tab index.
    tabPane.setSelectedIndex((int)(Math.random() * tabPane.getComponentCount()));
    System.out.println(" value: " + val);
  }
}

**** 

package tabpane_pane_communication;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * <p> To demonstrate that custom panels can maintain a reference to an
 * owning tab pane without messing up the compiler.</p>
 * <p> </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author Paul Furbacher
 * @version 1.0
 */

public class Frame1 extends JFrame {
  JTabbedPane jTabbedPane1 = new JTabbedPane();
  BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel1 = new JPanel();
  JPanel jPanel2 = new JPanel();
  JPanel jPanel3 = new JPanel();
  TabPaneReferencerPanel customPanel1 = new TabPaneReferencerPanel();
  TabPaneReferencerPanel customPanel2 = new TabPaneReferencerPanel();
  TabPaneReferencerPanel customPanel3 = new TabPaneReferencerPanel();

  public Frame1() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * Look here!  Note that the Object Inspector was used to
   * set the tabPane property of the three custom panels nested
   * in the tabPane.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {
    this.getContentPane().setLayout(borderLayout1);
    customPanel1.setTabPane(jTabbedPane1);
    customPanel2.setTabPane(jTabbedPane1);
    customPanel3.setTabPane(jTabbedPane1);
    this.getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
    jTabbedPane1.add(jPanel1,    "Tab One");
    jTabbedPane1.add(jPanel2,   "Tab Two");
    jTabbedPane1.add(jPanel3,   "Tab Three");
    jPanel1.add(customPanel1, null);
    jPanel2.add(customPanel2, null);
    jPanel3.add(customPanel3, null);
    jTabbedPane1.setSelectedComponent(jPanel3);
    this.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        this_windowClosing(e);
      }
    });
  }

  public static void main(String[] args) {
    Frame1 frame = new Frame1();
    frame.pack();
    frame.show();
  }

  void this_windowClosing(WindowEvent e) {
    System.exit(0);
  }

}
  

*****
Technical Details
Message-ID: <20030612111442529-0400@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!in.100proofnews.com!in.100proofnews.com!newspeer1.nwr.nac.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ee39039$1@newsgroups.borland.com> <3ee79a57@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,da0f3d1640562bd
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2003-06-12 08:21:42 PST
User-Agent: Halime (MacOSX)/1.0rc1a
Newsgroups: borland.public.jbuilder.java.api
Message-ID: <20030612111442529-0400@newsgroups.borland.com>
References: <3ee39039$1@newsgroups.borland.com> <3ee79a57@newsgroups.borland.com>
Content-Type: text/plain; charset="US-ASCII"
Subject: Re: Path problems after doing a Rebuild
From: Paul Furbacher [TeamB] <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 68.39.103.120
Date: 12 Jun 2003 08:14:35 -0700
X-Trace: newsgroups.borland.com 1055430875 68.39.103.120 (12 Jun 2003 08:14:35 -0700)
Lines: 212
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!in.100proofnews.com!in.100proofnews.com!newspeer1.nwr.nac.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail