🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12211

Problem with JTabbedPane

#12211
From: Ryan Turner
Date: Sat, 13 Feb 1999 00:00
180 lines
5929 bytes
I am trying to develop a UI which contains a JTabbedPane. I don't have a
problem adding the tabs to the container, but when I try to add
components to the panels which represent each tab (JLabels,
JTextFields), the components don't show up at run time. Here is the
source code:

package Testing;

import java.awt.*;
import java.awt.event.*;
import borland.jbcl.control.*;
import borland.jbcl.layout.*;
import com.sun.java.swing.*;


public class Frame1 extends JFrame
{
  //Construct the frame
  BorderLayout borderLayout1 = new BorderLayout();
  XYLayout xYLayout2 = new XYLayout();
  BevelPanel bevelPanel1 = new BevelPanel();
  MenuBar menuBar1 = new MenuBar();
  Menu menuFile = new Menu();
  MenuItem menuFileExit = new MenuItem();
  Menu menuHelp = new Menu();
  MenuItem menuHelpAbout = new MenuItem();
  ButtonBar toolBar = new ButtonBar();
  StatusBar statusBar = new StatusBar();

  JTabbedPane navigationTabs;
  JPanel jobMgrPane;
  JPanel batchMonitorPane;

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

  private void jbInit() throws Exception
  {
    this.getContentPane().setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    menuFile.setLabel("File");
    menuFileExit.setLabel("Exit");
    menuFileExit.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        fileExit_actionPerformed(e);
      }
    });
    menuHelp.setLabel("Help");
    menuHelpAbout.setLabel("About");
    menuHelpAbout.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        helpAbout_actionPerformed(e);
      }
    });
    toolBar.setButtonType(ButtonBar.IMAGE_ONLY);
    toolBar.setLabels(new String[] {"File", "Close", "Help"});
    toolBar.setImageBase("image");
    toolBar.setImageNames(new String[] {"openFile.gif", "closeFile.gif",
"help.gif"});
    bevelPanel1.setLayout(xYLayout2);
    menuFile.add(menuFileExit);
    menuHelp.add(menuHelpAbout);
    menuBar1.add(menuFile);
    menuBar1.add(menuHelp);

    // Set up the navigation tabs
    InitializeNavTabs();

    // Add the nav tabs to the bevel panel
    bevelPanel1.add(navigationTabs, new XYConstraints(10, 10, 200,
200));

    this.setMenuBar(menuBar1);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);
    this.getContentPane().add(statusBar, BorderLayout.SOUTH);
    this.getContentPane().add(bevelPanel1, BorderLayout.CENTER);
  }
//File | Exit action performed

  public void fileExit_actionPerformed(ActionEvent e)
  {
    System.exit(0);
  }
//Help | About action performed

  public void helpAbout_actionPerformed(ActionEvent e)
  {
    Frame1_AboutBox dlg = new Frame1_AboutBox(this);
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.show();
  }


/////////////////////////////////////////////////////////////////////////////

  // InitializeNavTabs
  // This routine initializes the main navigator tab control
  private void InitializeNavTabs()
  {
    navigationTabs = new JTabbedPane();
    navigationTabs.setLayout(new XYLayout());
    navigationTabs.setMinimumSize(new Dimension(600, 500));
    navigationTabs.setMaximumSize(new Dimension(750, 550));
    navigationTabs.setPreferredSize(new Dimension(600, 500));

    // Set up the Job Manager pane
    InitializeJobMgrPane();

    // Set up the Batch Monitor pane
    InitializeBatchMonitorPane();

    // Add the panes to the navigation tabs
    navigationTabs.addTab("Job Manager", jobMgrPane);
    navigationTabs.addTab("Batch Monitor", batchMonitorPane);
  }


/////////////////////////////////////////////////////////////////////////////

  // InitializeJobMgrPane
  // This routine initializes the split pane which contains the tree
control
  // and the communications details tab control
  private void InitializeJobMgrPane()
  {
    jobMgrPane = new JPanel();
    jobMgrPane.setLayout(new BorderLayout());
    jobMgrPane.setForeground(SystemColor.controlText);

    jobMgrPane.setPreferredSize(new Dimension(200,200));
    jobMgrPane.setMinimumSize(new Dimension(200, 200));
    jobMgrPane.setMaximumSize(new Dimension(200, 200));

    JLabel testLabel = new JLabel("Testing");
    testLabel.setForeground(SystemColor.controlText);
    jobMgrPane.add(testLabel, BorderLayout.CENTER);
  }


/////////////////////////////////////////////////////////////////////////////

  // InitializeBatchMonitorPane
  // This routine sets up the Batch Monitor pane within the navigation
tabs
  private void InitializeBatchMonitorPane()
  {
    batchMonitorPane = new JPanel();
    batchMonitorPane.setLayout(new XYLayout());
    batchMonitorPane.setPreferredSize(new Dimension(200, 200));

    JLabel test = new JLabel("Testing");
    test.setForeground(SystemColor.controlText);
    batchMonitorPane.add(test, new XYConstraints(20, 20, 50, 25));
  }
}

Ryan Turner
Software Engineer
MicroMass Communications
rturner@micromass.com
Technical Details
Message-ID: <36C5C836.AAF64F37@micromass.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,85082f6af84d299f,start
X-Google-Attributes: gid111d45,public
From: Ryan Turner <rturner@micromass.com>
Subject: Problem with JTabbedPane
Date: 1999/02/13
Message-ID: <36C5C836.AAF64F37@micromass.com>
X-Deja-AN: 444037303
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing