GridBagLayout with Panels

In a nutshell I have five panels. The comboPanel contains a label and comboBox; objectPanel has a label and text field; filePanel and directPanel have a label, text field and button; buttonPanel has two buttons.
When the program is first run only the comboPanel is visible. If "Display object and filePanel" is selected from the comboBox then the objectPanel and filePanel are visible, else directPanel is visible. buttonPanel is visible no matter what is selected.
The problem is I am trying to add them to the GridBayLayout and have them display below one another which is why I am using gbc.gridwidth = GridBagConstraints.REMAINDER for each, however they are all showing up on the same line.
Thanks in advance
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SMG3AuditInterface extends JFrame
    JComboBox comboBox;
    JLabel lblComponent, lblObjectName, lblFileName, lblDirectName;
    JTextField tfObjectName, tfFileName, tfDirectName;
    JButton btnSubmit, btnCancel, btnFileBrowse, btnDirectBrowse;
    JPanel comboPanel, objectPanel, filePanel, directPanel, buttonPanel;
    GridBagLayout gb;
    GridBagConstraints gbc;
    public SMG3AuditInterface()
    gb = new GridBagLayout();
    gbc = new GridBagConstraints();
    Container cp = getContentPane();
    cp.setLayout(gb);
    String components[] = {"Display directPanel",
        "Display object and filePanel"};
    comboBox = new JComboBox(components);
    comboBox.setSelectedIndex(-1);
    lblComponent = new JLabel("Component Type: ");
    comboPanel = new JPanel();
    comboPanel.add(lblComponent);
    comboPanel.add(comboBox);
    cp.add(comboPanel);
    lblObjectName = new JLabel("Object name: ");
    tfObjectName = new JTextField(20);
    objectPanel = new JPanel();
    objectPanel.add(lblObjectName);
    objectPanel.add(tfObjectName);
    cp.add(objectPanel);
    objectPanel.setVisible(false);
    lblFileName = new JLabel("XML Filename: ");
    tfFileName = new JTextField(20);
    btnFileBrowse = new JButton("Browse");
    filePanel = new JPanel();
    filePanel.add(lblFileName);
    filePanel.add(tfFileName);
    filePanel.add(btnFileBrowse);
    cp.add(filePanel);
    filePanel.setVisible(false);
    lblDirectName = new JLabel("XML Directory name: ");
    tfDirectName = new JTextField(20);
    btnDirectBrowse = new JButton("Browse");
    directPanel = new JPanel();
    directPanel.add(lblDirectName);
    directPanel.add(tfDirectName);
    directPanel.add(btnDirectBrowse);
    cp.add(directPanel);
    directPanel.setVisible(false);
    btnSubmit = new JButton("Submit");
    btnCancel = new JButton("Cancel");
    buttonPanel = new JPanel();
    buttonPanel.add(btnSubmit);
    buttonPanel.add(btnCancel);
    cp.add(buttonPanel);
    buttonPanel.setVisible(false);
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = GridBagConstraints.RELATIVE;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.gridwidth = 3;
    gbc.gridheight = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gb.setConstraints(comboPanel, gbc);
    add(comboPanel);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 1;
    gb.setConstraints(objectPanel, gbc);
    add(objectPanel);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 2;
    gb.setConstraints(filePanel, gbc);
    add(filePanel);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 2;
    gb.setConstraints(directPanel, gbc);
    add(directPanel);
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gb.setConstraints(buttonPanel, gbc);
    add(buttonPanel);
    comboBox.addItemListener(new ItemListener()
       public void itemStateChanged(ItemEvent e)
          JComboBox cb = (JComboBox)e.getSource();
          String itemName = (String)cb.getSelectedItem();
          buttonPanel.setVisible(true);
          if (itemName == "Display object and filePanel")
             objectPanel.setVisible(true);
             filePanel.setVisible(true);
             directPanel.setVisible(false);
          else
             objectPanel.setVisible(false);
             filePanel.setVisible(false);
             directPanel.setVisible(true);
    public static void main(String[] args)
    SMG3AuditInterface ai = new SMG3AuditInterface();
    ai.setDefaultCloseOperation(ai.EXIT_ON_CLOSE);
    ai.setLocation(400, 300);
    ai.setPreferredSize(new Dimension(400,300));
    ai.pack();
    ai.show();
}

