How to switch between pages in a JTabbedPane

I hava form with a JTabbedPane whit 5 "pages" om page 1 there is a button that when pressed i want to switch to page 5 and display that content
I have tried the setSelectedIndex method but i does not work.. Any tips?

How about the source code?
It must be buggy somewhere! There is no problem with those methods in my example.
Try this one:
package tabs;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
* <p>�berschrift: </p>
* <p>Beschreibung: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Organisation: </p>
* @author Florian Fray
* @version 1.0
public class TabExample extends JFrame {
private JPanel root = new JPanel();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JPanel jPanel2 = new JPanel();
JButton jButton2 = new JButton();
FlowLayout flowLayout1 = new FlowLayout();
public TabExample() throws HeadlessException {
try {
jbInit();
pack();
show();
catch(Exception e) {
e.printStackTrace();
public static void main(String[] args) throws HeadlessException {
TabExample tabExample1 = new TabExample();
private void jbInit() throws Exception {
setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
this.setState(Frame.NORMAL);
this.setTitle("Tabbing around");
setContentPane(root);
jButton1.setText("to Tab 2");
jButton1.addActionListener(new TabExample_jButton1_actionAdapter(this));
jButton2.setText("back to Tab 1");
jButton2.addActionListener(new TabExample_jButton2_actionAdapter(this));
jTabbedPane1.setMinimumSize(new Dimension(155, 83));
jTabbedPane1.setPreferredSize(new Dimension(155, 83));
root.add(jTabbedPane1, null);
jTabbedPane1.add(jPanel1, "jPanel1");
jPanel1.add(jButton1, null);
jTabbedPane1.add(jPanel2, "jPanel2");
jPanel2.add(jButton2, null);
void jButton1_actionPerformed(ActionEvent e) {
jTabbedPane1.setSelectedIndex(1);
void jButton2_actionPerformed(ActionEvent e) {
jTabbedPane1.setSelectedIndex(0);
class TabExample_jButton1_actionAdapter implements java.awt.event.ActionListener {
TabExample adaptee;
TabExample_jButton1_actionAdapter(TabExample adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
class TabExample_jButton2_actionAdapter implements java.awt.event.ActionListener {
TabExample adaptee;
TabExample_jButton2_actionAdapter(TabExample adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}

Similar Messages

  • How to keep location in a table persistent when switching between pages

    Hi -
    How would I keep my last location persistent in a table when switching between pages? If I am on cell X and switch to another page, when returning to the previous page, I return to the top of the table. This can be very annoying when trying to find the same location in a large table (or even in a small one).
    Thanks.

    If by "page" you mean "sheet", you can do it. To get back to the same place you were in the other sheet, click on the sheet in the sidebar (the list of sheets/tables/charts/etc on the left). Don't click on the table, click on the sheet.

  • Switching between page layout and word processing

    I can't seem to switch between page layout and word processing view.  I've read all the posts on this and still can't figure out why I can't just type a document into Pages.  The only option I have in page layout view is to type into text boxes, which is not what I want.  I just want to type a letter for crying out loud.
    Before I get all the rants about reading User Guides, etc.  *I have*.  I've also searched on here and in-app help and just don't understand the fuzzy/non-existant answers.  Obviously, I'm a newbie, so please don't jump all over me for this.  If it was Word - I could do this in NO time.  I just find it incredibly frustrating that inputting a normal document should be so difficult.
    Is "Pages" *not* a word processing program?  Is it just a cut and paste application?  Sorry for the tone - I mean no disrespect - it's just that I've been fooling around with this for DAYS and I just don't have time to spare anymore.  I really need to get this done.
    Can somebody give me a straightforward answer on how to just type a normal document into pages without using text boxes?
    Thanks and I apologize for not being mac-savvy.  It took some of us a lot longer to see the light =)

    Here is a script doing the conversion task for you.
    Open a Page Layout document
    run this script:
    --{code}
    set p2t to (path to temporary items from user domain) as text
    set path_2_doc to p2t & (do shell script "date +_%Y%m%d_%H%M%S.doc")
    tell application "Pages"
      save document 1 in path_2_doc
      open file path_2_doc
    end tell
    --{code}
    that's all folks.
    Yvan KOENIG (VALLAURIS, France) lundi 20 juin 2011 18:03:28
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How to switch between messages in the BlackBerry Hub

    With the release of BlackBerry 10 version 10.1, we’ve added a new gesture to the BlackBerry Hub that allows you to quickly switch between your next and previous messages. It’s simple: while viewing a message drag your finger from the left to the right and in one continuous motion swipe up or down.
    For example, in the following screenshot you’ll notice I am viewing ‘Test 08”. To get to the next message, “Test 09”, all I need to do is swipe from left to right (red arrow) followed by swiping up (green arrow) in a single motion. To switch to the previous message, “Test 07”, I complete the same gesture, but swipe down instead (blue arrow).
    Tip: Using a BlackBerry Q10 or Q5? On top of using this gesture to switch between messages, you also have the option of pressing the N key to view your next message, or the P key to view a previous message.
    If this gesture doesn’t appear to be working on your device, verify you are using BlackBerry 10.1.0.4181 or later by going to Settings > About and reviewing the OS Version field. If the OS Version is lower than 10.1.0.4181, check for updates by going to Settings > Software Updates.
    For more details about the availability of BlackBerry 10.1, check out Inside BlackBerry’s post on BlackBerry 10 Software Updates.
    VIA | helpblog.blackberry.com
    http://helpblog.blackberry.com/2013/10/how-to-switch-between-messages-in-the-blackberry-hub/
    Please thank those who help you by clicking the button.
    If your issue has been solved, please resolve it by marking "Accept as Solution"

    I would set up a variable before you get to that node, lets call it $EmpID and assign to it the value of the prompt you want to play lets say 12345 which would be the library promptID. It will then play prompt, get digits, and once you validate if it goes through the expression that flags it as invalid, in that node re-declare the variable, but this time give it the value of the new prompt you want to play, then sent it back to the node which will then play the new prompt and collect the digits.

  • MSI R9 290 How to switch between Gaming Modes?

    Hi, I just got a MSI R9 290... with Afterburner installed. This card has 3 preset modes that are supposed to be easy to switch between OC Mode 1007Mhz, Gaming 974Mhz, Silent 947Mhz... How do I switch between modes? I just tried to up the MHz in Afterburner and must have done something wrong, becuase I froze everything instalntly and had to reboot. Can someone please advise me how to switch between these modes? Do I have the right software installed, Afterburner or is there another suite specificly for this card? I did not install the card, and sorry I am a noob when it comes to OC. . . Noob to gaming in general, but I am getting some pretty bogus 30FPS on a 2012 game, LA Noire, which shouldnt even be demanding for t

    Quote from: kris.meaney on 07-March-15, 18:45:04
    This card has 3 preset modes that are supposed to be easy to switch between OC Mode 1007Mhz, Gaming 974Mhz, Silent 947Mhz... How do I switch between modes?
    You need the Gaming APP for switching (not Afterburner): http://download.msi.com/uti_exe/gamingApp.zip
    Afterburner is for manual overclocking (for advanced users) if not using the modes.

  • How to switch between markets in AppStore?

    How to switch between markets in AppStore? It says that I cannt buy in Russian market because my account registered in other

    Follow the directions here:
    http://support.apple.com/kb/ht1311

  • Question How to switch between tabs automatically? for example every 30 seconds

    Question
    How to switch between tabs automatically? for example every 30 seconds

    Tab Mix Plus has that feature.
    *Tab Mix Plus: https://addons.mozilla.org/firefox/addon/tab-mix-plus/

  • AS: how to switch between screen modes?

    hi @ all,
    does anybody know how to switch between the 4 screen modes in ps cs3?
    - standard
    - maximized
    - full screen with menubar
    - full screen
    I looked around but could not find anything discribing a way doing this by applescript.
    the only thread I found
    http://www.adobeforums.com/webx/.3bc85cba/0
    refers to javascript but I was not able to adopt it.
    thanks for any help
    Claus

    To do it with AS only, you need to simulate the "f" key with System Events:
    tell application "System Events"
      tell process "Adobe Photoshop CS3" to keystroke "f"
    end tell
    That will loop thought the screen modes as if you did it manually.
    To run the JS from the other thread, you need to use the "do javascript" command. Remember to escape all the quotes in the JS:
    tell application "Adobe Photoshop CS3"
      do javascript "var screenModeOptions = new Array(4);
         screenModeOptions[0] = \"screenModeStandard\";
         screenModeOptions[1] = \"screenModeMaximized\";
         screenModeOptions[2] = \"screenModeFullScreenWithMenubar\";
         screenModeOptions[3] = \"screenModeFullScreen\";
         applyScreenMode(screenModeOptions[0]);
         function applyScreenMode(mode){
          var desc = new ActionDescriptor();
          var ref = new ActionReference();
          var menuID = stringIDToTypeID( mode );
          ref.putEnumerated( charIDToTypeID( \"Mn  \" ), charIDToTypeID( \"MnIt\" ), menuID );
          desc.putReference( charIDToTypeID( \"null\" ), ref) ;
          executeAction( charIDToTypeID( \"slct\" ), desc, DialogModes.NO );
    end tell
    The JS is the better solution if you wanted to skip directly to the desired screen mode without looping through the others.
    Carl.

  • How do I keep the page format from changing on my IPAD as I switch between pages

    How do I keep my page format from changing on my IPAD as I switch from page to page.

    Can you provide more information. Switching from page to page in what app? How if the format changing?

  • How to switch between two query in Web templete.

    Hi all,
      Here i am facing problem to switch between two query in web template by using one 'table' web item. is there any way to use hyperlink 'SAP_BW_URL' and we can switch to query. here i am using these HTML code..
    <table><tr><td class="SAPBEXBtnStdBorder" cellspacing="0" cellpadding="0" border="0"><tr><td>
    <table><tr><td class="sapbexbtnstd" ><A href="<SAP_BW_URL cmd='reset_item' item='table_data' query_ID='ZSD_ZSD_M01_Q20' apply_cmd_on_target= "X">" >Switch to other query</A></td></tr></table>
    but i am not getting correct functionality.
    please help me to solve this problem.
    I know the best way to say thanks in SDN.
    thanks
    Kiran Patel

    Kiran,
      Use the web api reset_data_provider as links or in select option in HTML.
       Onchange event of this select option should call JAVASCRIPT method and
       this in turn resets the current dataprovider to your concerned one.
       How to change graphs:
       The graph item has the default data provider:
       <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="CHART_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_CHART"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="TMP_CHART_DATA_HANDLE" value="IIP_49MOXB0UVNOMM6JOZMZU7QO21"/>
             ITEM:            CHART_1
       </object>
      So if you change the DATAPROVIDER_1 using RESET_DATA_PROVIDER to your concerned DP, this changes chart as well !!
       Please use this method and refer to sample code for Onchange Event on SELECT OPTION:
      <HTML>
    <HEAD>
    <script>
    function callDP() {
         if(document.forms[0].dp.value == "1") {
            //form your URL here..
           url = SAP_BW_URL_Get() + "&CMD=RESET_DATA_PROVIDER&DATA_PROVIDER_1=..&...";
            SAPBWOpenURL(url);
            //or docuemtn.location.href = url..
            //etc..
    </script>
    </HEAD>
    <BODY>
    <form>
    <select name="dp" onChange="javascript:callDP();">
    <option value="1">1</option>
    <option value="2">2</option>
    </select>
    </form>
    </BODY>
    </HTML>
    HOPE THIS HELPS !!!

  • How to switch between apps in mission control shortcut key

    I open two apps in my macbook, how can i select the app without clicking on it?.I know that f3 > mission control and then click, but i want to switch between apps with keyboard shortcut.Thanks in advance for your help.( I am runnig lion).

    Hold down the cmd (⌘) key and briefly press the tab key (⇥) then use the left/right arrow keys to select the application you wish to switch to.  When done release the cmd key.

  • How to switch between 2 windows of the same application using Cmd+Tab

    Hi,
    I am using my mac now since about 10 months. I was used to work with Linux and Windows XP.
    Something I am badly missing on mac os x is the possibility to switch between 2 windows of the same application using cmd + tab just like it simply works for Linux and Windows (and maybe many other OS out there!).
    Very often I have 2 text files open in 2 editor windows (e.g. TextEdit) and need to copy and paste text from one window to the other. I was used to simply use ALT+TAB. But here I have to get my right hand away from the keyboard and use the mouse to change the focus from one window to the other and then use the mouse again to get the focus back to the previous TextEdit windows.
    THIS REALLY *****!!!! It makes me crazy. I cannot believe that such a "modern" OP does not support this action. I must be doing something completely wrong or did not understand the mac correctly. Right?
    Does anyone have an idea how I can get mac to do something all other operating systems so easily do?
    Thanks
    Quartz84

    Hi Kappy,
    well what you are saying is obvious to me. This is not the point for me and not what I wanted to know. But I think you answered my question anyway: OS X is unable to switch between windows of the same application as I mentioned in my example.
    WHY NOT???
    Every other OS is able to differentiate between windows and not just applications.
    Another example: The Mail application and an Email editor window. When you are writing an Email and you want to switch to the main window of the Mail application to read something you must again use the mouse!
    I mean Apple seems to be "somehow" using FreeBSD in the background and even in FreeBSD's window manager it is possible to switch between windows of the same application.
    Well, in the Apple world it is always the pour user who is not intelligent enough to understand Apple's philosophy ;-(
    To me this is not modern, it is simply a weakness of the OS.
    Cheers
    Quartz84

  • How to switch between libraries?

    I have got to do a disk repair. I'm making sure my backup is correct as I don't want to lose all my precious pics. Lucky I checked as I've just discovered I've got two iPhoto libraries! The one I appear to be using is in the mac folder - where Users folder is, Library, System Folder, Updaters etc. It's the first area you come to when you double click on your mac's symbol in upper right corner.
    However, I also have an iPhoto library within a folder which is in my User/Pictures area.
    I want to make sure that the iPhoto library I'm using is within my user/pictures folder as it's my user files which are being backed up. However, I don't want to trash the one which is there without looking in it to see what's within. How do I switch between libraries?
    If it's empty, I can presumable just bin it then use the recommended technique to move my other library to User\Pictures.
    Thanks!

    If you use iPhoto LIbrary Manager like Larry suggested it will display the library name in the top iPhoto frame like this:
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    Note: There's now an Automator backup application for iPhoto 5 that will work with Tiger or Leopard.

  • How to switch between open excel documents?

    How do I switch between open excel documents.  I am used to windows and really miss this funciton

    The Command +` keys will switch between windows in an application
    ~Lyssa

  • How to switch between different libraries for different iPods?

    Hi,
    I succesfully created two separate iTunes libraries on my computer (windows XP) for the iPods of me and my girlfriend. But, how can we switch easily back and forth between the different libraries?
    The suggested option on http://docs.info.apple.com/article.html?artnum=300432 'method three' and bullet '13' does not appear / work....
    Regards,
    Roy

    thanx for replying so fast.
    No problem, Roy. : - )
    Sorry for the delay in getting back to you this time. : - (
    i'd like to know how i can switch between libraries without closing down iTunes.
    Unfortunately you can only choose your Library at startup. So the only way to switch Libraries is to close iTunes ...
    You might want to let Apple know your thoughts on the matter by submitting this form: http://www.apple.com/feedback/itunesapp.html

Maybe you are looking for

  • Itunes won't open...error 2206..tried many time to uninstall and to install...any help?

    Itunes won't open...error 2206 I have tried to uninstall and to reinstall...still won't open. Any suggestions so i can use my itunes library again?

  • Not Connecting to Wired Network and Forcing the loss of all Connections on the Home Network

    Just got a new G550 laptop  w/Win 7 OS. Tried to connect to wired router and got message "network cable not connected". Recycled laptop and router and came up with router connected to the laptop. Same message after search and identify steps finished.

  • Steps to configure Content Repository OAC0

    Hi. I'm trying to use Tx OA_FIND , but this send a message " Any links exist" What are the steps to configure content repository to ARCHIVELINK??. Im trying with OAC0 OAC2 OAC3 However  unknow the parameters for OAC0. Can anyone , help me. Thx in adv

  • Send a mail

    Hi, I'm looking for a Forté command to send automatically a mail with a body message and a file attached . I have tried these lines: Cmd.setvalue('start mailto:adresshere.com?subject=Trial'); task.part.operatingsystem.runCommand(command=Cmd); But the

  • 5310 Contact Search

    Is there a way to search contacts by both last name and first name in one go (like N series or all Windows phones)? As of now, I need to remember which name was entered in which order. Anyone can help here? I will have to change my phone because of t