Updating different panels in Swing?

I have a JTabbedPane with panel1, panel2, panel3
and a JButton in panel1. I know I need to addActionListener, etc, but what code would change the display of panel3? (Let's say I just want to display a new JLabel there; ie "Button pressed")
Thanks

Use indexOftab(String) to get the tab index based on the caption of the tab you want.
Use setSelectedIndex(String) to select the tab based on the index you specify.
Use getSelectedComponent() to get the component from the selected tab, such as a JPanel. Then add a JLabel with the caption to this component.
Look at: http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html for more info
Hope this helps.
Riz

Similar Messages

  • Problem updating a control on one panel based on a value change in another control on a different panel

    Hi,
    I am trying to update the value of a control on one panel when the value of another control on a different panel is changed.  The two panels are saved in two different .uir files, so there are two associated .h files generated by CVI.  The problem is that, inside the callback function for the control that is being modified (Ctrl_Id_A on Panel_A), when I call SetCtrlVal(Panel_B, Ctrl_Id_B, Value); 'Panel_B' and 'Ctrl_Id_B' (which have the same numeric values as Panel_A = 1 and Ctrl_Id_A = 2 in their respective .h files) are being interpreted as Panel_A and Ctrl_Id_A.  I never understood how CVI makes this distinction, eg. knowing which of PANEL_A = 1 and PANEL_B = 1 is being referred to, but didn't worry about it since I never needed cross-communication between panels until now.  Any help on how to implement this would be greatly appreciated.  Thanks!
    Solved!
    Go to Solution.

    This is a basic issue on which you can find tons of forum posts
    The online help for the function recitates:
    int SetCtrlVal (int panelHandle, int controlID, ...);
    Parameters
    Input
    Name
    Type
    Description
    panelHandle
    int
    Specifier for a particular panel that is currently in memory. You obtain this
    handle from LoadPanel, NewPanel, or DuplicatePanel.
    controlID
    int
    The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by NewCtrl or DuplicateCtrl.
    value
    New value of the control. The data type of value must match the data type of the control.
    That is, you must not use the panel constant name in the first parameter of SetCtrlVal, use the panel handle instead. The system guarantees that all panel handles are unique throughout the whole application whichever is the number of panels used in every moment.
    int SetCtrlVal (int panelHandle, int controlID, ...);
    Purpose
    Sets the value of a control to a value you specify.
    When you call SetCtrlVal on a list box or a ring control, SetCtrlVal
    sets the current list item to the first item that has the value you
    specify. To set the current list item through a zero-based index, use SetCtrlIndex.
    When you call SetCtrlVal on a text box, SetCtrlVal appends value to the contents of the text box and scrolls the text box to display value. Use ResetTextBox to replace the contents of the text box with value.
    Note   This function updates the displayed value immediately. Use SetCtrlAttribute with ATTR_CTRL_VAL to set the control value without immediately updating the displayed value. For this reason, SetCtrlAttribute with ATTR_CTRL_VAL is generally faster than SetCtrlVal. However, if the control in which you are setting the value is the active control in the panel, SetCtrlAttribute with ATTR_CTRL_VAL displays the value immediately.
    Note   This function is not valid for graph and strip chart controls.
    Parameters
    Input
    Name
    Type
    Description
    panelHandle
    int
    Specifier for a particular panel that is currently in memory. You obtain this
    handle from LoadPanel, NewPanel, or DuplicatePanel.
    controlID
    int
    The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by NewCtrl or DuplicateCtrl.
    value
    New value of the control. The data type of value must match the data type of the control.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • One Components into 2 different panel problems

    Hi,
    I have one component, just call it A, and 2 different
    panels just call it PA and PB.
    I put A into PA and then I put A into PB,
    and display PA & PB into screen together.
    The problem is A is missing in PA but displayed
    into PB. I know this is behavior of AWT/Swing,
    but maybe some of you know how to solve
    this problem without creating two instances of A.
    Thank you in advance...

    You could make something like this:
    public class multicomponent
         Vector activecomponents=new Vector
         //all methods you intend to use on this component this way
         public method(somearg arg)
               for //all c in vector
                   c.method(arg);
          public void addto(Container co)
               comp=new yourcomponent();
               co.add(comp);
               activecomponents.add(comp);
    }You can enhance that by using weak references for the elements in the vector and you will have to think what to do for get methods.

  • Updating a panel within a container

    I am attempting to update a panel within a container. I have tried to search the forum but couldn't find a solution. The codes are listed below. What am I doing wrong?
    package test;
    import java.awt.*;
    import java.awt.Graphics;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.plaf.FontUIResource;
    import javax.swing.plaf.ColorUIResource;
    class Template1 extends JFrame {     
         private static final Dimension screenSize = Toolkit.getDefaultToolkit ().getScreenSize ();
         private JLabel numLockKey, capsLockKey, mode;
         protected Container pane;
         protected JPanel buttonPanel, basePanel;
         public Template1() {
              super("Soybean Candles -- Authorized Personnel Only");                
            buildLayout();       
              setSize(screenSize.width, screenSize.height);                    
                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 setResizable(false);             
              show();                              
         private void buildLayout() {
              pane = getContentPane();
              pane.setLayout(new BorderLayout());          
              basePanel = new JPanel(new BorderLayout());
              basePanel.add(new JLabel(new ImageIcon("C:/GUI/Images/plogo.jpg")), BorderLayout.CENTER);
                pane.add(panel_1(), BorderLayout.NORTH);
                pane.add(basePanel, BorderLayout.CENTER);            
         private JPanel panel_1() {
              buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 10));          
              buttonPanel.setBackground(Color.decode("#526dad"));
              JButton buttons[] = new JButton[3];
              buttonPanel.add(createButton(buttons[0], "TIME CLOCK", new TestAction()));
              buttonPanel.add(createButton(buttons[1], "LOGIN", new LoginAction()));
              buttonPanel.add(createButton(buttons[2], "EXIT", new TestAction()));
              return buttonPanel;
         private JButton createButton(JButton btn, String displayTxt, AbstractAction action) {
              Dimension dim = new Dimension(100, 40);
              btn = new JButton(action);
              btn.setText(displayTxt);          
              btn.setPreferredSize(dim);
              btn.setMaximumSize(dim);
              btn.setMinimumSize(dim);
              btn.setBorder(BorderFactory.createLineBorder(Color.white, 2));
              btn.setBackground(Color.decode("#3e4b84"));
              btn.setForeground(Color.white);          
              btn.setFocusPainted(false);
              btn.setActionCommand(displayTxt);
              return btn;          
         private JPanel panel_2() {          
              basePanel = new JPanel(new BorderLayout());
              basePanel.add(new JLabel(new ImageIcon("C:/GUI/Images/plogo.jpg")), BorderLayout.CENTER);
              return basePanel;
         public static void main(String args[]) {
              UIManager.put("Label.font", new FontUIResource(new Font("Arial", Font.PLAIN, 12)));
              UIManager.put("Button.font", new FontUIResource(new Font("Arial", Font.PLAIN, 12)));
              Template1 tpl = new Template1();
         class TestAction extends AbstractAction {             
                 public void actionPerformed(ActionEvent e) {
                      System.out.println("button pressed");
            class LoginAction extends AbstractAction {
                 public void actionPerformed(ActionEvent e) {
                      basePanel.invalidate();
                    basePanel = new JPanel();
                   basePanel.add(new JLabel("test"));
                   basePanel.repaint();               
    }

    You're creating a new panel every time an action is performed. That panel is never going to be visible unless you add it to the frame.
    Either remove the old panel and add the new panel or add the label to the panel you already have without creating a new one. Then call validate on the whole frame, and it should work.

  • Plz lookin "different panels which can place where ever we need"

    in one jsp how can we create different panels to display where each panel can collapse and can invisible by checking or unchecking it dynamically and each panel can be placed by the user where ever he need it that too the request should not go to the server when user changes the each panels state......
    (any doubts regarding this query are welcome)
    can any one help me out.

    The problem is that this forum does OR logic for its searches.  The most specific you can be is to use only the most unique word you have to use in a normal search.  Otherwise, use a regular web search and specify which site you want to see results
    for.   E.g. in BING or Google you would use the  site:technet.microsoft.com/forums  query term.
    This looks like a very simple case of 'bad engineering'.
    If I am going to have to go out to Google in order to perform a search to get s decent result for a Microsoft database, that really doesn't speak well of Microsoft.
    Sadly however, it really is the case that I get substantially better, more accurate results when using Google then when using Microsoft's TechNet directly - even when the answer is a TechNet forum or knowledgebase article.
    This said, it really doesn't address the question at hand in any way whatsoever.  If you direct your attention to the source question (should be recognizable as it is the big bold letters at the top listed under "Title") the answer being sought
    is regarding finding a way or a person who can "update the product list checkboxes on the left of the Technet search results" - as these, in fact, DO play a role in narrowing out unwanted search results, they are merely being terribly neglected.

  • Reload different panels

    Hello all,
    Like to reload different panels onto the same load panel.
    Code sample below on what I'am trying to achieve
    Each panel size would like to be 45% of window size.
    Have problems of reloading different panels to achieve the size and
    also when resizing the window
    Have 8 dukes to get rid of from:
    http://forum.java.sun.com/thread.jsp?forum=43&thread=431639
    Thanks
    Abraham Khalil
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.*;
    * Want to test reloading panels of very different text sizes inside it<br>
    * The goal is no matter want the label text size is, each label panel should only
    * show a maximum of 45% of the window size. <br>
    * <p>
    * Each button on the right will show a more uglier panel to load
    public class PanelChangeTest extends JFrame implements ActionListener {
       private static final int WIDTH = 640;
       private static final int HEIGHT = 400;
       private static final String BUTTON_PANEL_TEST1 = "Load Normal Panel";
       private static final String BUTTON_PANEL_TEST2 = "Load bit ugly Panel";
       private static final String BUTTON_PANEL_TEST3 = "Load very ugly Panel";
       private static final String[] BUTTON_COMMANDS = {
                                                         BUTTON_PANEL_TEST1,
                                                         BUTTON_PANEL_TEST2,
                                                         BUTTON_PANEL_TEST3
       private JPanel loadPanel = new JPanel();
       private PanelChange[] testPanels = null;
        * Model for each panel. <br>
        * Each panel contain email fields of from, to, subject and cc
       private class PanelFields {
          private String from = null;
          private String to = null;
          private String subject = null;
          private String cc = null;
          public PanelFields(String from, String to, String subject, String cc) {
             this.from = from;
             this.to = to;
             this.subject = subject;
             this.cc = cc;
          public String getFrom() {
             return from;
          public String getTo() {
             return to;
          public String getSubject() {
             return subject;
          public String getCC() {
             return cc;
       } // End PanelFields class
        * View panel class <br>
        * Each panel change class will contain four panels and they are from, to, cc and subject panel. <br>
        * Each of the from, to, cc and subject panel contain two labels, one for description and other for
        * its text value.
        * Want to set each panel size to 45% of window size so it looks even, and if label text is too long
        * to fit in 45% view, it should truncate it..
       private class PanelChange extends JPanel {
          private static final float PERCENT = 1 / 100.0f;
          private static final float EACH_PANEL_SIZE = 45 * PERCENT;
          private JPanel getPanel(String labelForText, String text) {
             JLabel labelLeft = new JLabel(labelForText, JLabel.LEFT);
             JLabel labelRight = new JLabel(text, JLabel.LEFT);
             setBold(labelLeft, true);
             JPanel panel = new JPanel();
             panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
             panel.add(labelLeft);
             panel.add(labelRight);
             panel.setBorder(BorderFactory.createLineBorder(Color.blue));
             return panel;
          public void recalculate(Dimension parentSize) {
             Dimension eachPanelSize = new Dimension((int) (parentSize.width * EACH_PANEL_SIZE), 12);
             System.out.println("Parent size = (" + parentSize.width + ", " + parentSize.height + ")\n" +
                                "Each panel size is recalculated as (" + eachPanelSize.width + ", " + eachPanelSize.height + ")\n");
             Component[] components = getComponents();       
             for (int eachPanel = 0 ; eachPanel < components.length ; eachPanel++) {
                JComponent panel = (JComponent) components[eachPanel];
                panel.setMaximumSize(eachPanelSize);
                panel.setMinimumSize(eachPanelSize);
                panel.setSize(eachPanelSize);
          public PanelChange(PanelFields panelFields) {
             JPanel fromPanel = getPanel("From: ", panelFields.getFrom());
             JPanel toPanel = getPanel("To: ", panelFields.getTo());        
             JPanel subjectPanel = getPanel("Subject: ", panelFields.getSubject());
             JPanel ccPanel = getPanel("CC: ", panelFields.getCC());
             setLayout(new BorderLayout());
             JPanel panel = new JPanel();
             // Test with panel of GridLayout instead of GridBagLayout to see the difference...     
             panel.setLayout(new GridLayout(2, 2, 5, 5));
             panel.add(fromPanel);
             panel.add(toPanel);
             panel.add(subjectPanel);
             panel.add(ccPanel);
             panel.setLayout(new GridBagLayout());
             constrain(panel, fromPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       0, 0, 1, 1, 1.0, 0.0);
             constrain(panel, toPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       1, 0, 1, 1, 1.0, 0.0);
             constrain(panel, subjectPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       0, 1, 1, 1, 1.0, 0.0);
             constrain(panel, ccPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       1, 1, 1, 1, 1.0, 0.0);
             add(panel, BorderLayout.CENTER);
          private int getFontStyle(Component component, boolean makeBold) {
             int style = 0;
             if (component != null) {
                Font f = component.getFont();
                if (f != null) {
                   if (f.isPlain()) style = style | Font.PLAIN;
                   if (f.isItalic()) style = style | Font.ITALIC;
                   if (makeBold) style = style | Font.BOLD;
             return style;
          private void setBold(Component component, boolean makeBold) {
             int style = getFontStyle(component, makeBold);
             Font styleFont = component.getFont().deriveFont(style);
             component.setFont(styleFont);
       } // End PanelChange class
       public void constrain( Container container, Component component, 
                              int fill, int anchor,
                              int gx, int gy, int gw, int gh, double wx, double wy ) {
          GridBagConstraints c = new GridBagConstraints();
          c.fill = fill;
          c.anchor = anchor;
          c.gridx = gx;
          c.gridy = gy;
          c.gridwidth = gw;
          c.gridheight = gh;
          c.weightx = wx;
          c.weighty = wy;
          ( (GridBagLayout) container.getLayout() ).setConstraints( component, c );
          container.add( component );
       public void constrain( Container container, Component component, 
                              int fill, int anchor,
                              int gx, int gy, int gw, int gh,
                              double wx, double wy, Insets inset ) {
          GridBagConstraints c = new GridBagConstraints();
          c.fill = fill;
          c.anchor = anchor;
          c.gridx = gx;
          c.gridy = gy;
          c.gridwidth = gw;
          c.gridheight = gh;
          c.weightx = wx;
          c.weighty = wy;
          c.insets = inset;
          ( (GridBagLayout) container.getLayout() ).setConstraints( component, c );
          container.add( component );
       private void initPanels() {
          PanelFields okPanel = new PanelFields("Simple from...",
                                                "[email protected]; [email protected]",
                                                "Simple subject...",
                                                "[email protected]; [email protected]");
          PanelFields bitUglyPanel = new PanelFields("A bit ugly from................",
                                                     "[email protected]; [email protected]; [email protected]; [email protected]",
                                                     "A bit ungle subject.....................",
                                                     "[email protected]; [email protected]; [email protected]; [email protected]");
          PanelFields veryUglyPanel = new PanelFields("A very very very very very " +
                                                      "very very ugly from................",
                                                      "[email protected]; [email protected]; [email protected]; [email protected], " +
                                                      "[email protected]; [email protected]; [email protected]; [email protected]",
                                                      "A very very very very very very " +
                                                      "very ungle subject.....................",
                                                      "[email protected]; [email protected]; [email protected]; [email protected]; " +
                                                      "[email protected]; [email protected]; [email protected]; [email protected]");
          testPanels = new PanelChange[] {
                                            new PanelChange(okPanel),
                                            new PanelChange(bitUglyPanel),
                                            new PanelChange(veryUglyPanel)
          Container container = getContentPane();
          container.setLayout(new BorderLayout());
          JPanel buttonPanel = new JPanel();
          buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
          JButton button1 = new JButton(BUTTON_PANEL_TEST1);
          button1.setActionCommand(BUTTON_PANEL_TEST1);
          button1.addActionListener(this);
          JButton button2 = new JButton(BUTTON_PANEL_TEST2);
          button2.setActionCommand(BUTTON_PANEL_TEST2);
          button2.addActionListener(this);
          JButton button3 = new JButton(BUTTON_PANEL_TEST3);
          button3.setActionCommand(BUTTON_PANEL_TEST3);
          button3.addActionListener(this);
          buttonPanel.add(button1);
          buttonPanel.add(Box.createHorizontalStrut(5));
          buttonPanel.add(button2);
          buttonPanel.add(Box.createHorizontalStrut(5));
          buttonPanel.add(button3);
          JPanel mainPanel = new JPanel();
          mainPanel.setLayout(new GridBagLayout());
          constrain(mainPanel, loadPanel,
                    GridBagConstraints.BOTH, GridBagConstraints.WEST,
                    0, 0, 1, 1, 1.0, 1.0, new Insets(5, 5, 5, 5));
          constrain(mainPanel, buttonPanel,
                    GridBagConstraints.NONE, GridBagConstraints.CENTER,
                    0, 1, 1, 1, 0.0, 0.0, new Insets(5, 5, 5, 5));
          container.add(mainPanel);
       private void setupLoadPanel(PanelChange panelToLoad) {
          loadPanel.removeAll();
          panelToLoad.recalculate(getSize());
          loadPanel.add(panelToLoad);
          loadPanel.revalidate();     
       public void actionPerformed(ActionEvent e) {
          String actionCommand = e.getActionCommand();
          for (int i = 0 ; i < BUTTON_COMMANDS.length ; i++) {
             if (actionCommand.equals(BUTTON_COMMANDS)) {
    setupLoadPanel(testPanels[i]);
    break;
    public PanelChangeTest() {
    super("Panel change test...");
    Dimension size = new Dimension(WIDTH, HEIGHT);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screenSize.width - size.width) / 2;
    int y = (screenSize.height - size.height) / 2;
    setBounds(x, y, WIDTH, HEIGHT);
    addWindowListener(new WindowAdapter() {
    public void windowClosing( WindowEvent e ) {
    System.exit(0);
    FontUIResource standardFont = new FontUIResource("dialogPlain11", Font.PLAIN, 11);
    UIManager.put("Label.font", standardFont);
    UIManager.put("Button.font", standardFont);
    initPanels();
    public static void main(String args[]) {
    new PanelChangeTest().setVisible(true);

    Please use the following code below:
    Somehow it doesn't show the text if it can't fit inside the panel.
    When resize to full screen, it shows the text??
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.*;
    * Want to test reloading panels of very different text sizes inside it<br>
    * The goal is no matter want the label text size is, each label panel should only
    * show a maximum of 45% of the window size. <br>
    * <p>
    * Each button on the right will show a more uglier panel to load
    public class PanelChangeTest extends JFrame implements ActionListener {
       private static final int WIDTH = 640;
       private static final int HEIGHT = 400;
       private static final String BUTTON_PANEL_TEST1 = "Load Normal Panel";
       private static final String BUTTON_PANEL_TEST2 = "Load bit ugly Panel";
       private static final String BUTTON_PANEL_TEST3 = "Load very ugly Panel";
       private static final String[] BUTTON_COMMANDS = {
                                                         BUTTON_PANEL_TEST1,
                                                         BUTTON_PANEL_TEST2,
                                                         BUTTON_PANEL_TEST3
       private JPanel loadPanel = new JPanel();
       private PanelChange[] testPanels = null;
        * Model for each panel. <br>
        * Each panel contain email fields of from, to, subject and cc
       private class PanelFields {
          private String from = null;
          private String to = null;
          private String subject = null;
          private String cc = null;
          public PanelFields(String from, String to, String subject, String cc) {
             this.from = from;
             this.to = to;
             this.subject = subject;
             this.cc = cc;
          public String getFrom() {
             return from;
          public String getTo() {
             return to;
          public String getSubject() {
             return subject;
          public String getCC() {
             return cc;
       } // End PanelFields class
        * View panel class <br>
        * Each panel change class will contain four panels and they are from, to, cc and subject panel. <br>
        * Each of the from, to, cc and subject panel contain two labels, one for description and other for
        * its text value.
        * Want to set each panel size to 45% of window size so it looks even, and if label text is too long
        * to fit in 45% view, it should truncate it..
       private class PanelChange extends JPanel {
          private static final float PERCENT = 1 / 100.0f;
          private static final float EACH_PANEL_SIZE = 45 * PERCENT;
          public PanelChange(PanelFields panelFields) {
             JPanel fromPanel = getPanel("From: ", panelFields.getFrom());
             JPanel toPanel = getPanel("To: ", panelFields.getTo());        
             JPanel subjectPanel = getPanel("Subject: ", panelFields.getSubject());
             JPanel ccPanel = getPanel("CC: ", panelFields.getCC());
             setLayout(new BorderLayout());
             JPanel panel = new JPanel();
             // Test with panel of GridLayout instead of GridBagLayout to see the difference...     
             panel.setLayout(new GridLayout(2, 2, 5, 5));
             panel.add(fromPanel);
             panel.add(toPanel);
             panel.add(subjectPanel);
             panel.add(ccPanel);
             panel.setLayout(new GridBagLayout());
             constrain(panel, fromPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       0, 0, 1, 1, 1.0, 0.0);
             constrain(panel, toPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       1, 0, 1, 1, 1.0, 0.0);
             constrain(panel, subjectPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       0, 1, 1, 1, 1.0, 0.0);
             constrain(panel, ccPanel,
                       GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST,
                       1, 1, 1, 1, 1.0, 0.0);
             add(panel, BorderLayout.CENTER);
          public void recalculate(Dimension parentSize) {
             Dimension eachPanelSize = new Dimension((int) (parentSize.width * EACH_PANEL_SIZE), 20);
             System.out.println("Parent size = (" + parentSize.width + ", " + parentSize.height + ")\n" +
                                "Each panel size is recalculated as (" + eachPanelSize.width + ", " + eachPanelSize.height + ")\n");
             JPanel mainPanel = (JPanel) getComponent(0);
             Component[] components = mainPanel.getComponents();
             for (int eachPanel = 0 ; eachPanel < components.length ; eachPanel++) {
                JComponent panel = (JComponent) components[eachPanel];
                panel.setMaximumSize(eachPanelSize);
                panel.setMinimumSize(eachPanelSize);
                panel.setPreferredSize(eachPanelSize);
          private JPanel getPanel(String labelForText, String text) {
             JLabel labelLeft = new JLabel(labelForText, JLabel.LEFT);
             JLabel labelRight = new JLabel(text, JLabel.LEFT);
             setBold(labelLeft, true);
             JPanel panel = new JPanel();
             panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
             panel.add(labelLeft);
             panel.add(labelRight);
             panel.setBorder(BorderFactory.createLineBorder(Color.blue));
             return panel;
          private int getFontStyle(Component component, boolean makeBold) {
             int style = 0;
             if (component != null) {
                Font f = component.getFont();
                if (f != null) {
                   if (f.isPlain()) style = style | Font.PLAIN;
                   if (f.isItalic()) style = style | Font.ITALIC;
                   if (makeBold) style = style | Font.BOLD;
             return style;
          private void setBold(Component component, boolean makeBold) {
             int style = getFontStyle(component, makeBold);
             Font styleFont = component.getFont().deriveFont(style);
             component.setFont(styleFont);
       } // End PanelChange class
       public void constrain( Container container, Component component, 
                              int fill, int anchor,
                              int gx, int gy, int gw, int gh, double wx, double wy ) {
          GridBagConstraints c = new GridBagConstraints();
          c.fill = fill;
          c.anchor = anchor;
          c.gridx = gx;
          c.gridy = gy;
          c.gridwidth = gw;
          c.gridheight = gh;
          c.weightx = wx;
          c.weighty = wy;
          ( (GridBagLayout) container.getLayout() ).setConstraints( component, c );
          container.add( component );
       public void constrain( Container container, Component component, 
                              int fill, int anchor,
                              int gx, int gy, int gw, int gh,
                              double wx, double wy, Insets inset ) {
          GridBagConstraints c = new GridBagConstraints();
          c.fill = fill;
          c.anchor = anchor;
          c.gridx = gx;
          c.gridy = gy;
          c.gridwidth = gw;
          c.gridheight = gh;
          c.weightx = wx;
          c.weighty = wy;
          c.insets = inset;
          ( (GridBagLayout) container.getLayout() ).setConstraints( component, c );
          container.add( component );
       private void initPanels() {
          PanelFields okPanel = new PanelFields("Simple from...",
                                                "[email protected]; [email protected]",
                                                "Simple subject...",
                                                "[email protected]; [email protected]");
          PanelFields bitUglyPanel = new PanelFields("A bit ugly from................",
                                                     "[email protected]; [email protected]; [email protected]; [email protected]",
                                                     "A bit ungle subject.....................",
                                                     "[email protected]; [email protected]; [email protected]; [email protected]");
          PanelFields veryUglyPanel = new PanelFields("A very very very very very " +
                                                      "very very ugly from................",
                                                      "[email protected]; [email protected]; [email protected]; [email protected], " +
                                                      "[email protected]; [email protected]; [email protected]; [email protected]",
                                                      "A very very very very very very " +
                                                      "very ungle subject.....................",
                                                      "[email protected]; [email protected]; [email protected]; [email protected]; " +
                                                      "[email protected]; [email protected]; [email protected]; [email protected]");
          testPanels = new PanelChange[] {
                                            new PanelChange(okPanel),
                                            new PanelChange(bitUglyPanel),
                                            new PanelChange(veryUglyPanel)
          Container container = getContentPane();
          container.setLayout(new BorderLayout());
          JPanel buttonPanel = new JPanel();
          buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
          JButton button1 = new JButton(BUTTON_PANEL_TEST1);
          button1.setActionCommand(BUTTON_PANEL_TEST1);
          button1.addActionListener(this);
          JButton button2 = new JButton(BUTTON_PANEL_TEST2);
          button2.setActionCommand(BUTTON_PANEL_TEST2);
          button2.addActionListener(this);
          JButton button3 = new JButton(BUTTON_PANEL_TEST3);
          button3.setActionCommand(BUTTON_PANEL_TEST3);
          button3.addActionListener(this);
          buttonPanel.add(button1);
          buttonPanel.add(Box.createHorizontalStrut(5));
          buttonPanel.add(button2);
          buttonPanel.add(Box.createHorizontalStrut(5));
          buttonPanel.add(button3);
          JPanel mainPanel = new JPanel();
          mainPanel.setLayout(new GridBagLayout());
          constrain(mainPanel, loadPanel,
                    GridBagConstraints.BOTH, GridBagConstraints.WEST,
                    0, 0, 1, 1, 1.0, 1.0, new Insets(5, 5, 5, 5));
          constrain(mainPanel, buttonPanel,
                    GridBagConstraints.NONE, GridBagConstraints.CENTER,
                    0, 1, 1, 1, 0.0, 0.0, new Insets(5, 5, 5, 5));
          container.add(mainPanel);
       private void setupLoadPanel(PanelChange panelToLoad) {
          loadPanel.removeAll();
          Dimension parentSize = getSize();
          panelToLoad.recalculate(parentSize);     
          loadPanel.add(panelToLoad);
          loadPanel.revalidate();
          loadPanel.repaint(); 
       public void actionPerformed(ActionEvent e) {
          String actionCommand = e.getActionCommand();
          for (int i = 0 ; i < BUTTON_COMMANDS.length ; i++) {
             if (actionCommand.equals(BUTTON_COMMANDS)) {
    setupLoadPanel(testPanels[i]);
    break;
    public PanelChangeTest() {
    super("Panel change test...");
    Dimension size = new Dimension(WIDTH, HEIGHT);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screenSize.width - size.width) / 2;
    int y = (screenSize.height - size.height) / 2;
    setBounds(x, y, WIDTH, HEIGHT);
    addWindowListener(new WindowAdapter() {
    public void windowClosing( WindowEvent e ) {
    System.exit(0);
    FontUIResource standardFont = new FontUIResource("dialogPlain11", Font.PLAIN, 11);
    UIManager.put("Label.font", standardFont);
    UIManager.put("Button.font", standardFont);
    initPanels();
    public static void main(String args[]) {
    new PanelChangeTest().setVisible(true);

  • Data communication b/w different panels!!!

    I have two different panels CFtree and CMyTab and I am trying to call a function of CFtree from CMyTab
    //+++++++++++++++++++++++++++++
    //CFtree code...
    // Generating only one object of this class like
    public class CFTree extends JTree implements ActionListener {
    private static CFTree objFeatureTree = null;
    public static CFTree createObject() {
    if (objFeatureTree == null) {
    objFeatureTree = new CFTree();
    return objFeatureTree;
    return objFeatureTree;
    * Get object of CFTree
    * @return CFTree
    public static CFTree getObject() {
    return objFeatureTree;
    public void dummy(){
    System.out.println("Feature tree function called");
    // CMyTab pseudo-code..
    public class CMyTab
    extends JPanel {
    CFTree mFtrTree = CFTree.getObject(); // calling to get current object of CFTree
    // and function acess like
    mFtrTree.dummy();
    As soon as mFtrTree.dummy() is called, following exception is thrown:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    What can be the reason for this? How can I specify in CMyTab that it is going to call a function placed in a different panel CFTree. What are the way to tackle this problem?
    Please comment!
    Thanks,
    rdh

    In the following statement, please replace "getObject" with "createObject":
    CFTree mFtrTree = CFTree.getObject(); // calling to get current object of CFTree

  • Set Cursor.vi fails after it has been called for 30 different panel refs in LV 7.1.1

    Make sure both attached files (Run LabVIEW_Cursor_TestCase.vi, SimpleVI.vi) are in the same folder. Run LabVIEW_Cursor_TestCase.vi notice that the -3 error code is returned from "Set Cursor.vi" after it has been called with 30 different panel refs. If "Set Cursor.vi" is replaced with "Set Busy.vi" the same error occurs.Is there a workaround for this problem other that setting the cursor image manually in user32.dll? I must be able to open more than 30 panels and set them all to busy. In the test case I used a single VI, simply to demonstrate the error.
    Message Edited by Jerred on 05-04-2007 10:06 AM
    Attachments:
    LabVIEW_Cursor_TestCase.vi ‏68 KB
    SimpleVI.vi ‏13 KB

    This bug is fixed in LabVIEW 8.0 and later.  Unfortunately, I know of no workaround in LabVIEW 7.x.  When I encountered this bug in one of my UIs in LabVIEW 7.x, my "fix" was simply to ignore the error outputs from the cursor VIs, and to live with the fact that I had no custom cursors after 30 windows had been opened.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Spry Accordion Different Panel Heights

    I'm building a Spry Accordion Widget as a left nav menu with
    25 different panels. Some of my panels contain 10 different links
    and others contain only 1 single link. Therefore I would like to
    adjust the height of each panel individually according to the
    number of links they contain, so I don't end up with huge white
    spaces in panels that contain fewer links. My initial idea, in
    addition to the .AccordionPanelContent class was to add an "id" to
    each panel and control each panels height through CSS. But for some
    reason I haven't been successful that way. It looks like all panels
    tend to take the height of the first panel, regardless of their
    individual set heights. I wonder if I can resolve my problem
    uniquely with CSS, or I do I have to go and change something in the
    SpryAccordion.js file.
    Thanks.

    Hi Donald, I inserted <script type="text/javascript">
    var acc1 = new Spry.Widget.Accordion("Acc1", {
    useFixedPanelHeights: false });
    </script> into my code. It's almost there, but not
    quite. I can see that it is trying to re-ajust the panels' height,
    but for panels that have a larger content it tends to show the
    whole panel's content and then hides the half of it. Also for
    panels with fewer content it doesn't seem to have an effect at all.
    I don't know if I have to fix something in the CSS or place the
    Acc1 ID in a different location within my accordion HTML code.
    Thank you.
    Here's the URL I'm working on if you want to take a look.
    http://64.49.218.100/product_p/00-120-0ll.htm

  • Why is the Amber update different for ATT and Chin...

    Why is the Amber update different for ATT and China? For Lumia 520, it could tap to unlock but, in china, this function is disappeared disappear. Could you give an expain as the matching hardware, otherwise I think it's a definately discriminatory to Chinese.

    Double tap to unlock is not available for any 520, anywhere in the world. See link below. You should always check first before making allegations. 
    http://discussions.nokia.com/t5/Nokia-Lumia/quot-Missing-quot-new-features-in-Amber/td-p/2061872

  • Urgent!!!Want to add different panels in different rows..

    i am trying to add different Panels in differnt rows of same column..
    But each time i am getting the default panel which is being retuned by the MyTableCellRenderer class which i have implemented from TableCellRenderer .
    Would you like reply whats wrong in my approach...Can anyone modify my code???
    public class TablePanel extends JPanel
    JTable alertInsertTable;
    JScrollPane alertInsertPane;
    String columnnames[]={"Insert Alert"};
    Object[][] values={
    new JPanel()
    DefaultTableModel tableModel= new DefaultTableModel(values,columnnames);
    TablePanel()
    setLayout(new BorderLayout());
    alertInsertTable= new JTable(tableModel);
    alertInsertPane = new JScrollPane(alertInsertTable);
    alertInsertTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    this.add(alertInsertPane,BorderLayout.CENTER);
    setDataInTable();
    public void setDataInTable()
    int count=0;
    alertInsertTable.setRowHeight(80);
    MyTableCellRenderer ob=new MyTableCellRenderer();
    this.alertInsertTable.getColumn("Insert Alert").setCellRenderer(ob);
    JPanel panel1=new JPanel();
    JPanel panel2=new JPanel();
    panel1.add(new JLabel("HIiiiiiiiiiiiiiii"));
    panel2.add(new JLabel("Hellooooooooooooo"));
    Object[] ob1={panel1};
    Object[] ob2={panel2};
    model.addRow(ob1);
    //its always adding to the Panel with label new JLabel("Oppsssss")
    //which is the panel instance returned by MyTableCellRender
    model.addRow(ob2);
    // this also adding to the Panel with label new JLabel("Oppsssss")
    //which is the panel instance returned by MyTableCellRender
    // ? What code should i write here so that i can add panel1 and panel2
    //which i have created here.
    class MyTableCellRenderer extends JPanel implements TableCellRenderer
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex)
         JPanel panel = new JPanel();
         panel.add(new JLabel("Oppsssss"));
    return panel;
    }

    Only three exclamation marks; can't be that urgent.And only 1 cross-post...
    Let's continue here:
    http://forum.java.sun.com/thread.jspa?threadID=742590

  • Adding different images to different panels

    If I am having a class which is extending Applet not JApplet and in that I am having CardLayout with 4 different panels. If I want to add 4 different images 2 these Panels what is the solution? Can anyone please help?

    sorry
    myPanel p1, p2, p3, p4;
    class myPanel extends Panel
    Image image;
    public myPanel(Image img)
    image = img;
    public void paint (Graphics g)
    if (image == null)
    return;
    g.drawImage(image, 0, 0, this);
    }

  • Deadlock when updating different rows on a single table with one clustered index

    Deadlock when updating different rows on a single table with one clustered index. Can anyone explain why?
    <event name="xml_deadlock_report" package="sqlserver" timestamp="2014-07-30T06:12:17.839Z">
      <data name="xml_report">
        <value>
          <deadlock>
            <victim-list>
              <victimProcess id="process1209f498" />
            </victim-list>
            <process-list>
              <process id="process1209f498" taskpriority="0" logused="1260" waitresource="KEY: 8:72057654588604416 (8ceb12026762)" waittime="1396" ownerId="1145783115" transactionname="implicit_transaction"
    lasttranstarted="2014-07-30T02:12:16.430" XDES="0x3a2daa538" lockMode="X" schedulerid="46" kpid="7868" status="suspended" spid="262" sbid="0" ecid="0" priority="0"
    trancount="2" lastbatchstarted="2014-07-30T02:12:16.440" lastbatchcompleted="2014-07-30T02:12:16.437" lastattention="1900-01-01T00:00:00.437" clientapp="Internet Information Services" hostname="CHTWEB-CH2-11P"
    hostpid="12776" loginname="chatuser" isolationlevel="read uncommitted (1)" xactid="1145783115" currentdb="8" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
               <inputbuf>
    UPDATE analyst_monitor SET cam_status = N'4', cam_event_data = N'sales1', cam_event_time = current_timestamp , cam_modified_time = current_timestamp , cam_room = '' WHERE cam_analyst_name=N'ABCD' AND cam_window= 2   </inputbuf>
              </process>
              <process id="process9cba188" taskpriority="0" logused="2084" waitresource="KEY: 8:72057654588604416 (2280b457674a)" waittime="1397" ownerId="1145783104" transactionname="implicit_transaction"
    lasttranstarted="2014-07-30T02:12:16.427" XDES="0x909616d28" lockMode="X" schedulerid="23" kpid="8704" status="suspended" spid="155" sbid="0" ecid="0" priority="0"
    trancount="2" lastbatchstarted="2014-07-30T02:12:16.440" lastbatchcompleted="2014-07-30T02:12:16.437" lastattention="1900-01-01T00:00:00.437" clientapp="Internet Information Services" hostname="CHTWEB-CH2-11P"
    hostpid="12776" loginname="chatuser" isolationlevel="read uncommitted (1)" xactid="1145783104" currentdb="8" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
                <inputbuf>
    UPDATE analyst_monitor SET cam_status = N'4', cam_event_data = N'sales2', cam_event_time = current_timestamp , cam_modified_time = current_timestamp , cam_room = '' WHERE cam_analyst_name=N'12345' AND cam_window= 1   </inputbuf>
              </process>
            </process-list>
            <resource-list>
              <keylock hobtid="72057654588604416" dbid="8" objectname="CHAT.dbo.analyst_monitor" indexname="IX_Clust_scam_an_name_window" id="lock4befe1100" mode="X" associatedObjectId="72057654588604416">
                <owner-list>
                  <owner id="process9cba188" mode="X" />
                </owner-list>
                <waiter-list>
                  <waiter id="process1209f498" mode="X" requestType="wait" />
                </waiter-list>
              </keylock>
              <keylock hobtid="72057654588604416" dbid="8" objectname="CHAT.dbo.analyst_monitor" indexname="IX_Clust_scam_an_name_window" id="lock18ee1ab00" mode="X" associatedObjectId="72057654588604416">
                <owner-list>
                  <owner id="process1209f498" mode="X" />
                </owner-list>
                <waiter-list>
                  <waiter id="process9cba188" mode="X" requestType="wait" />
                </waiter-list>
              </keylock>
            </resource-list>
          </deadlock>
        </value>
      </data>
    </event>

    To be honest, I don't think the transaction is necessary, but the developers put it there anyway. The select statement will put the result cam_status
    into a variable, and then depends on its value, it will decide whether to execute the second update statement or not. I still can't upload the screen-shot, because it says it needs to verify my account at first. No clue at all. But it is very simple, just
    like:
    Clustered Index Update
    [analyst_monitor].[IX_Clust_scam_an_name_window]
    cost: 100%
    By the way, for some reason, I can't find the object based on the associatedObjectId listed in the XML
    <keylock hobtid="72057654588604416" dbid="8" objectname="CHAT.dbo.analyst_monitor"
    indexname="IX_Clust_scam_an_name_window" id="lock4befe1100" mode="X" associatedObjectId="72057654588604416">
    For example: 
    SELECT * FROM sys.partition WHERE hobt_id = 72057654588604416
    This return nothing. Not sure why.

  • Updating different Databases Using XI

    Hello,
    I am having one requirement for updating different databases using XI.
    The scenario is that
    Data is coming from ERP to XI.
    This data should be inserted or updated in SQL server.
    Depending on certain conditions I need to update different SQL servers.
    Currently I am having one interface which updates one SQL server database.
    I want to change that interface for updating different SQL server databases depending on the data coming from ERP.
    Is it possible?
    How can I achieve this?
    Thanks in Advance
    Abhijit.

    Hi abi,
        For using more than one database server u can use the BPM.
        there in the design phase, while u making the layout of the picture type connection , there in the switch tool , u can put the condition and according to that
    it will connect to the database server.......
    if it is useful give the rewards
    Regards
    Sasi.........

  • Is software update different than iPhone software update?

    Is the v2.0.x iPod Touch update different than the iPhone version in terms of how it authenticates to networks? At work, an iPhone can authenticate just fine, but my iPod Touch (@ v 2.0.1) can not. It spins and spins saying it is connecting, but never does. Thx.

    You have to do more than just restart to apply a firmware update.
    Complete instructions are available here.

Maybe you are looking for

  • I am unable to scan from my HP all in one printer/scanner

    Since installing Mavericks I am unable to scan using my HP printer/scanner.  I have uninstalled the software and tried to just use Apple method - but really cannot find out how to scan and save.  Does anyone have any ideas?

  • Mcxd.app reports errors in system.log

    Hello! On every startup of my mac os x server I get the following entries in system.log from mcxd.app. Oct 9 20:34:45 sebastian /System/Library/CoreServices/mcxd.app/Contents/MacOS/mcxd: DSGetLocallyHostedNodeNames(): dsFindDirNode() == -14008 Oct 9

  • Opening a selection screen in display mode

    I have an ALV grid created in OOPS. Each line of this ALV has name of a report and its variant name. Here I have created a button on toolbar. When a user selects a line and clicks this button, selection screen of the selected report is to be opened i

  • Problem in sorting with date

    Hi, I have a requirement of sorting a column which displays date or a comment. Because of the presence of comment in some of the rows, the data type is not maintained as Date but as String. That is cause of problem as the dates are getting sorted as

  • Retrieve error description from PCI-7334 board with VB

    Even with the examples provided by NI I get the error "Compile error. By Ref argument type mismatch" on argument "errordescription of function "flex_get_error_description". Try it with the "One-Axis Move with Position Monitor.vbp" project. Select an