Here's an example:
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class SMG3Petes extends JPanel
    private static final String DIRECT_PANEL = "Display directPanel";
    private static final String OBJECT_FILE_PANEL = "Display object and filePanel";
    private static final String components[] =
        DIRECT_PANEL, OBJECT_FILE_PANEL
    private static final String SUBMIT = "Submit";
    private static final String CANCEL = "Cancel";
    private static final String EMPTY_PANEL = "Empty Panel";
    private JPanel centerPanel;
    private CardLayout cardlayout = new CardLayout();
    private JComboBox comboBox;
    private JButton submitBtn = new JButton(SUBMIT);
    private JButton cancelBtn = new JButton(CANCEL);
    private JTextField tfObjectName = new JTextField(20);
    private JTextField tfFileName = new JTextField(20);
    private JTextField tfDirectName = new JTextField(20);
    public SMG3Petes()
        int eb = 15;
        setBorder(BorderFactory.createEmptyBorder(eb, eb, eb, eb));
        setLayout(new BorderLayout());
        add(createBigCenterPanel(), BorderLayout.CENTER);
        add(createPageEndPanel(), BorderLayout.PAGE_END);
    private JPanel createBigCenterPanel()
        JPanel p = new JPanel();
        p.setLayout(cardlayout);
        p.add(new JPanel(), EMPTY_PANEL);
        p.add(createObjectFilePanel(), OBJECT_FILE_PANEL);
        p.add(createDirectPanel(), DIRECT_PANEL);
        centerPanel = p;
        return p;
    private JPanel createObjectFilePanel()
        JPanel p = new JPanel();
        p.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.gridheight = 1;
        gbc.gridwidth = 1;
        gbc.weightx = 1;
        gbc.weighty = 1;
        gbc.insets = new Insets(5, 5, 5, 5);
        p.add(new JLabel("Object name: "), gbc);
        gbc.gridx = 1;
        gbc.gridwidth = 2;
        gbc.weightx = 2;
        p.add(tfObjectName, gbc);
        gbc.gridx = 3;
        gbc.gridwidth = 1;
        gbc.weightx = 1;
        p.add(new JLabel("   "));
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridwidth = 1;
        gbc.weightx = 1;
        p.add(new JLabel("XML Filename: "), gbc);
        gbc.gridx = 1;
        gbc.gridwidth = 2;
        gbc.weightx = 2;
        p.add(tfFileName, gbc);
        gbc.gridx = 3;
        gbc.gridwidth = 1;
        gbc.weightx = 1;
        JButton browseBtn = new JButton("Browse");
        p.add(browseBtn, gbc);
        return p;
    private JPanel createDirectPanel()
        JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 0));
        JLabel lblDirectName = new JLabel("XML Directory name: ");
        tfDirectName = new JTextField(20);
        JButton btnDirectBrowse = new JButton("Browse");
        p.add(lblDirectName);
        p.add(tfDirectName);
        p.add(btnDirectBrowse);
        return p;
    private JPanel createPageEndPanel()
        JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 0));
        p.add(createComboPanel());
        p.add(createButtonPanel());
        return p;
    private JPanel createComboPanel()
        comboBox = new JComboBox(components);
        comboBox.setSelectedIndex(-1);
        comboBox.addItemListener(new ComboItemListener());
        JPanel p = new JPanel();
        p.add(new JLabel("Component Type: "));
        p.add(comboBox);
        return p;
    private class ComboItemListener implements ItemListener
        public void itemStateChanged(ItemEvent ie)
            submitBtn.setEnabled(true);
            cancelBtn.setEnabled(true);
            String itemName = (String) comboBox.getSelectedItem();
            if (itemName.equals(DIRECT_PANEL))
                cardlayout.show(centerPanel, DIRECT_PANEL);
            else if (itemName.equals(OBJECT_FILE_PANEL))
                cardlayout.show(centerPanel, OBJECT_FILE_PANEL);
    private JPanel createButtonPanel()
        JPanel p = new JPanel(new GridLayout(1, 0, 15, 0));
        submitBtn.setEnabled(false);
        cancelBtn.setEnabled(false);
        p.add(submitBtn);
        p.add(cancelBtn);
        return p;
    private static void createAndShowGUI()
        JFrame frame = new JFrame("SMG3 Petes1234 Application");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new SMG3Petes());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    public static void main(String[] args)
        javax.swing.SwingUtilities.invokeLater(new Runnable()
            public void run()
                createAndShowGUI();
}

