How to a particular panel in a tabbed pane to the front?

Hello
I have a small application that uses a tabbed pane. At some point I want to press a button in one of the panels of the tabbed pane and then another panel in the same tabbed pane to show up, as if I had clicked on that tab to bring it to the front.
Only difference is I don't want to click on the tab to do it but on another button, so I can do some more stuff through the button before I bring the other panel to the front
I thought I could do this by getting focus, but it seems not to be the case. Getting focus does not mean coming to the front as I originally thought.
I hope this is clear. Here is an example that you can compile and run. I want to get jpanel2 to the front by clicking jbutton1 and vice versa.
Any help appreciated.
(Frame1.java)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame {
    private JTabbedPane jTabbedPane1 = new JTabbedPane();
    private JPanel jPanel1 = new JPanel();
    private JPanel jPanel2 = new JPanel();
    private JButton jButton1 = new JButton();
    private JButton jButton2 = new JButton();
    private JTextField jTextField1 = new JTextField();
    private JTextField jTextField2 = new JTextField();
    public Frame1() {
        try {
            jbInit();
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            setVisible(true);
        } catch (Exception e) {
            e.printStackTrace();
    private void jbInit() throws Exception {
        this.getContentPane().setLayout( null );
        this.setSize( new Dimension(400, 300) );
        jTabbedPane1.setBounds(new Rectangle(0, 0, 395, 270));
        jPanel1.setLayout(null);
        jPanel2.setLayout(null);
        jButton1.setText("jButton1");
        jButton1.setBounds(new Rectangle(20, 170, 160, 25));
        jButton1.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jButton1_actionPerformed(e);
        jButton2.setText("jButton2");
        jButton2.setBounds(new Rectangle(20, 135, 160, 25));
        jButton2.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jButton2_actionPerformed(e);
        jTextField1.setBounds(new Rectangle(55, 45, 210, 20));
        jTextField2.setBounds(new Rectangle(95, 50, 180, 20));
        jPanel1.add(jTextField1, null);
        jPanel1.add(jButton1, null);
        jTabbedPane1.addTab("jPanel1", jPanel1);
        jPanel2.add(jTextField2, null);
        jPanel2.add(jButton2, null);
        jTabbedPane1.addTab("jPanel2", jPanel2);
        this.getContentPane().add(jTabbedPane1, null);
    private void jButton1_actionPerformed(ActionEvent e) {
    private void jButton2_actionPerformed(ActionEvent e) {
    public static void main(String[] args) {
        new Frame1();
}

tabbedPane.setSelectedIndex(...);

Similar Messages

  • Hi, can anyone advise me how i can stop any texts messages from displaying on the front screen of my mobile plz? despite my iphone requiring a password to get into it , texts can still be read from front screen.

    can anyone please advise me how i can steop any text messages from displaying on the front screen of my apple iphone 5c? Despite my phone requiring a password to get into it and this being locked when the text comes in, the text message is still actually visible on the front screen and could be read by anyone. Can anyone provide me with any resolution to this please?

    Settings > Notifications and turn off the ones you don't want.

  • Blank tab position: How can I make new (CTRL+T) tabs open on the left instead of far right?

    When I open a new tab (new, blank tab, from a link), it opens on the far right of the tab bar. This doesn't work for me because when I open a new tab, I use it immediately, so I would like it to be appear adjacent to the tab I'm currently using. I've scoured support and forums without finding a way to change the position of new tabs.
    NOTE: When I say "new tab," I am mean NEW tabs - the kind that contain the new tab page, created using CTRL+T or File->New Tab not tabs opened from links. I am emphasizing this point because I have found plenty of questions and answers about how to make links opened in a new tab open on the far right or next to the current tab by changing the value in browser.tabs.insertRelatedAfterCurrent in about:config.

    The [https://addons.mozilla.org/en-us/firefox/addon/tab-mix-plus/ Tab Mix Plus] extension appears to have this feature, pictured in the screen shot here: http://tmp.garyr.net/help/#Events_-_New_Tabs

  • How To use JFile Chooser in a Tabbed Pane Dialog

    I have created a tabbed pane dialog. In one of the tabs I want to add a JFile Chooser.
    How can I approach this problem. also Do I have to use a JDialog with a frame or can I create a JDialog without using a frame and create a instance from the main function.

    I have created a tabbed pane dialog. In one of the
    tabs I want to add a JFile Chooser. Since JFileChooser is a JComponent you could add it to any Container like any other JComponent.
    Maybe you have to do some init by hand which is done normally by the show*() methods of JFileChooser. Taking a look at the source of showDialog() should help.
    Hope that helps,
    Alex

  • How can we get an image of selected area of the front panel

    i am plotting some graphs and want a group photo of all those in one shot is it possible????
    n i want to get the graph coordinates on the mouse click.....
    i.e when i click on the graph at any place the values corresponding to it must be retrieved. how do we do that,,...
    i have tried with the labview help but didnt get any help
    help please????????

    Here's a start.  This will get the front panel image and display it as a picture indicator.
    You could use an event structure to capture the mouse clicks on the picture control to set the image area.  Then using the mouse coordinates (referenced from the image coordinates), you can get the image subset "Get Image Subset.vi".
    Message Edited by vt92 on 04-20-2010 08:30 AM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal

  • How can I simultaneously acquire and display an image on the front panel using a PCI-1424

    Dear friends;
    I want to use PCI-1424  , and labview 5.1 to capture the image,  But I can not find some functions in labview to capture, display and save the image.Can you be kind to share some examples or provide some information.
    Another question is how I CAN display the image in the front panel.
    thanks so much

    Hello yangshang,
    Thank you for contacting National Instruments!  To acquire images from the 1424 you will need NI IMAQ 2.5.1 or later.  This can be found HERE on our drivers download page.  One thing to note is that in LabVIEW 5 we only had the ability to view an IMAQ image as a pop up window.  This VI is called "IMAQ Windraw".  This will pop up a separate window that will display your picture.  If you need to view the picture on the front panel you can try saving the image as a file (BMP, JPG, etc) then use the LabVIEW Graphics and Sound VI's to Read a picture file in and then wire the picture to a picture control on the front panel.  Let me know if you have anymore questions.  Good Luck.
    Regards,
    Mark T
    Applications Engineer | National Instruments

  • How can I simultaneously acquire and display an image on the front panel using a PCI-1408

    I have to acquire and display an image directely in the front panel of a *.vi using a PCI-1408. i have to know all informmations about this image because I want to create a calibration system.

    Hi Paola,
    if you own IMAQ Vision you can just have a look at the examples that comes with your board or you can look at: http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/2abaefe05789961686256866007c0d22?OpenDocument.
    Without IMAQ Vision look at:
    http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/22474456534202b086256aff005fc4f3
    (or search at ni.com for "IMAQ Display without IMAQ Vison)
    Please mail me if you need further help,
    Michael

  • Hi do someone now how to fix this "when i press Tab button on the keyboard the cursor don't move to the next string control"

    When i press Tab button on the keyboard the cursor don't move to the next password control. i have simple login dialog in web ui builder.
    When i run the vix i need to press two times Tab to move from username string control to the next password "password control" my Tab index for the username
    control is "1" and for the password is "2' and i try to use all of the 3 options for TabNavigation Local, Cycle and Once and noone work.
    Thanks

    I attached one simple example of the issue.
    Thanks for the Reply.
    Attachments:
    Login Dialog.zip ‏2 KB

  • Using Key down to control the Tab Control on the front panel

    Greetings everyone,
    Like the question ask how do i control the Tab control's tabs using the key down of the event structure...I dont want to use any of the fuctions keys..i have seem a lot of other sample like the one that i have attached it can only alternate between page 1 and page 2 what if i have a lot of pages and i want to use key down function to switch across the pages.
    Attachments:
    Tab_switch.vi ‏28 KB

    Try something like the attached modification.Message Edited by altenbach on 03-13-2005 04:04 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Tab_switchDOWN.vi ‏32 KB

  • In Safari on a MacBook Pro, how do you open a new blank tab while leaving the site you were on still on another tab?

    This is my first Mac computer, and this may be a silly question, but I can't find the answer anywhere else. Anyway, is there a way to open a new tab that's blank? Like in iPhones, you can click new page, and a blank page opens up. Anyway that's possible on Macs? Or do I just need to download Chrome?

    A new tab can be obtained with command-t, or via the File menu, or with the + sign at the end of the tabs, or.... 
    What happens when a new tab is opened is determined via Safari > Preferences > General.
    You will want to select "Empty page" under "New tabs open with".
    charlie

  • How much it cost to update bb9810 and to change the front panel

    i went to various service centres for updation of my phone's software but everywhere they are charging more than 500 and i have my phone in warranty period when i informed it to them , they said i have to leave the phone for 1 week , i dint get that how can it takes 1 week for software updation .. please help

    Hello,
    Every shop controls their prices...no one here can tell you if those prices are good, bad, or otherwise. But, you can conduct the process yourself. The simplest way is to, on a PC (you cannot do this on MAC):
    1) Make sure you have a current and complete backup of your BB...you can find complete instructions via the link in my auto-sig below.
    2) Uninstall, from your PC, any BB OS packages
    3) Make sure you have the BB Desktop Software already installed
    http://us.blackberry.com/software/desktop.html
    4) Download and install, to your PC, the BB OS package you desire:
    http://us.blackberry.com/support/downloads/download_sites.jsp
    It is sorted first by carrier -- so if all you want are the OS levels your carrier supports, your search will be quick. However, some carriers are much slower than others to release updates. To truly seek out the most up-to-date OS package for your BB, you must dig through and find all carriers that support your specific model BB, and then compare the OS levels that they support.
    5) Delete, on your PC, all copies of VENDOR.XML...there will be at least one, and perhaps 2, and they will be located in or similarly to (it changes based on your Windows version) these folders:
    C:\Program Files (x86)\Common Files\Research In Motion\AppLoader
    C:\Users\(your Windows UserName)\AppData\Roaming\Research In Motion\BlackBerry\Loader XML
    6a) For changing your installed BB OS level (upgrade or downgrade), you can launch the Desktop Software and connect your BB...the software should offer you the OS package you installed to your PC.
    6b) Or, for reloading your currently installed BB OS level as well as for changing it, bypass the Desktop Software and use LOADER.EXE directly, by proceeding to step 2 in this process:
    http://supportforums.blackberry.com/t5/BlackBerry-Device-Software/How-To-Reload-Your-Operating-Syste...
    Note that while written for "reload" and the Storm, it can be used to upgrade, downgrade, or reload any BB device model -- it all depends on the OS package you download and install to your PC.
    If, during the processes of 6a or 6b, your BB presents a "507" error, simply unplug the USB cord from the BB and re-insert it...don't do anything else...this should allow the install to continue.
    If you are on MAC, you are limited to only your carriers sanctioned OS packages...but can still use any levels that they currently sanction. See this procedure:
    KB19915How to perform a clean reload of BlackBerry smartphone application software using BlackBerry Desktop Software
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Trouble adding actionlistener to a panel in a tabbed pane

    Hi, please help me! this is the code i wrote, with the error given below:
    CODE:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class tabslisten extends JApplet
         JPanel RecPanel;
         GridBagLayout gbl;
         GridBagConstraints gbc;
         public void init ()
              FlowLayout flow;
              flow = new FlowLayout();     
              Container content = getContentPane();
              content.setLayout(new GridLayout());
              JTabbedPane tabpane = new JTabbedPane();
              content.add(tabpane, flow);
              RecPanel = new JPanel();
              recipientDetails();
              tabpane.addTab("Recipient Details", null, RecPanel, "Recipient Details");     
         public void recipientDetails()
              JLabel lblRecFName;
              JLabel lblRecLName;
              JTextField txtRecFName;
              JTextField txtRecLName;
              JButton btnValidate;
              gbl = new GridBagLayout();
              gbc = new GridBagConstraints();
              RecPanel.setLayout(gbl);
              lblRecFName = new JLabel("First Name");
              lblRecLName = new JLabel("Last Name");
              txtRecFName = new JTextField(8);
              txtRecLName = new JTextField(5);
              btnValidate= new JButton("Validate");
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 8;
              gbl.setConstraints(lblRecFName, gbc);
              RecPanel.add(lblRecFName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 4;
              gbc.gridy = 8;
              gbl.setConstraints(txtRecFName, gbc);
              RecPanel.add(txtRecFName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 11;
              gbl.setConstraints(lblRecLName, gbc);
              RecPanel.add(lblRecLName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 4;
              gbc.gridy = 11;
              gbl.setConstraints(txtRecLName, gbc);
              RecPanel.add(txtRecLName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 4;
              gbc.gridy = 32;
              gbl.setConstraints(btnValidate, gbc);
              RecPanel.add(btnValidate);
              validateAction validateButton = new validateAction();
              btnValidate.addActionListener(validateButton);
         class validateAction implements ActionListener
              public void actionPerformed(ActionEvent evt)
                   Object obj = evt.getSource();
                   if (obj == btnValidate)
                        String fName = txtRecFName.getText();
                        String lName = txtRecLName.getText();
                        if (fName.length()==0)
                             getAppletContext().showStatus("First Name not entered.");
                             return;
                        else if (lName.length()==0)
                             getAppletContext().showStatus("Last Name not entered.");
                             return;
                        else
                             getAppletContext().showStatus("Successful.");
    ERROR:
    tabslisten.java:90: Undefined variable: btnValidate
    if (obj == btnValidate)
    ^
    tabslisten.java:92: Undefined variable or class name: txtRecFName
    String fName = txtRecFName.getText();
    ^
    tabslisten.java:93: Undefined variable or class name: txtRecLName
    String lName = txtRecLName.getText();
    ^
    3 errors
    Press any key to continue...
    I'm sure I'm doing something really stupid, but I don't know what! ANY and ALL help will be appreciated! Thanks!

    I copied your program and ran it. It works fine. Make sure the three variables you made class variables are only defined in one place. (ie you moved them not copied them). Other than that I have no ideas.
    With regards to naming conventions. My only comment is, take a look at the Java API.
    1) classes have uppercased words. Examples from your program - JTextField, Container, FlowLayout, GridLayout...
    2) methods and variable names don't upper case the first word - getContentPane(), setLayout()...
    Here is the program that works for me:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class FirstApplet extends JApplet
         JPanel RecPanel;
         GridBagLayout gbl;
         GridBagConstraints gbc;
         JTextField txtRecFName;
         JTextField txtRecLName;
         JButton btnValidate;
         public void init ()
              System.out.println("hello there");
              FlowLayout flow;
              flow = new FlowLayout();
              Container content = getContentPane();
              content.setLayout(new GridLayout());
              JTabbedPane tabpane = new JTabbedPane();
              content.add(tabpane, flow);
              RecPanel = new JPanel();
              recipientDetails();
              tabpane.addTab("Recipient Details", null, RecPanel, "Recipient Details");
         public void recipientDetails()
              JLabel lblRecFName;
              JLabel lblRecLName;
              gbl = new GridBagLayout();
              gbc = new GridBagConstraints();
              RecPanel.setLayout(gbl);
              lblRecFName = new JLabel("First Name");
              lblRecLName = new JLabel("Last Name");
              txtRecFName = new JTextField(8);
              txtRecLName = new JTextField(5);
              btnValidate= new JButton("Validate");
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 8;
              gbl.setConstraints(lblRecFName, gbc);
              RecPanel.add(lblRecFName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 4;
              gbc.gridy = 8;
              gbl.setConstraints(txtRecFName, gbc);
              RecPanel.add(txtRecFName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 11;
              gbl.setConstraints(lblRecLName, gbc);
              RecPanel.add(lblRecLName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 4;
              gbc.gridy = 11;
              gbl.setConstraints(txtRecLName, gbc);
              RecPanel.add(txtRecLName);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 4;
              gbc.gridy = 32;
              gbl.setConstraints(btnValidate, gbc);
              RecPanel.add(btnValidate);
              validateAction validateButton = new validateAction();
              btnValidate.addActionListener(validateButton);
         class validateAction implements ActionListener
              public void actionPerformed(ActionEvent evt)
                   Object obj = evt.getSource();
                   if (obj == btnValidate)
                        String fName = txtRecFName.getText();
                        String lName = txtRecLName.getText();
                        if (fName.length()==0)
                             getAppletContext().showStatus("First Name not entered.");
                             return;
                        else if (lName.length()==0)
                             getAppletContext().showStatus("Last Name not entered.");
                             return;
                        else
                             getAppletContext().showStatus("Successful.");

  • Tabbed pane and panel

    hi everybody!
    how can insert several panel into a tabbed pane ???
    thanks

    hi,
    i mean into a tab of tabbedpane!!
    haleh

  • How to use php variable for default tabbed panel

    I have a tabbed panel and with tabs labelled with the days of the week.  What I want to do is open up the tab that correspond to the current day.  I have been using the following to get the day in 3 char format:
    <?php
    $jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
    echo(jddayofweek($jd,2));
    ?>
    What I want to do is replace the value for the default tab in the following statement with a variable that matches the day returned with a number:
    var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1", {defaultTab:1});
    Please could anyone advice?
    Regards,
    Lloyd

    Hi,
    BIND_VARIABLE is useful when you have only IN variable but in your case you have IN and OUT.
    I don't know if you use the gateway for MS SQL SERVER or HSODBC/DG4ODBC but here how you can do to call a remote procedure with bind variables:
    DECLARE
    ret integer;
    inp varchar2(255);
    outp varchar2(255);
    BEGIN
    inp :='Hello World';
    outp :='';
    ret := "dbo"."in_out_proc_test"@tg4msql( inp, outp);
    dbms_output.put_line('Input value: ' ||v_ut1||' - Output value: '||v_ut2);
    END;
    The MS SQL Server procedure belongs to the user "dbo" and the database link
    being used is tg4msql.
    The following line initilaize the out variables of the procedure with an
    empty string:
    outp :=''
    I hope it helps you.
    Regards
    Mireille

  • Events effecting panels in multiple tabs

    I'm currently working on an application that has three tabs inside a JTabbedPane. Inside each pane is several panels ( probably a minimum of 5 panels to a pane, for layout resons ). I'm starting to code in the event handling for all of the buttons, and I have a few problems.
    One: All of the panels are in seperate class and source files. For example, the west panel for a border layout is in WestPanel.class, and all the panels that are inside WestPanel have their own class files. Should I move all of the panels into one source file and have them as private inner classes to make event handling easier?
    Two: How do I setup an event handler so that events in one panel affect objects in another panel? Say, pressing a button in WestPanel affects something in EastPanel? Or would this be fixed by having all the panels setup in one source file?
    Three: This is sort of like #2, but this is for the seperate tabbed panes. The first pane is a setup pane. For instance, in the first panel, there is a JSlider to set the time. After the user has finished setting up the rest of the application, they press finish. When they press finish, it creates an object that keeps track of everything ( like the time ). How do I setup an event handler so that when they press finish, it takes all the values, creates the object, then uses the values in that object to set the values in the other panes?
    Alrighty, I think that's everything. Any help is VERY much appreciated. Thank ye.

    One is personal preference and good judgement. Either way will work,
    and we can't really be helpful beyond general advice since we're not
    familiar with your codebase. If the functionality of JPanel isn't extended,
    they may fare better as inner classes, unless they're very large, etc..
    For Two and Three, I suggest looking up the Mediator design pattern.

Maybe you are looking for

  • PSU for Windows 64?

    Hello, We have 11.2.0.2 for Windows 64 installed. I am unable to find ANY PSUs for Windows. I cannot find 11.2.0.2.5 , or 11.2.0.2 or any others (ie 11.2.0.2.7 for example). Do they not exist for Windows? They for the other platforms (ie LINUX). I ha

  • Out of the box initial setup locked up - how to re-run it?

    Unboxed our iMac 27" yesterday and as it was going through the first time setup, when it asked to take a picture to associate it with the user account I created, both buttons were grey-ed out and couldn't take a picture either.  I let the computer si

  • Add customized fields in ME21N item overview.

    Hi experts, Can we insert our own customized fields into ME21N item overview section. Pls advise. Thanks and regards, Simonksh.

  • PI SP13 - ALM issue - BPM alerts are received many times

    Hi all, the program RSALRTPROC is scheduled every 5 minute to do : - deliver - escalate the program RSALRTPROC is scheduled every week to do : - delete - reorganisation While an alert isn't completed, RSALRTPROC job (deliver) sends my uncompleted BPM

  • Unable to set fontFamily property in Business Graphics UI Element?

    Dear All, I was trying to set the fontFamily property of BusinessGraphics(BG) UI Element. After setting the fontFamily property for BG UI Element, this property is not getting reflected in the chart in Portal but it is reflected under Chart designer.