Prob with JTabbedPane

Hello everybody,
I am not able to arrange the things in my TabbedPane.
I have put two tabs onto the pane.
I will paste the code, see if anybody can help.
// This is the main program, there are two other classes in two different files.
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
* @author Akila
public class Main extends JPanel implements ActionListener
     static JTabbedPane tabbedPane;
     public Main()
          super(new GridLayout(5, 5));
          //System.out.println("main prog");
          //System.out.println("creatin tab");
          JTabbedPane tabbedPane = new JTabbedPane();
          //System.out.println("callin tab1");
          JComponent tab1= new Tab1(tabbedPane);
          add(tab1);
          JComponent tab2= new Tab2(tabbedPane);
          add(tab2);
          add(tabbedPane);
     public static void main(String[] args)
          SwingUtilities.invokeLater(new Runnable()
               public void run() {
                    UIManager.put("swing.boldMetal", Boolean.FALSE);
                    createAndShowGUI();
     public static void createAndShowGUI()
          JFrame frame = new JFrame("Service Software");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          //Add content to the window.
          frame.add(new Main(), BorderLayout.CENTER);
          //Display the window.
          frame.pack();
          frame.setVisible(true);
     @Override
     public void actionPerformed(ActionEvent arg0)
}// This is Tab1. java
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
public class Tab1 extends JPanel implements ActionListener
     JLabel name;
     JComponent tab1;
     JTextArea area;
     public Tab1(JTabbedPane jt)
          JComponent tab1=new JPanel(false);
          jt.add("Services",tab1);
          tab1.setLayout(new GridLayout(5, 5));
          name= new JLabel("Name");
          JButton sub = new JButton("Submit");
          tab1.add(sub);
          JTextArea area = new JTextArea();
          tab1.add(name);
          tab1.add(area);
          add(jt);
          sub.addActionListener(this);
          jt.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
     public void actionPerformed(ActionEvent e)
}//This is Tab2.java
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
public class Tab2 extends JPanel implements ActionListener
          public Tab2(JTabbedPane jt)
               //System.out.println("tab1 prog");
               JComponent tab2=new JPanel(false);
               jt.add("New Contact",tab2);
               tab2.setLayout(new GridLayout(5, 5));
               JLabel name= new JLabel("Age");
               JTextArea area = new JTextArea();
               tab2.add(name);
               tab2.add(area);
               add(jt);
               jt.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
               public void actionPerformed(ActionEvent e)
}So when i run this program, the tabs come in the center, and it is stretched. It doesn't look nice. I want it to look nice, The tabs should be in the beginning, and the JLabel JTextArea , Submit button should be of right size.
Thanks in Advance.
Akila
Edited by: akila17 on Sep 5, 2008 10:33 PM

Hm,
Did you read the API of JTabbedPane ...
If not read this tutorial how to use tabbed panes.
Your problem is a layout problem ... grid layout is not a good choice for "nice looking" gui's
read this turial about layouts.
This should help you.
Olek