Similar Messages

  • Flex Module issue with Panel

    Hello everyone. I have the following problem.
    In my application I have several modules and each of them have components CollapsableTitleWindow (extends Panel). After opening the window it is added to the container which is in the main application (CollapsableTitleWindowContainer). In these windows you can open another window (and so on).
    Now, what is the problem. When I change (reload) any module and I want to open a new window (sub window) with the already loaded window I get this error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.containers::Panel/layoutChrome()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\containers\Panel.as:1405]
    at com::CollapsableTitleWindow/layoutChrome()[D:\Flex 3 Workspace\WesobCrm\src\com\CollapsableTitleWindow.as:216]
    at mx.core::Container/updateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2867] (...)
    Indicates that the main applications have object Panel
    Please help.
    P.S. I found a similar problem on http://www.nabble.com/Flex-Module-issue-with-Panel-td20168053.html
    ADDED: I extendes the Panel class and do something like that:
    override protected function layoutChrome(unscaledWidth:Number, unscaledHeight:Number):void
                    use namespace mx_internal;
                    if(!(mx_internal::titleBarBackground is TitleBackground)) {
                            mx_internal::titleBarBackground = new TitleBackground();
                    super.layoutChrome(unscaledWidth, unscaledHeight);                     
    But now i had something like that: Before After
    You can see that it loos style declaration.H

    Thanks for the anserw.
    I don't exacly understand all but i found a solution for my problem and it works.
    Could you tell me if this is ok ?
    I Add in my main app
    public function getProductWindow():ProductWindow {
        return new ProductWindow();
    And in the module i change
    From var productWindow:ProductWindow = new ProductWindow();
    To var productWindow:ProductWindow = Application.application.getProductWindow();

  • "Open with" panel items

    How do I remove old applications that I no longer have on my Mac from the "Open with" panel the appears when you use the "Open with" command? For example I have Adobe Reader 9.3.4 installed but I'm also given a choice of 2 other Reader versions, in addition to 9.3.4

    No. but you can remove duplicates by rebuilding the LaunchServices database with this one-line command run in the Terminal app. Restart after running it:
    */System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchS ervices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user*

  • Scale Object with Panel, but what about inside a Tab control?

    The Scale Object with Panel option works very well for simple UI
    objects.  I like to use it for VIs that display tables or
    multicolumn listboxes, etc.  I am finding a limitation when I use
    the Tab control.  If I have a table or listbox in each tab, I
    would like them to scale with the panel.  I would also like the
    tab to scale.  It should look like an Excel workbook where all
    sheets scale with the window even though they are each on their own
    tab.  If I could only Group the various tables / lists with the
    Tab itself....
    This wouldn't be such an issue if the Bounds property of the
    multicolumn listbox was writable.  I can set the number of rows
    and columns, but column size can be variable and not uniform across all
    columns.  Also, that solution looks and behaves much different
    from the Scale Object with Panel approach.... not to mention the extra
    coding required.
    I'm guessing that this amounts to a feature request, but if anyone has a present-version workaround, I'd love to hear about it.
    See you at NI Week!
    Dan Press
    PrimeTest Automation

    Hi Kalin T,
    Thanks for your prompt reply. I am running version 8.01. My problem is that i cannot select "Scale object with pane" for the controls inside a Tab control if the Tab control "Scale object with pane" is turned on. I want both the Tab control and the controls inside to be scaled, for instance an Waveform graph or an textbox  when i resize my main window.
    Best regards,
    Mattis
    Attachments:
    Scale.vi ‏11 KB

  • Need some help with Panel

    NOTE: I am using Flex Builder 3, I'm not sure if just the
    BUILDER is upgraded to 3, or Flex is upgraded as well. There
    doesn't seem to be a Flex 3 forum here or on Adobe labs. I am
    posting here hoping that this is a general Flex problem and someone
    can help me.
    I and trying to make a sub-class of Panel with a series of
    buttons at the top. As the buttons will be outside the container
    area, I chose to put them into the titleBar. using
    titleBar.addChild()
    The problem is, the buttons I place inside the titleBar do
    not get Events.
    In what I think is a related problem. If you adjust the
    "headerHeight" property to say "12" and then have controls
    (button/combo) at the top of the panel's container, the top of
    controls do not get events, but the bottom of the controls do. It
    seems that something in the Panel is blocking events at the top of
    the panel.
    Any ideas?
    Thanks
    -pete

    I have gathered more information about this issue today. it
    seems that the issue is not the panel, but the outer container that
    I embedded it into. The effect I was trying to get was a panel with
    a highlight at the top. To do this the border alpha has to be set
    to "0" otherwise you see odd artifacts, but then the highlight can
    only apply to the background color.
    To get the effect I wanted, I embeded the panel with the
    highlight and buttons inside another panel (with the
    backgroundColor i wanted and solid border) embeding the panels is
    what caused the mouse events to go missing. Changing the outer
    Panel to a Canvas fixed the problem.
    However I still think there is a problem with Panels.
    embedding a Panel inside another Panel should not make the mouse
    events disappear. I'm just not sure where the real problem is.
    If anyone is curious, i can prepare a simple test app that
    shows the bug.
    -pete
    -pete

  • Problem with panels

    i have a JFrame with layout set to null
    i have one jpanel with border layout ,showing a jtree
    another panel with gridbaglayout is attached to the frame
    when a node on the tree is clicked , changes are made to the second panel with lots of components.but the change in the second panel is reflected only when the jframe is resized,ie its not displayed automatically.what can be the problem?im using jdk6.

    try panel.updateUI();No. That method is used for a Look and Feel change.
    Use:
    panel.add(...);
    panel.revalidate();

  • GridBagLayout and Panel Border problem

    I have 3 panels like
    A
    B
    C
    and the C panel has a Mouse Listener that on a mouseEntered creates a border around the same panel and on a mouseExited clears that border.
    When this border is created the A and B panels go up a little bit .. they move alone when the border is created.
    Is there any way to fix this problem? Is there any way to get the panels static?
    the code is close to the following:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    import javax.swing.border.TitledBorder;
    import java.awt.event.*;
    import java.text.NumberFormat;
    public class Game extends JFrame implements MouseListener
    JPanel game, options, top, down, middle;
    NumberFormat nf;
    public Game() {
    super("Game");
    nf = NumberFormat.getPercentInstance();
    nf.setMaximumFractionDigits(1);
    JPanel center = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = gbc.BOTH;
    gbc.weighty = 1.0;
    gbc.weightx = 0.8;
    center.add(getGamePanel(), gbc);
    gbc.weightx = 0.104;
    center.add(getOptionsPanel(), gbc);
    Container cp = getContentPane();
    // use the JFrame default BorderLayout
    cp.add(center); // default center section
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setSize(700,600);
    // this.setResizable(false);
    setLocationRelativeTo(null);
    setVisible(true);
    addComponentListener(new ComponentAdapter()
    public void componentResized(ComponentEvent e)
    showSizeInfo();
    showSizeInfo();
    private void showSizeInfo()
    Dimension d = getContentPane().getSize();
    double totalWidth = game.getWidth() + options.getWidth();
    double gamePercent = game.getWidth() / totalWidth;
    double optionsPercent = options.getWidth() / totalWidth;
    double totalHeight = top.getHeight() + middle.getHeight() + down.getHeight();
    double topPercent = top.getHeight() / totalHeight;
    double middlePercent = middle.getHeight() / totalHeight;
    double downPercent = down.getHeight() / totalHeight;
    System.out.println("content size = " + d.width + ", " + d.height + "\n" +
    "game width = " + nf.format(gamePercent) + "\n" +
    "options width = " + nf.format(optionsPercent) + "\n" +
    "top height = " + nf.format(topPercent) + "\n" +
    "middle height = " + nf.format(middlePercent) + "\n" +
    "down height = " + nf.format(downPercent) + "\n");
    private JPanel getGamePanel()
    // init components
    top = new JPanel(new BorderLayout());
    top.setBackground(Color.red);
    top.add(new JLabel("top panel", JLabel.CENTER));
    middle = new JPanel(new BorderLayout());
    middle.setBackground(Color.green.darker());
    middle.add(new JLabel("middle panel", JLabel.CENTER));
    down = new JPanel(new BorderLayout());
    down.setBackground(Color.blue);
    down.add(new JLabel("down panel", JLabel.CENTER));
    // layout game panel
    game = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.fill = gbc.BOTH;
    gbc.gridwidth = gbc.REMAINDER;
    gbc.weighty = 0.2;
    game.add(top, gbc);
    gbc.weighty = 0.425;
    game.add(middle, gbc);
    gbc.weighty = 0.2;
    game.add(down, gbc);
    down.addMouseListener(this);
    return game;
    private JPanel getOptionsPanel()
    options = new JPanel(new BorderLayout());
    options.setBackground(Color.pink);
    options.add(new JLabel("options panel", JLabel.CENTER));
    return options;
    // mouse listener events
         public void mouseClicked( MouseEvent e ) {
    System.out.println("pressed");
         public void mousePressed( MouseEvent e ) {
         public void mouseReleased( MouseEvent e ) {
         public void mouseEntered( MouseEvent e ) {
    Border redline = BorderFactory.createLineBorder(Color.red);
    JPanel x = (JPanel) e.getSource();
    x.setBorder(redline);
         public void mouseExited( MouseEvent e ){
    JPanel x = (JPanel) e.getSource();
    x.setBorder(null);
    public static void main(String[] args ) {
    Game exe = new Game();
    exe.show();
    }

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.*;
    import java.text.NumberFormat;
    public class Game extends JFrame implements MouseListener{
      JPanel game, options, top, down, middle;
      NumberFormat nf;
      public Game() {
        super("Game");
        nf = NumberFormat.getPercentInstance();
        nf.setMaximumFractionDigits(1);
        JPanel center = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = gbc.BOTH;
        gbc.weighty = 1.0;
        gbc.weightx = 0.8;
        center.add(getGamePanel(), gbc);
        gbc.weightx = 0.104;
        center.add(getOptionsPanel(), gbc);
        Container cp = getContentPane();
        // use the JFrame default BorderLayout
        cp.add(center); // default center section
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setSize(700,600);
        // this.setResizable(false);
        setLocationRelativeTo(null);
        setVisible(true);
        addComponentListener(new ComponentAdapter(){
            public void componentResized(ComponentEvent e){
            showSizeInfo();
        showSizeInfo();
      private void showSizeInfo(){
        Dimension d = getContentPane().getSize();
        double totalWidth = game.getWidth() + options.getWidth();
        double gamePercent = game.getWidth() / totalWidth;
        double optionsPercent = options.getWidth() / totalWidth;
        double totalHeight = top.getHeight() + middle.getHeight() + down.getHeight();
        double topPercent = top.getHeight() / totalHeight;
        double middlePercent = middle.getHeight() / totalHeight;
        double downPercent = down.getHeight() / totalHeight;
        System.out.println("content size = " + d.width + ", " + d.height + "\n" +
            "game width = " + nf.format(gamePercent) + "\n" +
            "options width = " + nf.format(optionsPercent) + "\n" +
            "top height = " + nf.format(topPercent) + "\n" +
            "middle height = " + nf.format(middlePercent) + "\n" +
            "down height = " + nf.format(downPercent) + "\n");
      private JPanel getGamePanel(){
        // init components
        top = new JPanel(new BorderLayout());
        top.setBackground(Color.red);
        top.add(new JLabel("top panel", JLabel.CENTER));
        middle = new JPanel(new BorderLayout());
        middle.setBackground(Color.green.darker());
        middle.add(new JLabel("middle panel", JLabel.CENTER));
        down = new JPanel(new BorderLayout());
        down.setBackground(Color.blue);
        down.add(new JLabel("down panel", JLabel.CENTER));
        // layout game panel
        game = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.fill = gbc.BOTH;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.weighty = 0.2;
        game.add(top, gbc);
        gbc.weighty = 0.425;
        game.add(middle, gbc);
        gbc.weighty = 0.2;
        game.add(down, gbc);
        down.addMouseListener(this);
        return game;
      private JPanel getOptionsPanel(){
        options = new JPanel(new BorderLayout());
        options.setBackground(Color.pink);
        options.add(new JLabel("options panel", JLabel.CENTER));
        return options;
      public void mouseClicked( MouseEvent e ) {
        System.out.println("pressed");
      public void mousePressed( MouseEvent e ) {
      public void mouseReleased( MouseEvent e ) {
      public void mouseEntered( MouseEvent e ) {
        Border redline = new CalmLineBorder(Color.red);
        JPanel x = (JPanel) e.getSource();
        x.setBorder(redline);
      public void mouseExited( MouseEvent e ){
        JPanel x = (JPanel) e.getSource();
        x.setBorder(null);
      public static void main(String[] args ) {
        Game exe = new Game();
        exe.setVisible(true);
    class CalmLineBorder extends LineBorder{
      public CalmLineBorder(Color c){
        super(c);
      public CalmLineBorder(Color c, int thick){
        super(c, thick);
      public CalmLineBorder(Color c, int thick, boolean round){
        super(c, thick, round);
      public Insets getBorderInsets(Component comp){
        return new Insets(0, 0, 0, 0);
    }

  • Programmatically Open a Remote Front Panel with Panel Open Method

    Hi,
    I am trying to open the front panel of the VI on my cRIO-9024 through a remote computer. Currently, I am able to run the VI with no problems with the RUN VI method; however, when I try to open the front panel, I receive "Error 1043 - This property or method is not supported in this version of LabVIEW" or the Front Panel is simply not visible. My cRIO is configured to allow TCP/IP protocol, The VI is visible, and I have made my project into a source distribution on my cRIO.
    Any help or suggestions regarding this problem would be great. I am very new to LabVIEW.
    I have attached a screenshot of my block diagram and project.
    Thanks,
    Jake 
    Attachments:
    Block_Diagram.PNG ‏12 KB

    Project Img
    Attachments:
    MyProject.png ‏15 KB
    MyProject.png ‏15 KB

  • Flex 3 need help with panels in dynamic tabs

    I am building an app where the user can add tabs as needed.  Each tab will have 4 panels inside
    it.  I can't get my for loop to build the panels.  It keeps erroring out.
    So question is  1) How do I create these with a loop and 2) I am wanting to put data from a data provider in here.  How can I reference the panel in the vbox in the tab control in the future?  Thanks in advance.
    PS...any reason why I can't get newPanel.width="100%" to work? Tried multiple ways. Thanks.
    private  
    function addNewTab():void{ 
    if(labelText.text!=""){ 
    var newVbox:VBox=new VBox(); 
    var newLabel:Label = new Label(); 
    var newPanel:Panel=new Panel() 
    newVbox.label=labelText.text;
    dbtabs.numChildren+1
    numChild = dbtabs.numChildren + 1;
    var i:int 
    for(i=0;i<4;i++){
    newPanel.title=
    "Panel";newPanel.layout=
    "absolute"; 
    //newPanel.width="100%";
    newVbox.addChild(newPanel)
    newVbox.addChild(newPanel)
    newwLabel.text =
    "Content here";newVbox.addChild(newLabel);
    dbtabs.addChild(newVbox);
    labelText.text=
    else{Alert.show(
    "You must enter a tab name") 
    // validate labelText

    NewPanel.percentWidth=100

  • Applying with panels doesn't work

    Hi,
    I've had this problem for a while now and no update seems to solve it. When i try to apply a style / color or anything by first selecting and then clicking on the panel nothing happens.
    For example, I create a text box with a filler text, select all, and try to apply a paragraph style I just created by clicking on the style in the paragraph style panel. Nothing happens. It's the same for all other panels.
    I'm on a brand new Mac Pro running Snow Leopard 10.6.6 with Indesign CS5 freshly installed (Dutch language version). The problem, however, trancends this system since I experience the same behaviour on my Macbook also running Snow Leopard 10.6.6.
    Is this a known issue (I have searched this forum and nothing similar turns up)?
    And more importantly can it be fixed...
    Thanks

    No, it's not normal or a known issue. Are you patched to 7.0.3? You said updates didn't help, but ti wasn't entirely clear if you meant to ID or the OS.
    Have you tried replacing your preferences? See Replace Your Preferences

  • Tabbed Panels: Opening panel with panel number doesn't work with Spry Data

    I have some data inside a TabbedPanelsContent div, and would
    like to be able to open tabs using links, but it only seems to work
    with static content.
    Clicking on tabs themselves loads content correctly, whereas
    clicking on links does nothing. I tried both - panel number and
    panel ID - neither worked. What gives?
    See code below.
    <div spry:region="ds1">
    <div class="TabbedPanels" id="tp1">
    <ul class="TabbedPanelsTabGroup">
    <li class="TabbedPanelsTab" tabindex="0">Asset
    Management</li>
    <li class="TabbedPanelsTab"
    tabindex="0">Brokerage</li>
    <li class="TabbedPanelsTab" tabindex="0">Mutual
    Funds</li>
    </ul>
    <div class="TabbedPanelsContentGroup">
    <div class="TabbedPanelsContent">
    <p spry:repeat="ds1"
    spry:test="'{@industry01}'.search(/^Asset Management/) !=
    -1;">{ds1::client}</p>
    </div>
    <div class="TabbedPanelsContent">
    <p spry:repeat="ds1"
    spry:test="'{@industry02}'.search(/^Brokerage/) !=
    -1;">{ds1::client}</p>
    </div>
    <div class="TabbedPanelsContent">
    <p spry:repeat="ds1"
    spry:test="'{@industry03}'.search(/^Mutual Funds/) !=
    -1;">{ds1::client}</p>
    </div>
    </div>
    </div>
    <script type="text/javascript">
    var tp1 = new Spry.Widget.TabbedPanels("tp1");
    </script>
    </div>
    <a href="#" onclick="tp1.showPanel(0); return
    false;">Asset Management</a>
    <a href="#" onclick="tp1.showPanel(1); return
    false;">Brokerage</a>
    <a href="#" onclick="tp1.showPanel(2); return
    false;">Mutual Funds</a>

    Try to declare the variable out side of the region
    <script> var tp1;</script>
    <div spry region ... >
    tab panel stuff
    <script type="text/javascript">
    tp1 = new Spry.Widget.TabbedPanels("tp1");
    </script>
    </div>

  • Mouse not interacting with panels.

    I have CS6 wich I just DL a few weeks ago for school, I use no plug-ins or other add on software. The problem is my mouse will not interact with the panels, (ie layers, swatches, and the such) in InDesign. So far Photoshop Illustrator, and Bridge all work just fine it is only ID that I am having issues with. On the panels I can get it to open the group but it has no interaction with the fine details, selecting layers, double click name to rename locking viewing and open layer options, create new layer button will also not work, I can use the options button at the top right of the panel for some things but it leaves me limited on what can be done. I can not even use my mouse to switch between layers. Any idea on what may be causeing this and what I can do to fix it. (yes my mouse works, it is charged and interacts with other software and games with no problem)

    Bob thanks so much for this. I had been using IdCS6 on Win7 without issues but recently got a new larger screen so had increased font size. BTW I did several searches on Adobe forum using various combinations of "indesign CS6 mouse will not work in layers panel" and did not manage to find your helpful reply.I eventually found it on about page 10 of Google search results! Have spent half a day on this search and found nothing so not a lot of info on this issue out there...I would not have found this information anywhere else. Glad I persisted! Again many thanks.

  • HELP, HELP, HELP, Problems using GridBagLayout with a BorderLayout

    I have a BorderLayout for my application. I created a JPanel that has the following items added to it:
    1)Button
    2)VisualComponent
    3)ControllerComponent
    The JPanel is then added to the WEST Pane of the BorderLayout. My problem is that I can not get my components in the JPanel to display correctly. The items should be added from top to buttom in my JPanel, but they overlap and display side by side, and some don't appear at all until my entire window application is Maximized. It seems as if all my components are trying to display in one row even though I explicitly add them to different rows as follows:
    1)addUsingGBL(openFile,0,1,2,1);
    2)addUsingGBL(visualComponent,1,1,1,3);
    3)addUsingGBL(controlsComponent,4,1,2,1);
    where addUsingGBL is as follows:
    void addUsingGBL(Component component,int row, int column, int width, int height)
    gbc. gridx = row;
         gbc.gridy = column;
         gbc.gridwidth = width;
         gbc.gridheight = height;
         gbLayout.setConstraints(component, gbc);
         mediaPanel.add(component);
         mediaPanel.doLayout();
    If anyone has any suggestions, I would greatly appreciate it. Entire code is available if needed. Thanks!

    Here is the code, sorry, didn't see that part before.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.media.*;
    public class MediaPlayerDemo extends JFrame /*implements ControllerListener*/{
    private Player player;
    private File file;
    public static JPanel mediaPanel;
    public static JScrollPane scrollableMediaPanel;
    //public static JFrame navigation = new JFrame("Lessons");
    public static Component visualComponent;
    public static Component controlsComponent;
    private static ImageIcon background = new ImageIcon("c:/Tony.jpg");
    public static GridBagConstraints gbc;
    public static GridBagLayout gbLayout;
    //public static panel column;
    //public static Container c;
    // inner class to handler events from media player
    private class EventHandler implements ControllerListener
         public void controllerUpdate( ControllerEvent e )
              if ( e instanceof EndOfMediaEvent)
              //if ( player == null )
              //return;
              player.close();
              //if ( visualComponent != null )
              mediaPanel.remove( visualComponent );
              //if ( controlsComponent != null )
              mediaPanel.remove( controlsComponent );
              mediaPanel.doLayout();
              // doLayout();
              if ( e instanceof RealizeCompleteEvent )
                   //c = getContentPane();
                   // load Visual and Control components if they exist
                   visualComponent =
                   player.getVisualComponent();
                   //visualComponent.setSize(5,5);
                   mediaPanel.doLayout();
                   //**Sets the layout for mediaPanel as GridLayout**
                   //**GridLayouts set the rows and col, **
                   //**& adds contentslt to rt **
                   //scrollableMediaPanel= new JScrollPane(mediaPanel);
                   //scrollableMediaPanel= new JScrollPane(mediaPanel);
                   gbc.weightx = 0;
                   gbc.weighty = 0;
                   gbc.fill = GridBagConstraints.NONE;
                   if ( visualComponent != null )
                   //add comp #2
                   addUsingGBL(visualComponent,1,1,1,3);
                   controlsComponent =
                   player.getControlPanelComponent();
                   if ( controlsComponent != null )
                   //add comp #3
                   //mediaPanel.add(controlsComponent);
                   addUsingGBL(controlsComponent,1,1,1,3);
                   controlsComponent =
                   player.getControlPanelComponent();
                   /*if ( controlsComponent != null )
                   //add comp #3
                   addUsingGBL(controlsComponent,4,1,2,1);
              doLayout();//after all components are added, you must redo your layout
              //**The following is for adding the a container only **
              //**getContentPane().add(mediaPanel,BorderLayout.WEST);**
              //**getContenPane().doLayout(); **
              //**setSize(200,700);//(width, Height) **
              //**show(); **
              }//if
         }//controllerUpdate
    }//eventHandler
    public MediaPlayerDemo()
         //**Title for a container **
         //**super( "Demonstrating the Java Media Player" );**
         mediaPanel = new panelBack(background);//instantiate JPanel Object
         gbLayout = new GridBagLayout();
         mediaPanel.setAlignmentY(TOP_ALIGNMENT);
         mediaPanel.setLayout(gbLayout);
                   gbc = new GridBagConstraints();
                   gbc.fill = GridBagConstraints.NONE;
                   //gbc.anchor = GridBagConstraints.NONE;
         //instatiate JButton object
         JButton openFile = new JButton( "Open file to play" );
         //openFile.setBounds(0, 0, 25, 25);
         //openFile.setVisible(true);
         //JBUTTON ActionListener
         openFile.addActionListener
              new ActionListener()
                   public void actionPerformed( ActionEvent e )
                   openFile();
                   createPlayer();
         );//addActionListener
         //add comp #1
         addUsingGBL(openFile,0,1,2,1);
         //set scrollPane
         scrollableMediaPanel = new JScrollPane(mediaPanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
         //Set Border
         scrollableMediaPanel.setViewportBorder(new BevelBorder(BevelBorder.RAISED));
    }//Constructor
    private void createPlayer()
         if ( file == null )
              return;
         removePreviousPlayer();
         try
              // create a new player and add listener
              player = Manager.createPlayer( file.toURL() );
              player.addControllerListener( new EventHandler() );
              player.start(); // start player
         catch ( Exception e )
              JOptionPane.showMessageDialog( this,
                   "Invalid file or location", "Error loading file",
                   JOptionPane.ERROR_MESSAGE );
    //Main only useful if creating a container to hold menuPanel
    public static void main(String args[])
         MediaPlayerDemo app = new MediaPlayerDemo();
         app.getContentPane().setLayout(new BorderLayout(0,0));
              app.getContentPane().setBackground(Color.white);
              app.getContentPane().add(scrollableMediaPanel, BorderLayout.WEST);
         app.getContentPane().validate();//re-layout a container for which the layout has changed
         app.setSize(1000,700);//(width, height)
         app.show();
         app.addWindowListener
              new WindowAdapter()
                   public void windowClosing( WindowEvent e )
                   System.exit(0);
    private void openFile()
         JFileChooser fileChooser = new JFileChooser();
         fileChooser.setFileSelectionMode(
              JFileChooser.FILES_ONLY );
         int result = fileChooser.showOpenDialog( this );
         // user clicked Cancel button on dialog
         if ( result == JFileChooser.CANCEL_OPTION )
              file = null;
         else
              file = fileChooser.getSelectedFile();
    private void removePreviousPlayer()
         if ( player == null )
              return;
         player.close();
         if ( visualComponent != null )
              mediaPanel.remove( visualComponent );
         if ( controlsComponent != null )
              mediaPanel.remove( controlsComponent );
         //set background for the JPanel
         public class panelBack extends JPanel
              ImageIcon image;
              panelBack(ImageIcon image)
                   super();
                   this.image=image;
              public void paintComponent(Graphics g)
                   image.paintIcon(this,g,0, 0);
         }//panelback
    void addUsingGBL(Component component,int row, int column, int width, int height)
    gbc = new GridBagConstraints();
         gbc. gridx = row;
         gbc.gridy = column;
         gbc.gridwidth = width;
         gbc.gridheight = height;
         gbLayout.setConstraints(component, gbc);
         mediaPanel.add(component);
         mediaPanel.doLayout();
    }//MediaPlayerDemo

  • GridBagLayout with JScrollPane difficulties

    I'm having problems getting the components in a JPanel to layout properly. I'm using GridBagLayout and I'm having problems with adding a JScollPane.
    The JScrollPane in the layout (holding a subclass of a JPanel as its viewport) does not work properly in some case. When the viewport won't display fully, and requires scroll bars, the JScrollPane shrinks to a tiny size (i think just enough to display minimized scroll bars). What do I mean to add to fix this problem?
    Here is the relavent code:
    public ScenePanel()
         SceneImagePanel sceneImagePanel = new SceneImagePanel("Images/library.jpg");
         JScrollPane sceneScroller = new JScrollPane(sceneImagePanel);
         GridBagLayout gridbag = new GridBagLayout();
         GridBagConstraints c = new GridBagConstraints();
         this.setLayout(gridbag);
         c.insets = new Insets(5,5,5,5);
         JButton b1 = new JButton("Left");
         c.anchor = GridBagConstraints.WEST;
         c.fill = GridBagConstraints.VERTICAL;
         c.gridx = 0;
         c.gridy = 0;
         c.gridwidth = 5;
         c.gridheight = 5;
         c.weightx = 0.5;
         c.weighty = 0.5;
         gridbag.setConstraints(b1, c);
         this.add(b1);
         c.anchor = GridBagConstraints.CENTER;
         c.fill = GridBagConstraints.NONE;
         c.gridx = 5;
         c.gridwidth = 10;
         c.weightx = 0.0;
         c.weighty = 0.0;
         gridbag.setConstraints(sceneScroller, c);
         this.add(sceneScroller);
         JButton b2 = new JButton("Right");
         c.anchor = GridBagConstraints.EAST;
         c.fill = GridBagConstraints.VERTICAL;
         c.gridx = 15;
         c.gridwidth = 5;
         c.weightx = 0.5;
         c.weighty = 0.5;
         gridbag.setConstraints(b2, c);
         this.add(b2);
         JButton b3 = new JButton("Bottom");
         c.anchor = GridBagConstraints.SOUTH;
         c.fill = GridBagConstraints.HORIZONTAL;
         c.gridwidth = 20;
         c.gridx = 0;
         c.gridy = 5;
         c.weighty = -0.5;
         gridbag.setConstraints(b3, c);
         this.add(b3);
    //          this.add(sceneScroller, BorderLayout.CENTER);
    }Note: the commented out line at the end displayed the JScrollPane properly (though I want the scroll pane to be sized to fit its viewport, not its container, so I stopped using BorderLayout)

    Alright, I've figured out why the JScrollPane gets shrunk to such a small size...the 'fill' paramenter of the constraint can't be set to NONE. I've set it to 'BOTH' and changed the other constraints of some other components to fit.
    The problem now is that the scroll pane is too big...the scroll pane does not need to actually have either scroll bar in all cases. To accomidate these situations, I want the scroll pane to only be as large as it needs to be to display as much of its viewport is possible. Meaning, if the viewport does not need the scroll pane to take up as much room as is avaliable to it in the JPanel, the scroll pane should only be as large as needed, and leave empty space around it.
    Here is what I have now:
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    this.setLayout(gridbag);
    c.insets = new Insets(5,5,5,5);
    JButton b1 = new JButton("Left");
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.VERTICAL;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 5;
    c.gridheight = 5;
    c.weightx = -0.5;
    c.weighty = 0.5;
    gridbag.setConstraints(b1, c);
    this.add(b1);
    c.anchor = GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 5;
    c.gridwidth = 10;
    c.weightx = 0.5;
    gridbag.setConstraints(sceneScroller, c);
    this.add(sceneScroller);
    JButton b2 = new JButton("Right");
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.VERTICAL;
    c.gridx = 15;
    c.gridwidth = 5;
    c.weightx = -0.5;
    c.weighty = 0.5;
    gridbag.setConstraints(b2, c);
    this.add(b2);
    JButton b3 = new JButton("Bottom");
    c.anchor = GridBagConstraints.SOUTH;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 20;
    c.gridx = 0;
    c.gridy = 5;
    c.weighty = -0.5;
    gridbag.setConstraints(b3, c);
    this.add(b3);

  • Is it a bug? GridBagLayout  with textField

    Hi,
    The following method does not work fine.
    The textfield field gets all the space
    but if i change
    JTextField field = new JTextField();
    with
    JPanel field = new JPanel();
    it will work fine.
    I think there is a problem with GridBagLayout
    and textField. is it a bug in jdk1.2
    public JPanel getCPane() {
    int XUNIT = 5;
    int YUNIT = 100;
    JPanel pane = new JPanel();
    JPanel pane1 = new JPanel();
    JTextField field = new JTextField();
    pane1.setBackground(Color.red);
    pane1.setPreferredSize(new Dimension(2*XUNIT, YUNIT));
    field.setPreferredSize(new Dimension(6*XUNIT, YUNIT));
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(0,0,0,0);
    c.weightx = c.weighty = 0;
    c.gridx = 0; c.gridy = 0;
    c.gridwidth = 2*XUNIT; c.gridheight = YUNIT;
    pane.add(pane1, c);
    c.weightx = c.weighty = 1;
    c.gridx = 2; c.gridy = 0;
    c.gridwidth = 6*XUNIT; c.gridheight = YUNIT;
    pane.add(field, c);
    return pane;

    Any solution please

Maybe you are looking for

  • VPN - can't access internet over VPN

    Hi, I have an issue with VPN. For my work I need to be able to log into my office network remotely and then access remote desktop connection from within my work network. This won't work unless I am accessing the internet from inside the VPN. I have g

  • I want to delete all transparent pixels, how can I? CS6

    I would like to delete all transparent pixels surrounding my irregularly (non-square) image.  The TRIM function only trims to a square surrounding my image and not to the edge of the image itself.  Is there a work around for this?  I have looked arou

  • Snow Leopard and Powerpoint

    Office '08 . Since installing Snow Leopard I cannot save my work in Powerpoint. I get a message that the file has been moved. What is going on?

  • Controlling external keyboard using MainStage

    Hi guys, i need help... I'm start in the mainstage word. i used cubase for control my vst's and my pc3x kurzweil. a friend show me the mainstage and i loved. It's perfect for vst's control and the interface is very dynamic. but i have a big problem..

  • Business Objects to pull Cognos data

    Hi All, I would like to know whether anyway to pull Cognos data into Business Objects? 1. Pull data thru Universe from Cognos Cubes? 2. Pull data using Crystal reports from Cognos Cubes? 3. Or any otehr method of pulling data from Cognos Cubes? If no