Similar Messages

  • Prob. with iTunes, Phone won't shut off.  Tks.

    3GS with 6.1.3 Prob. with iTunes.  When I want to close out of iTunes after a Podcast the App will not close out when I hit Home. All other Apps shut down, only prob. is with iTunes.  Cant turn phone off goes back ti iTunes when turned on again.  Tks.

    I hope the previous replies are wrong. It was my understanding that even when Match is turned off in iTunes, music previously matched or uploaded to iCloud will stay there, associated with my Apple ID, even through a cold boot etc. If you want to remove songs from iCloud, but keep them locally, do this:
    1. Click "Store" in the iTunes top Menu
    2. Select "Turn on iTunes Match" (if it isn't already turned on)
    3. Close iTunes.
    4. Hold down the Shift key while you open iTunes - this will prompt you to choose or create a (new, locally empty) Library in a different folder from your main Library.
    5. Now you should see ONLY music that is stored in iCloud.
    6. Delete them all. iTunes will show a checkbox or button for you to click to delete the selected items from iCloud.
    7. Turn off iTunes Match (see #1)
    8. Restart iTunes with the Shift key again, so you can get back to your main Library - with Match turned off.

  • I have copied my iTunes library onto a new computer, but when I play back the songs there seems to be random "miss" or "drop out".  No probs with old computer, just the new one.  I'm onto my third new computer - same problem.  Any suggestions please?

    I have copied my iTunes library onto a new computer, but when I play back the songs using the new computer, there seems to be random "miss" or "drop out" during play back, similar to a small scratch on a vinyl record.  Although when I play the same song over again, the "miss" occurs in a different location during the song.  No probs with old computer, just the new one.  I'm onto my third new computer - same problem.  Any suggestions please?

    You don't say which version of iTunes you are using, but the symptoms you describe have been encountered by some users with the 64-bit version of iTunes 12.1.
    There is an alternative version for 64-bit editions of Windows here:
    iTunes 12.1 for Windows (64-bit — for older video cards)
    that seems to address the most of the playback issues that some users have been reporting with the full 64-bit version of 12.1.0.77 - including problems with Bluetooth speakers where either sound is degraded or completely absent.  The alternative installer here is the same architecture as most previous "64-bit" versions of iTunes, i.e., a 32-bit application with a 64-bit installer.  The "for older video cards" label appears to be something of a misnomer as some people have reported that this corrects problems found on current / high-spec systems.
    Some users have reported that after installing this alternative version it is necessary to adjust the "Play audio using" selection (normally to "Direct Sound" rather than "Windows Audio Session", though this may vary based on your audio hardware/drivers) in Edit > Preferences > Playback to restore glitch-free audio (one part of the reported symptoms is that the "Direct Sound" choice isn't available, usually in Windows 8).  It may also be necessary to ensure that your Bluetooth speakers are active and selected as the default audio device before you run iTunes.
    If this doesn't address the issue, you may want to think about reverting to iTunes 12.0 - see Turingtest2's notes on Troubleshooting issues with iTunes for Windows updates for steps needed to completely remove all installed iTunes components, and for links to the 12.0 installers.

  • Prob with decode function

    hi iam having prob with the following decode function
    declare
    c varchar2(20);
    begin
    select decode(deptno,
    10, 'accounting',
    20,'Research',
    30 ,'sales',
    40,'operations','UNKNOWN') into c from dept where loc='DALLAS';
    dbms_output.put_line('DEPARTMENT in DALLAS'||c);
    select decode(deptno,
    10, 'accounting',
    20,'Research',
    30 ,'sales',
    40,'operations','UNKNOWN') into c from dept where loc='INDIA';
    dbms_output.put_line('DEPARTMENT IN INDIA'||c);
    end;
    iam getting no_data_found exception which is reasonable..but what happened to 'unknown' clause in decode function.
    thank u
    rajiv

    Please see the responses to your prob in decode function
    John

  • Airport connection probs with Mac Pro and 10.4.8  too.

    This prob is not just related to iMacs or MacBooks as published in the knowledge base doc. I have exactly the same prob with my 2.66 GHz Mac Pro. I have to reconnect this beast to my wlan router manually every time.
    PLZ Apple fix this asap!

    I had a similar problem which I've fixed!
    I have four machines here which can connect to my Netgear DG834N via Aiport. (I say can because they normally connect via ethernet.) My MacBook Pro always used to be fine when connected wirelessly but recently, not aware of any changes I've made, it connects for about 10 seconds then disconnects. All other machines are fine and hold the connection.
    This is what I tried before finding my solution:
    1) Deleted all references to the network in the keychain and remade them.
    2) Created another user to try
    3) Changed channels on the router even though I can't see any neighbour's networks.
    4) Made sure computer and router were up to date with firmware/software.
    I'm assuming that it has to be a computer problem as the PowerMac, iMac and iPod Touch have no issues at all. However, the cure was in the router.
    I run with SSID broadcast turned off, WPA2 encryption and MAC address filtering. Allowing broadcast of the SSID cures my problem. Turn it off and the computer connects then drops it ten seconds later. Turn broadcast on and it maintains the connection. I've tried it all afternoon, leaving it connected for about 30 minutes at a time before turning SSID broadcast off again. Works every time! Broadcast SSID - fine, no broadcast - drops after ten seconds.
    Now, if only I knew why! And why only the laptop?

  • Unicode font usage with jTabbedPane

    Hey there
    I faced a problem when I use Unicode characters on JTabbedPane
    the font is amharic power geez unicode1 and it works fine with jLabel and partially with jButtons ( except trying to set text at run time )
    The problem with jTabbedpane is that when I change its tab title property the other tabs disappear ( am using netbeans 5.5 )

    To me, it looks as if your problem is that you're only calling setFont on "this".
    That's only going to set it for the top level frame, and doesn't always do it for every individual component. The easy way to get around this is to go berserk with the setFont call. Set it on anything (heck, set it on your dog if it makes you feel any better)! ;D
    The slightly harder but smarter way to do this is to write a recursive function that drills down your component list.
    public void setFontRecursively(Font myFont, Component comp) {
       comp.setFont(myFont);
       if (comp instanceof Container) {
          Component[] childComps = ((Container)comp).getComponents();
          if (childComps != null) {
             for (int i=0; i < childComps.length; i++) {
                setFontRecursively(myFont, childComps);
    That should basically cover anything bar popup menus and drop-down submenus. You have to recall this as they appear, or they don't get the font straight off.
    Hope that helps!
    Martin Hughes

  • Hey, i have very strange prob with my iphone 5(latest version/updated), after resetting it, so it doesn't connect to my laptop, even it doesn't charge too. it does charge from wall charger i try all the possible methods but still i am facing the prob

    Hey, i have very strange prob with my iphone 5(latest version/updated), after resetting it, so it doesn't connect to my laptop, even it doesn't charge too. it does charge from wall charger i try all the possible methods but still i am facing the prob any fix/solution for it.. Helppppp!!!!!!!!!!!!!!!!!!!!!!!! As soon as possible, it will be gratefulness,
                                Thnksssssss....

    So you are saying that you followed all of the steps in the support document for problems with connection, including removing and reinstalling iTunes? You do not say what you have tried, so it is hard to make recommendations. If this is the case, then you have tried resolving driver issues? What if you go to Device Manager and look for the iPhone. You should be able to click on it and see about drivers. You can update/reinstall the device driver.

  • Function module Prob with kostl

    hi,good day guys.
    Iam using K_ORDER_SRULE_ADD for settelment rules. In this other function module  for read the fields one whic is K_DEFAULT_RULE_READ.. This is k_order_srule_add f.m source code as below as.
    .default rule table TKB2C is maintained as 'I_SRULES' therefore
    *.....aditional work area is needed.
          i_srules = srules.
    *.....fill COBL to find KONTY
          cobl-kokrs        = ld_kokrs.
          cobl-gsber        = srules-bus_area.
          cobl-bukrs        = srules-comp_code.
          cobl-saknr        = srules-gl_account.
          cobl-prctr        = srules-profit_ctr.
          cobl-kostl        = srules-costcenter.                     "here iam getting the cost center value
          cobl-aufnr        = srules-orderid.
          CALL FUNCTION 'CJPN_EXTERN_TO_INTERN_CONV'
            EXPORTING
              ext_num       = srules-wbs_element
            IMPORTING
              int_num       = cobl-ps_psp_pnr
            EXCEPTIONS
              error_message = 2
              OTHERS        = 1.
            EXIT.
          ENDIF.
          cobl-anln1        = srules-asset_no.
          cobl-anln2        = srules-sub_number.
          cobl-nplnr        = srules-network.
          cobl-vornr        = srules-activity.
          cobl-kdauf        = srules-sales_ord.
          cobl-kdpos        = srules-s_ord_item.
          cobl-kstrg        = srules-cost_obj.
          cobl-prznr        = srules-co_busproc.
    *.....get ASSIGN information in IT_DFTAB
          CLEAR konty.
          CALL FUNCTION 'K_DEFAULT_RULE_READ'        "this FM reads the fields and assining to the lt_dftab
            EXPORTING
              dfreg         = 'BAP'
              obart         = 'OR'
              i_cobl        = cobl
            IMPORTING
              e_konty       = konty
            TABLES
              dftab         = it_dftab                                           "iam not getting the costcenter[kostl] field..
            EXCEPTIONS
              error_message = 2
              OTHERS        = 1.
          IF ( sy-subrc <> 0 ).
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                    RAISING error_occurred.
            flg_leave = 'X'.
            EXIT.
          ENDIF.
    Based on lt_dftab fields. K_POSTING_RULE_INSERT f.m willbe insert the values.prob with costcenter.
    Edited by: balaji kiran on Apr 14, 2010 7:55 AM
    Edited by: balaji kiran on Apr 14, 2010 7:57 AM

    Hi,
    Could you explain how you did it?
    -Thanks

  • ACE HTTP Probe with regex

    ACE HTTP Probe with regex
    Hi,
    I'm trying to setup a HTTP probe with expected string rather then a code (config below). I do a GET for the page then a search for a string in the response however it's not working, as probe appears as failed.
    I've tested the connection to the server by using telneting and then looking at the page displayed to make sure the string I want to match is in the response.
    probe http HTTP-PROBE
    port 43050
    interval 30
    passdetect interval 30
    passdetect count 1
    request method get url /action=help
    open 43050
    expect regex action=help
    Q. Is there anything wrong with this configuration and what I'm trying to achive?
    Thanks,
    Pritesh

    Use "expect status" under probe config. expect regex doesnt work if expect status is not configured.
    expect regex work flawlessly with static pages. It doesnt work all the time with dynamic pages.
    Specially if "content-length" header is missing from Server response.
    Hope it helps
    Syed Iftekhar Ahmed

  • I Was trying to update my apps, then i got an alert that said sign in required. I pressed continue, then it took me to my acct settings and it said there was a prob with my previous purchase and I havent purchased anything???

    I Was trying to update my apps when i got a sign in required alert,
    i signed in and it took me to my account settings ]it said there was a prob with a previous purchase and i havent purchased anything?

    http://support.apple.com/kb/ht1808

  • Since I'm having probs with ios6 and Safari, would the Atomic browser be worth a try?

    Since i'm having probs with ios6 and Safari (Autofill and loss of Wi Fi), would the Atomic browser be worth a try?  trouble is, I'm a bit of a 'newbie' when it comes to the 'clever' stuff, so need a bit of expert advice here.

    I use the Atomic browser for some things. I feel it's main advantage is that you can set the type of browser that Atomic reports. I set mine to Internet Explorer and that allows me to visit regular websites without being redirected to a tablet version. Its free so why not download it and give it a try. If you find it wanting just delete it.

  • I'm a photoshop user on Mac and I was obliged to uninstall Photoshop because prob with generator. Now it's impossible for me to re-download Photoshop. Can you Help? Please

    I'm a photoshop user on Mac and I was obliged to uninstall Photoshop because prob with generator. Now it's impossible for me to re-download Photoshop. Can you Help? Please

    Run the cleaner tool and try again.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    Mylenium

  • ACE Appliance HTTP Probe with "POST" query

    Does the ACE support HTTP Probe with a "POST" query?
    Thanks
    Joe

    Hi Joe,
    The ACE only supports GET and HEAD
    Here is the documentation related to this:
    http://www.cisco.com/en/US/customer/docs/interfaces_modules/services_modules/ace/vA5_1_0/configuration/slb/guide/probe.html#wp1031485
    Cesar R

  • Need help with JTabbedPane

    hi please i need some help with JTabbedPane i've commented the line giving me the problem i'm trying to initialize Tabs but there's an error on it
    import java.awt.BorderLayout;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTabbedPane;
    import model.ContactModel;
    import view.ContactAddView;
    import controller.ContactController;
    public class PersonalContact extends JFrame
         private ContactModel          contactModel;
         private ContactAddView     contactAddView;
         private ContactController     contactController;
         public PersonalContact()
              super ("Personal Contact Manager Demo");
              setSize(580,300);
              getContentPane().setLayout(new BorderLayout());
              contactModel          = new ContactModel();
              contactModel.generateTestData(10);
              Vector searchTest = contactModel.searchMultipleContacts("Surname7");
              contactModel.printAllFoundContactSet(searchTest);
              contactAddView     = new ContactAddView();
              contactController     =     new ContactController(contactModel, contactAddView);
              //JTabbedPane Tabs = JTabbedPane(JTabbedPane.TOP);
              JTabbedPane Tabs = JTabbedPane();
              Tabs.addTab("Add", contactAddView);
              Tabs.addTab("Update", new JPanel());
              Tabs.addTab("View", new JPanel());
              Tabs.addTab("Search", new JPanel());
              Tabs.addTab("Delete", new JPanel());
              getContentPane().add(Tabs);
              getContentPane().add(contactController, BorderLayout.SOUTH);
              setResizable(false);
              show();
         public static void main (String [] argv)
              PersonalContact     Application = new PersonalContact();
    }

    You're missing the new keyword in a couple of places.

  • SD card reader prob with L530 on Win 7

    this forum is so crowded, incredible. sorry to say that. have a serious prob with the integrated SD card reader with my L530 on Win 7:
    - not showing in device manager with/without card
    - not showing in explorer, when card inserted (tried different cards, no worries)
    - installed all available lenovo&win7 card reader driver, no change
    - not even LED light flickering or anything, just off, no function
    - no option in power management to enable card reader (as suggested in some forums)
    would be a shame if i couldnt use the in-built lenovo hardware.
    thanks for help
    klingsor

    Hi, klingsor
    I would firstly make sure that the Card Reader is enabled in BIOS. This can be done by entering BIOS (hit Enter at splash screen, then hit F1 when the menu pops up.) From here, select Security and then I/O Port Access. Make sure the Card Reader here is set to Enabled. 
    I would also recommened making sure your BIOS has been updated, as this can sometimes cause some issues with peripherals not working as intended. The latest version can be found here.
    Best,
    Adam
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution!" This will help the rest of the community with similar issues identify the verified solution and benefit from it.

Maybe you are looking for

  • Can we implement the custom sql query in CR for joining the two tables

    Hi All, Is there anyway to implement the custom sql query in CR for joining the two tables? My requirement here is I need to write sql logics for joining the two tables... Thanks, Gana

  • Can the G4 accommodate external drives in addition to the 2 ATA internals?

    Hi all, I have a G4 dual 1GHz machine (Sales Order Number: M8667LL/A) with two 120 ATA internal drives. I am happy with them but I want to have more HD space. I read Apple's pdf file on G4's capacity and seems to indicate that this tower only will ac

  • Are Skype support response times too long for you?

    Just answer yes or no.... ....and then tell me how long you waited. i.e. Yes 7 hours  I'm really interested in finding out how much I can rely on this forum for a quick response to problems as I use Skype to communicate with my customers, suppliers a

  • Unable to sync podcasts to my nano

    Update iTunes with latest version. I am able to sync my music to the nano but not the podcasts. I have tried resetting and restoring the nano. Nothing works. Every time I click on the Podcasts tab everything freezes. Help! Thanks.

  • Can't hear VO I recorded over external speakers

    - I recorded a VO that I can hear clearly through my headphones when during playback but only as a whisper over my external speakers. - I have no problem hearing the AIFF music bed that is on a separate track so I know audio is working. - I'm using a