JTabbedPane Issues

JTabbedPane Issues:
After finding little info on the subject (that worked for me anyway), I thought I'd post this in case anyone else searched for it.
Removing JTabbedPane's Border the easy way:
UIManager.put("TabbedPane.contentBorderInsets", new Insets(0,0,0,0));
UIManager.put("TabbedPane.border", new BorderUIResource(
     javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)
));If you have to align the tabs with your components, you can do so by setting TabbedPane.tabAreaInsets. The top, left, bottom, right insets rotate with the tab. So, if you wanted to pad the left side of a tab where the tabPlacement is set to BOTTOM, you have to modify the right inset (The tab's 'fold' is always the top inset).
UIManager.put("TabbedPane.tabAreaInsets", new Insets(0,20,0,0));I hope this saves someone out there a great deal of time, it took me long enough to figure it out.

JTabbedPane Issues:
After finding little info on the subject (that worked for me anyway), I thought I'd post this in case anyone else searched for it.
Removing JTabbedPane's Border the easy way:
UIManager.put("TabbedPane.contentBorderInsets", new Insets(0,0,0,0));
UIManager.put("TabbedPane.border", new BorderUIResource(
     javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)
));If you have to align the tabs with your components, you can do so by setting TabbedPane.tabAreaInsets. The top, left, bottom, right insets rotate with the tab. So, if you wanted to pad the left side of a tab where the tabPlacement is set to BOTTOM, you have to modify the right inset (The tab's 'fold' is always the top inset).
UIManager.put("TabbedPane.tabAreaInsets", new Insets(0,20,0,0));I hope this saves someone out there a great deal of time, it took me long enough to figure it out.

Similar Messages

  • Issue with jtabbedpane created in class a, and data filled from b

    I hope that i can explain this clearly and succinctly. I have a tabbed pane that has 2 panels, a combobox, and some textfields in it. each pane has the same panels that l loaded from another class. Basically, i have a class that creates all the contents that would go into each pane and for each new tab, i create a new instance of that class. that solved my issue of not having to create a bunch of panels with different names. unfortunately, when i do an action on the combobox within the tab, the correct text field is not updated. It only modifies the last tab. does anyone know how i can specify the control i want to use withing that particular tab?? I will post a little pseudo to help describe what is going on:
    class a
      panel1 = new JPanel();
    textfield1 = new JtextField();
    combobox1 = new JComboBox();
    i then add these to the panel1;
    actionlistener:
    if combobox1.getSelectedItem().equals(1)
    textfield1.setEditable(false);
    end actionlistener
    class b
    for( i=0; i< 5; i++)
       tasktabs.add(new instance of class a)
    }If this is confusing, i will try to cut my code down to show you.
    Thanks,
    Jason
    }

    attempt #2 (first post disappeared into the ether)
    works OK like this (java 1.4.0_01)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Testing extends JFrame
      public Testing()
        setLocation(300,200);
        setSize(400,250);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JTabbedPane tp = new JTabbedPane();
        tp.addTab("tab 1",new TabPanel());
        tp.addTab("tab 2",new TabPanel());
        tp.addTab("tab 3",new TabPanel());
        getContentPane().add(tp);
      public static void main(String[] args){new Testing().setVisible(true);}
    class TabPanel extends JPanel
      public TabPanel()
        final JTextField tf = new JTextField(10);
        final JComboBox cbo = new JComboBox(new String[]{"0","1","2"});
        add(cbo);
        add(tf);
        cbo.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            if(cbo.getSelectedItem().equals("1")) tf.setEditable(false);}});
    }

  • Issue with re-sizing JTable Headers, JTabbedPane and JSplit pane

    Ok, hopefully I'll explain this well enough.
    In my Swing application I have a split pane, on the left hand side is a JTable and on the right hand is a JTabbedPane. In the tabs of the JTabbedPane there are other JTables.
    In order to make the rows in the JTable on the left and the JTable(s) on the right line up, the Table Header of all the tables is set to the size of the tallest (deepest?) table header.
    Hopefully so far I'm making sense. Now to get to the issue. One of the tables has a number of columns equal to the value on a NumberSpinner (it represents a number of weeks). When this value is changed the table is modified so that it contains the correct number of columns. As the table is re-drawn the table header goes back to its default size so I call my header-resize method to ensure it lines up.
    The problem is this: if I change the number of weeks when selecting a tab other than the one containing my table then everything is fine, the table header is re-sized and everything lines up. If I change the number of weeks with the tab containing the table selected, the column headers stay at their standard size and nothing lines up.
    To make things more complicated, I also put System.out.println's in as every method called in the process to obtain the size of the table header. And every println returned the same height, the height the table header should be.. So I'm really confused.
    Could anyone shed any light on this?
    Thanks.

    Okay I managed to solve the problem by explicitly revalidating and repainting the table header.
    Not sure why it wasnt doing it properly for that table when all the others where fine.
    Oh well...

  • JTabbedPane and variable issue

    ok so here's what I've got, it's a mess I know, everything is added and defined and such, but got cut out to make the code fit, but before I can clean it up I have to figure out what is wrong, my problem as far as I can tell is I don't know how to reference variables in gui, I think I had this problem before but I don't know how to fix it, the variable names are right, it's looking in the right class but nothing in the tab can be found from the action listener. I don't know where else to look. I'm really hoping that's the issue anyway, and not something that requires the demolition of all the code. thank you,
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.text.*;
    import java.awt.event.*;
    import java.io.*;
    public class PoolEstimator extends JFrame
    public PoolEstimator()
    super( "Pool Estimator" );
    DefaultListModel listModel = new DefaultListModel();
    JTabbedPane tab = new JTabbedPane();
    // constructing the second panel
    JPanel CustInfo = new JPanel();
    CustInfo.setLayout(new FlowLayout(FlowLayout.LEFT));
    JLabel FirstName, LastName, Street, City, Zip, Phone, poolDepthup, poolDepthlow,
    yardLength, poolLength, yardWidth, poolWidth, state;
    JTextField FirstNamein, LastNamein, Streetin, Cityin, Zipin,
    Phonein, poolDepthupin, poolDepthlowin, yardLengthin, poolLengthin, yardWidthin, poolWidthin;
    String[] States = {"AL","AK","AS","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN","IA",
    "KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK",
    "OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"};
    JComboBox State = new JComboBox(States);
    FirstName = new JLabel("First Name");
    LastName = new JLabel("Last Name");
    Street = new JLabel("Street Address");
    City = new JLabel("City");
    state = new JLabel("State");
    Zip = new JLabel("Zip Code");
    Phone = new JLabel("Phone Number");
    yardLength = new JLabel("Length of the yard.");
    yardWidth = new JLabel("Width of the yard.");
    poolDepthup = new JLabel("Deepest depth of the pool.");
    poolDepthlow = new JLabel("Shalowest depth of the pool.");
    poolLength = new JLabel("Length of the pool.");
    poolWidth = new JLabel("Width of the pool.");
    FirstNamein  = new JTextField(20);
    LastNamein   = new JTextField(20);
    Streetin   = new JTextField(25);
    Cityin   = new JTextField(15);
    Zipin  = new JTextField(5);
    Phonein  = new JTextField(5);
    poolDepthupin  = new JTextField(2);
    poolDepthlowin  = new JTextField(2);
    yardLengthin  = new JTextField(3);
    poolLengthin  = new JTextField(3);
    yardWidthin  = new JTextField(3);
    poolWidthin  = new JTextField(3);
    JButton Add = new JButton("Add");
    CustInfo.add(Add);
    tab.addTab( "New Customer Estimate", null, CustInfo, "Customer Information Page" );
    getContentPane().add( tab );
    setSize( 325,400 );
    setVisible( true );
    addWindowListener(new WindowAdapter()
       public void windowClosing(WindowEvent e)
       System.exit(0);
         AddButtonHandler AddNew = new AddButtonHandler();
         Add.addActionListener(AddNew);
    class AddButtonHandler implements ActionListener
         public void actionPerformed(ActionEvent e)
              try
              //PoolEstimator run  = new PoolEstimator();
              String StateSelection = PoolEstimator.State.getSelectedItem().toString();
              FileWriter AddEstimate = new FileWriter("Estimate.dat", true);
              AddEstimate.write("First Name: ");
              //AddEstimate.write(run.FirstNamein.getText());
              AddEstimate.write("\nLast Name:  ");
              //AddEstimate.write(LastNamein.getText());
              AddEstimate.write("\nTotal Cost:  ");
              //int width, length, depthupper, depthlower, SurfaceArea, Cement, Rebar, Labor, totalCost;
              //width =Integer.parseInt(poolWidthin);
              //length = Integer.parseInt(poolLengthin);
              //depth = (Integer.parseInt(poolDepthupin) + Integer.parseInt(poolDepthlowin))/2;
              //SurfaceArea = (width * depth)*2+(length*depth)*2;
              //Cement = SurfaceArea * 3;
              //Rebar = SurfaceArea *5;
              //Labor = SurfaceArea%10*18;
              //totalCost = Cement+Rebar+Labor;
              //AddEstimate.write(totalCost);
              AddEstimate.write("\n,");
              AddEstimate.close();
              //run.listmodel.add(run.FirstNamein + run.LastNamein);
            catch(IOException r)
            JOptionPane.showMessageDialog(null,r.getMessage(),"ERROR",2);
    public static void main( String args[] )
    PoolEstimator run = new PoolEstimator();
    run.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    }

    Im a newbie but Im finding it hard to understand what your talking about.
    Could you explain what your program is suppose to do and what you want it to do that it isnt doing yet because you dont know how?
    Plus I just thought I would mention this incase but its easier to use the following JFrame method instead of adding a window adaptor:
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  • JTabbedPane repainting issue

    when i repaint a panel that has a tabbedPane the components from other tabs bleed through the selected one, which is indice 0
    I have a JFrame borderlayout like this
    Container c = frame.getContentPane();
    c.add("West", jList);
    c.add("Center", panel);
    the panel is borderlayout as well like this
    panel.add("North", panel2);
    panel.add("Center", tabbedPane);
    the jList has about 10 items all of which need to remove and repaint panel depending on the selected item in list.
    so I do this:
    in a valueChanged method cause i implement ListSelectionListener
    int index = jList.getSelectedIndex();
    if(index == -1) return;
    c.remove(panel);
    if(index == 0) c.add("Center", new SomeClass());
    else if(index == 1) c.add("Center", new SomeClass2());
    else if(.....) ect....
    // then i do this
    c.invalidate();
    c.validate();
    c.update(c.getGraphics());
    seems to work and i get matching content to list selection, and all components are visible. but compoenets from tabs underneath the currently selected one bleed through. when i click on one of the other tabs, and click back to the first one, the problem is gone. if i choose something else from the jList, the problem starts all over again.

    found the issue - nevermind
    seems like I had old references to objects originally displayed on the panels that sat on TabbedPane
    so when i went tried to bring back an item in jList, i had a mess of old components lingering around.

  • How can we prevent JTabbedPanes from transferring focus to components outside of the tabs during tab traversal?

    Hi,
    I noticed a strange focus traversal behavior of JTabbedPane.
    During tab traversal (when the user's intention is just to switch between tabs), the focus is transferred to a component outside of the tabs (if there is a component after/below the JTabbedPane component), if using Java 6. For example, if using the SSCCE below...
    import java.awt.BorderLayout;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    public class TabbedPaneTest extends JPanel {
        public TabbedPaneTest() {
            super(new BorderLayout());
            JTabbedPane tabbedPane = new JTabbedPane();
            tabbedPane.addTab("Tab 1", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            tabbedPane.addTab("Tab 2", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
            tabbedPane.addTab("Tab 3", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);
            tabbedPane.addTab("Tab 4", buildPanelWithChildComponents());
            tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(tabbedPane);
            JButton button = new JButton("Dummy component that gains focus when switching tabs");
            panel.add(button, BorderLayout.SOUTH);
             * To replicate the focus traversal issue, please follow these steps -
             * 1) Run this program in Java 6; and then
             * 2) Click on a child component inside any tab; and then
             * 3) Click on any other tab (or use the mnemonic keys ALT + 1 to ALT 4).
            button.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    System.err.println("Gained focus (not supposed to when just switching tabs).");
            add(new JScrollPane(panel));
        private JPanel buildPanelWithChildComponents() {
            JPanel panel = new JPanel();
            BoxLayout boxlayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
            panel.setLayout(boxlayout);
            panel.add(Box.createVerticalStrut(3));
            for (int i = 0; i < 4; i++) {
                panel.add(new JTextField(10));
                panel.add(Box.createVerticalStrut(3));
            return panel;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test for Java 6");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.add(new TabbedPaneTest());
                    frame.pack();
                    frame.setVisible(true);
    ... Then we can replicate this behavior by following these steps:
    1) Run the program in Java 6; and then
    2) Click on a child component in any of the tabs; and then
    3) Click on any other tab (or use the mnemonic keys 'ALT + 1' to 'ALT + 4').
    At step 3 (upon selecting any other tab), the focus would go to the component below the JTabbedPane first (hence the printed message in the console), before actually going to the selected tab.
    This does not occur in Java 7, so I'm assuming it is a bug that is fixed. And I know that Oracle suggests that we should use Java 7 nowadays.
    The problem is: We need to stick to Java 6 for a certain application. So I'm looking for a way to fix this issue for all our JTabbedPane components while using Java 6.
    So, is there a way to prevent JTabbedPanes from passing the focus to components outside of the tabs during tab traversal (e.g. when users are just switching between tabs), in Java 6?
    Note: I've read the release notes between Java 6u45 to Java 7u15, but I was unable to find any changes related to the JTabbedPane component. So any pointers on this would be deeply appreciated.
    Regards,
    James

    Hi Kleopatra,
    Thanks for the reply.
    Please allow me to clarify first: Actually the problem is not that the child components (inside tabs) get focused before the selected tab. The problem is: the component outside of the tabs gets focused before the selected tab. For example, the JButton in the SSCCE posted above gets focused when users switch between tabs, despite the fact that the JButton is not a child component of the JTabbedPane.
    It is important for me to prevent this behavior because it causes a usability issue for forms with 'auto-scrolling' features.
    What I mean by 'auto-scrolling' here is: a feature where the form automatically scrolls down to show the current focused component (if the component is not already visible). This is a usability improvement for long forms with scroll bars (which saves the users' effort of manually scrolling down just to see the focused component).
    To see this feature in action, please run the SSCCE below, and keep pressing the 'Tab' key (the scroll pane will follow the focused component automatically):
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextField;
    import javax.swing.JViewport;
    import javax.swing.SwingUtilities;
    public class TabbedPaneAutoScrollTest extends JPanel {
        private AutoScrollFocusHandler autoScrollFocusHandler;
        public TabbedPaneAutoScrollTest() {
            super(new BorderLayout());
            autoScrollFocusHandler = new AutoScrollFocusHandler();
            JTabbedPane tabbedPane = new JTabbedPane();
            tabbedPane.addTab("Tab 1", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            tabbedPane.addTab("Tab 2", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
            tabbedPane.addTab("Tab 3", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);
            tabbedPane.addTab("Tab 4", buildPanelWithChildComponents(20));
            tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(tabbedPane);
            JButton button = new JButton("Dummy component that gains focus when switching tabs");
            panel.add(button, BorderLayout.SOUTH);
             * To replicate the focus traversal issue, please follow these steps -
             * 1) Run this program in Java 6; and then
             * 2) Click on a child component inside any tab; and then
             * 3) Click on any other tab (or use the mnemonic keys ALT + 1 to ALT 4).
            button.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    System.err.println("Gained focus (not supposed to when just switching tabs).");
            button.addFocusListener(autoScrollFocusHandler);
            JScrollPane scrollPane = new JScrollPane(panel);
            add(scrollPane);
            autoScrollFocusHandler.setScrollPane(scrollPane);
        private JPanel buildPanelWithChildComponents(int numberOfChildComponents) {
            final JPanel panel = new JPanel(new GridBagLayout());
            final String labelPrefix = "Dummy Field ";
            final Insets labelInsets = new Insets(5, 5, 5, 5);
            final Insets textFieldInsets = new Insets(5, 0, 5, 0);
            final GridBagConstraints gridBagConstraints = new GridBagConstraints();
            JTextField textField;
            for (int i = 0; i < numberOfChildComponents; i++) {
                gridBagConstraints.insets = labelInsets;
                gridBagConstraints.gridx = 1;
                gridBagConstraints.gridy = i;
                panel.add(new JLabel(labelPrefix + (i + 1)), gridBagConstraints);
                gridBagConstraints.insets = textFieldInsets;
                gridBagConstraints.gridx = 2;
                textField = new JTextField(22);
                panel.add(textField, gridBagConstraints);
                textField.addFocusListener(autoScrollFocusHandler);
            return panel;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test for Java 6 with auto-scrolling");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.add(new TabbedPaneAutoScrollTest());
                    frame.setSize(400, 300);
                    frame.setVisible(true);
    * Crude but simple example for auto-scrolling to focused components.
    * Note: We don't actually use FocusListeners for this feature,
    *       but this is short enough to demonstrate how it behaves.
    class AutoScrollFocusHandler extends FocusAdapter {
        private JViewport viewport;
        private JComponent view;
        public void setScrollPane(JScrollPane scrollPane) {
            viewport = scrollPane.getViewport();
            view = (JComponent) viewport.getView();
        @Override
        public void focusGained(FocusEvent event) {
            Component component = (Component) event.getSource();
            view.scrollRectToVisible(SwingUtilities.convertRectangle(component.getParent(),
                    component.getBounds(), view));
    Now, while the focus is still within the tab contents, try to switch to any other tab (e.g. by clicking on the tab headers, or by using the mnemonic keys 'ALT + 1' to 'ALT + 4')...
    ... then you'll notice the following usability issue:
    1) JRE 1.6 causes the focus to transfer to the JButton (which is outside of the tabs entirely) first; then
    2) In response to the JButton gaining focus, the 'auto-scrolling' feature scrolls down to the bottom of the form, to show the JButton. At this point, the tab headers are hidden from view since there are many child components; then
    3) JRE 1.6 transfers the focus to the tab contents; then
    4) The 'auto-scrolling' feature scrolls up to the selected tab's contents, but the tab header itself is still hidden from view (as a side effect of the behavior above); then
    5) Users are forced to manually scroll up to see the tab headers whenever they are just switching between tabs.
    In short, the tab headers will be hidden when users switch tabs, due to the Java 6 behavior posted above.
    That is why it is important for me to prevent the behavior in my first post above (so that it won't cause usability issues when we apply the 'auto-scrolling' feature to our forms).
    Best Regards,
    James

  • How to set focus on the title of JTabbedPane

    I have created a JTabbedPane and added three JPanels to it. They are titled, say "Panel 1", "Panel 2" and "Panel 3". And each of them contains buttons and text areas. Since this app is for physically disabled users, it must provide navigation through these three tabs with keyboard operations only (i.e. without mouse clicks).
    When the title "Panel 1" gets focused, users can go to "Panel 2" by the right arrow key. When Panel 2 is brought up, however, the title "Panel 2" does not get focused. Instead the first button inside panel 2 is focused. In order for users to navigate to 'Panel 3" by the arrow key, the title "Panel 2" has to be focused. How do I set focus on the tab title?
    I have tried 'requestFocus()' on Panel 2, but it does not work. Please help me with this issue. Thanks in advance.

    I'd be quite interested to know if this can be doen as well so I thought I'd post this message to move it to the top of the board.
    Thanks.

  • Scrolling through text file records issue?

    Hi there
    I am having an issue when trying to scroll though my saved contacts.
    On boot up they all work fine, and each record goes in its corresponding textfield. Now I cannot scroll left and right through the records, to display each new record.
    I tried making a marker at the end of each set, by putting a -1, -2 and so on per record, to distinguish the end of a record set. With the below however when I click right, and it just puts a -1 in the textfield??
    How do I get the program to distinguish the difference between the end of a record and the details of a new one?
    //This code is used at start up to read in the first record. This works fine.
    public TabbedPaneDemo()
    //BufferedReader br = null;
    BufferedReader no = null;
    Count = 0;
    try
    br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
    String s = "";
    while((s=br.readLine()) != null )
    Count = 1;
    //System.out.println("Data is " + s);
    inboundtext = s;
    if ( Count == 1 )
    //fdTitle.setText(inboundtext);
    fdTitle.setText(inboundtext);
    break;
    while((s=br.readLine()) != null )
    //System.out.println("Data is " + s);
    inboundtext = s;
    Count = 2;
    if ( Count == 2 )
    //fdTitle.setText(inboundtext);
    fdFirst.setText(inboundtext);
    break;
    //--------and so on tfor the rest
    //The code here is the problem. This is the button to scroll right through the records.
    else if (evt.getSource() == pane_butRIGHT)
    System.out.println("RIGHT");
    Aniversary = fdAniversary.getText();
    int test = Integer.parseInt(Aniversary);
    int setter = 4;
    try
    br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
    String s = "";
    while((s=br.readLine()) != null )
    Count = 1;
    inboundtext = s;
    //System.out.println(s);
    if ( inboundtext.equals("-1"))
    System.out.println("positive");
    //continue ;
    while((s=br.readLine()) != null )
    fdTitle.setText(inboundtext);
    fdFirst.setText(inboundtext);
    //break;
    catch(IOException ie)
    finally
    try
    if(br!=null) br.close();
    catch(Exception e)
    /* my text file I'm reading from below */
    mr
    lee
    smithers
    smith
    chappy
    [email protected]
    1 d road
    delta rd
    surrey
    kt4
    uk
    ww.vw.com
    337
    5791
    0781
    arm
    110 fb road
    cambs
    cambs
    cb1
    UK
    arm.com
    3rd line
    sysadmin
    410
    00
    00
    1
    2
    3
    4
    -1
    dr
    bob
    b
    bun
    cob
    [email protected]
    main st
    hamp
    ny
    14457
    ussa
    arse.com
    44
    00
    66
    piano inc
    main st
    rubbish
    5749
    duff
    usa
    abc.com
    yoyo
    billies
    desk
    222
    111
    00
    3
    69
    8
    7
    -2

    Hi camickr
    thanks for the responce,
    I understand what you saying with the stringtokenizer.
    However my text file would have loads of rows of contacts. My problem comes in where when I want to scroll through those rows, I need them to be display on my GUI which has a Jtextfield per contact detail type, IE one for name and another surname and so on.
    Now when the program loads, it reads in the first contact set fine. If I want to read the second contact set, I am stuck. Same again applies if I want to scroll back throgh the contacts? How do I do this?
    As you can see in the default constructor, there is a whole batch of while loops getting text initally for the JTextfields. If I could change this just to read the second through in and so on when hitting left or right, problem solved.
    thanks
    Whole program below:
    import javax.swing.JFrame;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.awt.Graphics.*;
    import java.awt.Color.*;
    import javax.swing.JPanel.*;
    import javax.swing.JLabel;
    import java.awt.event.*;
    import javax.swing.text.html.*;
    import java.net.*;
    import java.net.URL.*;
    import java.io.IOException;
    import java.io.*;
    import java.awt.image.*;
    import javax.swing.border.*;
    import java.applet.*;
    import javax.swing.JEditorPane;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.tree.TreeSelectionModel;
    import javax.swing.JTabbedPane;
    import javax.swing.ImageIcon;
    import java.util.StringTokenizer;
    public class TabbedPaneDemo extends JPanel implements ActionListener
         JButton pane_butSave = new JButton();
    private JLabel lblTitle = new JLabel("tilte:" );
    private JLabel lblFirst = new JLabel("first:" );
    private JLabel lblMiddle = new JLabel("Middle:");
    private JLabel lblLast = new JLabel("Last:" );
    private JLabel lblNickName= new JLabel("nick name:" );
    private JLabel lblEmail= new JLabel("e-mail:" );
    private JTextField fdTitle = new JTextField(4);
    private JTextField fdFirst= new JTextField(15);
    private JTextField fdMiddle = new JTextField(15);
    private JTextField fdLast = new JTextField(20);
    private JTextField fdNickName = new JTextField(15);
    private JTextField fdEmail = new JTextField(50);
    private JLabel lblStreetAddress = new JLabel("Street Address");
    private JLabel lblCity = new JLabel("Town");
    private JLabel lblCounty = new JLabel("County");
    private JLabel lblCountry = new JLabel("Country");
    private JLabel lblPostCode = new JLabel("ZIP/Post");
    private JLabel lblWebpage = new JLabel("Web Page");
    private JLabel lblPhone = new JLabel("Phone");
    private JLabel lblFax = new JLabel("Fax");
    private JLabel lblMobile = new JLabel("Mobile");
    private JTextField fdStreetAddress = new JTextField();
    private JTextField fdCity = new JTextField ();
    private JTextField fdCounty = new JTextField ();
    private JTextField fdCountry = new JTextField ();
    private JTextField fdPostCode = new JTextField ();
    private JTextField fdWebpage = new JTextField ();
    private JTextField fdPhone = new JTextField ();
    private JTextField fdFax = new JTextField ();
    private JTextField fdMobile = new JTextField ();
    private JLabel lblCompany = new JLabel("Company");
    private JLabel lblCompanyAddress = new JLabel("Company Address");
    private JLabel lblCompanyCity = new JLabel("Town");
    private JLabel lblCompanyCounty = new JLabel("County");
    private JLabel lblCompanyPostCode = new JLabel("ZIP/Post");
    private JLabel lblCompanyCountry = new JLabel("Country");
    private JLabel lblCompanyWebPage = new JLabel("Web Page");
    private JLabel lblJobTitle = new JLabel("JOB Title");
    private JLabel lblDepartment = new JLabel("Department");
    private JLabel lblOffice = new JLabel("Office");
    private JLabel lblCompanyPhone = new JLabel("Phone");
    private JLabel lblCompanyFax = new JLabel("Fax");
    private JLabel lblPager = new JLabel("Pager");
    private JLabel lblCompanyIPphone = new JLabel("IP Phone");
    private JTextField fdCompany = new JTextField ();
    private JTextField fdCompanyAddress = new JTextField ();
    private JTextField fdCompanyCity = new JTextField ();
    private JTextField fdCompanyCounty = new JTextField ();
    private JTextField fdCompanyPostCode = new JTextField ();
    private JTextField fdCompanyCountry = new JTextField ();
    private JTextField fdCompanyWebPage = new JTextField ();
    private JTextField fdJobTitle = new JTextField ();
    private JTextField fdDepartment = new JTextField ();
    private JTextField fdOffice = new JTextField ();
    private JTextField fdCompanyPhone = new JTextField ();
    private JTextField fdCompanyFax = new JTextField ();
    private JTextField fdPager = new JTextField ();
    private JTextField fdCompanyIPphone = new JTextField ();
    private JLabel lblSpouse = new JLabel("Spouse");
    private JLabel lblGender = new JLabel("Gender");
    private JLabel lblBirthday = new JLabel("Birthday");
    private JLabel lblAniversary = new JLabel("Aniversary");
    private JTextField fdSpouse = new JTextField ();
    private JTextField fdGender = new JTextField ();
    private JTextField fdBirthday = new JTextField ();
    private JTextField fdAniversary = new JTextField ();
    private JLabel lblNotes = new JLabel("Other Notes");
    private JTextArea taNotes = new JTextArea ();
    private ImageIcon imaNameInfo = new ImageIcon("nameinfo.gif");
    private JLabel lblNameInfo = new JLabel(imaNameInfo);
    private ImageIcon imaHomeInfo = new ImageIcon("homeinfo.gif");
    private JLabel lblHomeInfo = new JLabel(imaHomeInfo);
    private ImageIcon imaBusinessInfo = new ImageIcon("businessinfo.gif");
    private JLabel lblBusinessInfo = new JLabel(imaBusinessInfo);
    private ImageIcon imaPersonalInfo = new ImageIcon("personal.gif");
    private JLabel lblPersonalInfo = new JLabel(imaPersonalInfo);
    private ImageIcon imaOtherInfo = new ImageIcon("otherinfo.gif");
    private JLabel lblOtherInfo = new JLabel(imaOtherInfo);
    private JButton pane_butAddOK = new JButton("Ok");
    private JButton pane_butAddCANCEL = new JButton("Exit");
    //private JButton pane2_butAddOK = new JButton("Ok");
    private JButton pane2_butAddCANCEL = new JButton("Exit");
    //private JButton pane3_butAddOK = new JButton("Ok");
    private JButton pane3_butAddCANCEL = new JButton("Exit");
    //private JButton pane4_butAddOK = new JButton("Ok");
    private JButton pane4_butAddCANCEL = new JButton("Exit");
    //private JButton pane5_butAddOK = new JButton("Ok");
    private JButton pane5_butAddCANCEL = new JButton("Exit");
    private ImageIcon imaLeft = new ImageIcon("left.gif");
    private ImageIcon imaRight = new ImageIcon("right.gif");
    private JButton pane_butLEFT = new JButton(imaLeft);
    private JButton pane_butRIGHT = new JButton(imaRight);
    private JButton pane2_butLEFT= new JButton(imaLeft);
    private JButton pane2_butRIGHT= new JButton(imaRight);
    private JButton pane3_butLEFT = new JButton(imaLeft);
    private JButton pane3_butRIGHT = new JButton(imaRight);
    private JButton pane4_butLEFT = new JButton(imaLeft);
    private JButton pane4_butRIGHT = new JButton(imaRight);
    private JButton pane5_butLEFT = new JButton(imaLeft);
    private JButton pane5_butRIGHT = new JButton(imaRight);
    private JButton pane_butNEW= new JButton("Reset");
    private JButton pane2_butNEW = new JButton("Reset");
    private JButton pane3_butNEW = new JButton("Reset");
    private JButton pane4_butNEW = new JButton("Reset");
    private JButton pane5_butNEW = new JButton("Reset");
    private JTabbedPane tabbedPane = new JTabbedPane();
    private RandomAccessFile raf;
                   String inboundtext;
                   String Title, First, Middle, Last, NickName, Email;
                   String Address, Town, County, PostCode, Country, Phone, Fax,
                        Mobile, Webpage;
                   String Company, CompanyAddress, CompanyTown, CompanyCounty, CompanyPostCode,
                        CompanyCountry, Job, Department, Office, CompanyPhone, CompanyFax,
                        CompanyPager,CompanyIPPhone, CompanyWebpage;
                   String Spouse, Gender, Birthday, Aniversary;
                   String Notes;
                   public JTextArea area = new JTextArea();
                   BufferedReader br = null;
                   int Count;
    public TabbedPaneDemo()
              pane_butSave .setVerticalTextPosition(SwingConstants.BOTTOM);
                   pane_butSave .setHorizontalTextPosition(SwingConstants.CENTER);
              pane_butSave .setText("<html><center>"+"Update "+"<br>"+"Changes"+"</center></html>");
              pane_butAddOK .setVerticalTextPosition(SwingConstants.BOTTOM);
                   pane_butAddOK .setHorizontalTextPosition(SwingConstants.CENTER);
              pane_butAddOK .setText("<html><center>"+"New "+"<br>"+"Contact"+"</center></html>");
         //BufferedReader br = null;
         BufferedReader no = null;
         Count = 0;
         try
              br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
              String s = "";
              while((s=br.readLine()) != null )
                   Count = 1;     
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   if ( Count == 1 )
                        //fdTitle.setText(inboundtext);
                        fdTitle.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 2;
                   if ( Count == 2 )
                        //fdTitle.setText(inboundtext);
                        fdFirst.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 3;
                   if ( Count == 3 )
                        //fdTitle.setText(inboundtext);
                        fdMiddle.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 4;
                   if ( Count == 4 )
                        //fdTitle.setText(inboundtext);
                        fdLast.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 5;
                   if ( Count == 5 )
                        //fdTitle.setText(inboundtext);
                        fdNickName.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 6;
                   if ( Count == 6 )
                        //fdTitle.setText(inboundtext);
                        fdEmail.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 7;
                   if ( Count == 7 )
                        //fdTitle.setText(inboundtext);
                        fdStreetAddress.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 8;
                   if ( Count == 8 )
                        //fdTitle.setText(inboundtext);
                        fdCity.setText(inboundtext);
                        break;
         while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 9;
                   if ( Count == 9 )
                        //fdTitle.setText(inboundtext);
                        fdCounty.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 10;
                   if ( Count == 10 )
                        //fdTitle.setText(inboundtext);
                        fdCountry.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 11;
                   if ( Count == 11 )
                        //fdTitle.setText(inboundtext);
                        fdPostCode.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 12;
                   if ( Count == 12 )
                        //fdTitle.setText(inboundtext);
                        fdWebpage.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 13;
                   if ( Count == 13 )
                        //fdTitle.setText(inboundtext);
                        fdPhone.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 14;
                   if ( Count == 14 )
                        //fdTitle.setText(inboundtext);
                        fdFax.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 15;
                   if ( Count == 15 )
                        //fdTitle.setText(inboundtext);
                        fdMobile.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 16;
                   if ( Count == 16 )
                        //fdTitle.setText(inboundtext);
                        fdCompany.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 17;
                   if ( Count == 17 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyAddress.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 18;
                   if ( Count == 18 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyCity.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 19;
                   if ( Count == 19 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyCounty.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 20;
                   if ( Count == 20 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyPostCode.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 20;
                   if ( Count == 20 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyCountry.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 20;
                   if ( Count == 20 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyWebPage.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 21;
                   if ( Count == 21 )
                        //fdTitle.setText(inboundtext);
                        fdJobTitle.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 22;
                   if ( Count == 22 )
                        //fdTitle.setText(inboundtext);
                        fdDepartment.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 23;
                   if ( Count == 23 )
                        //fdTitle.setText(inboundtext);
                        fdOffice.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 24;
                   if ( Count == 24 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyPhone.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 25;
                   if ( Count == 25 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyFax.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 26;
                   Company = fdCompany.getText();
                   String comp = Company;
                   //System.out.println(Company);
                   if ( Count == 26 )
                        //fdTitle.setText(inboundtext);
                        fdPager.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 27;
                   if ( Count == 27 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyIPphone.setText(inboundtext);
                        break;
                   while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 28;
                   if ( Count == 28 )
                        //fdTitle.setText(inboundtext);
                        fdSpouse.setText(inboundtext);
                        break;
                   while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 29;
                   if ( Count == 29 )
                        //fdTitle.setText(inboundtext);
                        fdGender.setText(inboundtext);
                        break;
                   while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 30;
                   if ( Count == 30 )
                        //fdTitle.setText(inboundtext);
                        fdBirthday.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 31;
                   if ( Count == 31 )
                        //fdTitle.setText(inboundtext);
                        fdAniversary.setText(inboundtext);
                        break;
              no = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\notes.txt")));
              String n = "";
              while((n=no.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = n;
                   Count = 32;
                        //taNotes.setText(inboundtext);
                        taNotes.append(n + '\n' );
                        First delete notes.txt
                                  You always want to take a mirror image of what is in the box at that time
                                  save that that to a new notes.txt*/
         catch(IOException ie)
         finally
              try
                   if(br!=null) br.close();
              catch(Exception e)
    File name = new File("\\c:\\filename.txt");
              if( name.isFile() )
                   try
                        BufferedReader input = new BufferedReader( new FileReader( name ) );
                        StringBuffer buffer = new StringBuffer();
                        String text;
                        while (( text = input.readLine() ) != null )
                        buffer.append( text + "\n" );
                        //buffer.append( buffer.toString() );
                        System.out.println(buffer);
                        inBoundtext.append( buffer.toString() );
                   catch( IOException ioException )
                        JOptionPane.showMessageDialog( this, "FILE ERROR", "FILE ERROR", JOptionPane.ERROR_MESSAGE );
         setLayout(new GridLayout(1,1));
              JPanel pane = new JPanel();
              pane.setLayout(null);
    //--------------NAME PANEL START----------------------------------------
         lblNameInfo.setBounds(10, 10, 500, 50);
         pane.add(lblNameInfo);
         lblFirst.setBounds(20, 60 ,50 ,50);
              pane.add(lblFirst);
              fdFirst.setBounds(60, 70, 70, 30);
              pane.add(fdFirst);
              lblMiddle.setBounds(150, 60 ,50 ,50);
              pane.add(lblMiddle);
              fdMiddle.setBounds(200, 70, 70, 30);
              pane.add(fdMiddle);
              lblLast.setBounds(300, 60 ,50 ,50);
    pane.add(lblLast);
    fdLast.setBounds(350, 70, 70, 30);
              pane.add(fdLast);
              lblTitle.setBounds(20, 100 ,50 ,50);
                   pane.add(lblTitle);
              fdTitle.setBounds(60, 110, 70, 30);
              pane.add(fdTitle);
              lblNickName.setBounds(150, 100, 70,50);
              pane.add(lblNickName);
              fdNickName.setBounds(220, 110, 70, 30);
              pane.add(fdNickName);
              lblEmail.setBounds(20,160, 100, 50);
              pane.add(lblEmail);
              fdEmail.setBounds(70, 170, 210,30);
              pane.add(fdEmail);
              pane_butLEFT.setBounds(10, 400, 50, 40);
              pane.add(pane_butLEFT);
    pane_butRIGHT.setBounds(450, 400, 50, 40);
    pane.add(pane_butRIGHT);
              pane_butAddOK.setBounds(160, 400, 70, 50);
              pane.add(pane_butAddOK);
              pane_butAddCANCEL.setBounds(240, 400, 90, 40);
              pane.add(pane_butAddCANCEL);
              pane_butSave.setBounds(340,400, 90, 40);
              pane.add(pane_butSave);
              pane_butNEW.setBounds(80, 400, 70, 40);
              pane.add(pane_butNEW);
              tabbedPane.addTab("Name", null, pane, "Name Information");
    tabbedPane.setSelectedIndex(0);
    //--------------NAME PANEL END----------------------------------------
    //--------------HOME PANEL START----------------------------------------
    JPanel pane2 = new JPanel();
    pane2.setLayout(null);
    //pane2.setLayout(new GridLayout(6, 6, 10, 10));
    tabbedPane.addTab("Home", null, pane2, "Home Information");
                   lblHomeInfo.setBounds(10, 10, 500, 50);
         pane2.add(lblHomeInfo);
         lblStreetAddress.setBounds(10, 60 ,100 ,50);
              pane2.add(lblStreetAddress);
              fdStreetAddress.setBounds(100, 70, 150, 30);
              pane2.add(fdStreetAddress);     
              lblCity.setBounds(10, 90 ,100 ,50);
              pane2.add(lblCity);
              fdCity.setBounds(100, 100, 100, 30);
              pane2.add(fdCity);
                   lblCounty.setBounds(10, 120 ,100 ,50);
              pane2.add(lblCounty);
              fdCounty.setBounds(100, 130, 100, 30);
              pane2.add(fdCounty);
              lblCountry.setBounds(10, 150 ,100 ,50);
              pane2.add(lblCountry);
              fdCountry.setBounds(100, 160, 100, 30);
              pane2.add(fdCountry);
              lblPostCode.setBounds(10, 180 ,100 ,50);
              pane2.add(lblPostCode);
              fdPostCode.setBounds(100, 190, 100, 30);
              pane2.add(fdPostCode);
              lblWebpage.setBounds(10, 250 ,100 ,50);
              pane2.add(lblWebpage);
              fdWebpage.setBounds(100, 260, 330, 30);
              pane2.add(fdWebpage);
              lblPhone.setBounds(270, 60 ,100 ,50);
              pane2.add(lblPhone);
              fdPhone.setBounds(310, 70, 100, 30);
              pane2.add(fdPhone);
              lblFax.setBounds(270, 90 ,100 ,50);
              pane2.add(lblFax);
              fdFax.setBounds(310, 100, 100, 30);
              pane2.add(fdFax);
              lblMobile.setBounds(270, 120,100 ,50);
              pane2.add(lblMobile);
              fdMobile.setBounds(310, 130, 100, 30);
              pane2.add(fdMobile);
                   pane2_butLEFT.setBounds(10, 400, 50, 40);
              pane2.add(pane2_butLEFT);
    pane2_butRIGHT.setBounds(450, 400, 50, 40);
    pane2.add(pane2_butRIGHT);
    /* pane2_butAddOK.setBounds(180, 400, 50, 40);
              pane2.add(pane2_butAddOK);*

  • JTabbedPane API too primitive??

    hello,
    does anyone else out there wish for a variant of JTabbedPane.addTab()
    that looked like this?:
    public void addTab(Component tab, Component body);
    with such a method, one could pass in a jlabel for the tab component and therefore
    have complete control over the placement of the icon (and whether an icon should
    be displayed on the tab). but this is trivial compared to the need to put, say a close
    button on a tab (possibly selectively) by passing a button as the tab component,
    or a panel composite. another example of what i really want to
    do is the grafting of a jpopupmenu on a jlabel that i use as the component for the
    tab so that the tab can actually represent something tangible in my business domain
    and domain actions exposed via the jpopupmenu.
    i just skimmed a thread on a customization/extension to jtabbedpane to allow for
    a "close tab" button ('x') on each tab:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=337070
    i'm trying to avoid having to do something so complicated.
    - has this issue been brought up before? (i did a quick search but did not find)
    - if anyone from sun is listening, are there plans to add such a feature to 1.5/tiger?? (i assume
    it's probably already too late)
    is there a jtabbedpane extension out there that provides such a feature?
    thank you!
    / eitan

    Actually, this is something that was supposed to show up in Tiger: a JTabbedPane that used arbitrary components as the tabs. But they dropped the idea, apparently at the last minute. They also failed to make the improvements to the Actions architecture that they had been promising. I'm sure they have good reasons, but it's hard not to feel betrayed...

  • Jtabbedpane with replacing tab content

    Hello,
    I am developing an applet that should contain a JTabbedPane with 2 tabs.
    The second tab is easy to do because ti contains one Jpanel all the way.
    the first however is an issue, because i am supposed to change its content when the applet is running.
    this means i have 3 JPanels, J1, J2, J3.
    At tge beginning the applet contains J1 in the first tab.
    and J1 contains a button. when i click that button the applet should replace J1 with J2.
    the problem is i haven't managed to find a solution yet :(
    I have tried with setvisible(false) and validate(). It won't work. I also tried to add the J2 panel over J1, but encountered no succes.
    anybody has any idea ?
    Message was edited by:
    asrfel

    If you want to change back and forth repeatedly then wrap J1/2/3 in a JPanel with a CardLayout.
    If you can discard one when it's done with, use the remove() and insertTab() methods of JTabbedPane.

  • Change tab navigation keys in JTabbedPane

    OK, what's the trick here?
    I need to map a different pair of keys (replacing the default right/left keys) to manage tab selection in a JTabbedPane.
    Anybody have some insight into this?

    Well, as is so often the case after posting something, I found a discussion of a similiar issue with a JTable using a custom UI to manage keyboard assignments and this is working fine.
    Except that now the selected tab color isn't getting set ...

  • Strange JTabbedPane behaviour

    In my application I need tabs only, i.e., without the content area. I'm trying to achieve that by adding JComponent with (1,1) dimensions. But the more tabs I add the bigger the size of JTabbedPane becomes. Is it a bug?
    Here is a simple testcase:
    package tabtest;
    import java.awt.Dimension;
    import javax.swing.JComponent;
    public class NewJFrame extends javax.swing.JFrame {
        public NewJFrame() {
            jSplitPane1 = new javax.swing.JSplitPane();
            jPanel1 = new javax.swing.JPanel();
            jPanel2 = new javax.swing.JPanel();
            jLabel2 = new javax.swing.JLabel();
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jButton1 = new javax.swing.JButton();
            jButton1.setPreferredSize(new Dimension(100,50));
            jPanel1.setPreferredSize(new Dimension(500, 200));
            this.setSize(800,600);
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
            jPanel1.setLayout(new java.awt.BorderLayout());
            jLabel2.setText("jLabel2");
            jPanel2.add(jLabel2);
            jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER);
            jPanel1.add(jTabbedPane1, java.awt.BorderLayout.NORTH);
            jSplitPane1.setLeftComponent(jPanel1);
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jSplitPane1.setRightComponent(jButton1);
            getContentPane().add(jSplitPane1, java.awt.BorderLayout.NORTH);
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            TestComponent tc=new TestComponent();
            tc.setSize(1,1);
            tc.setPreferredSize(new Dimension(1,1));
            jTabbedPane1.addTab("Tab "+Integer.toString(jTabbedPane1.getComponentCount()),null,tc, "Tab "+Integer.toString(jTabbedPane1.getComponentCount()));
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JPanel jPanel2;
        private javax.swing.JSplitPane jSplitPane1;
        private javax.swing.JTabbedPane jTabbedPane1;
    /** JComponent class to be used with JTabbedPane
    class TestComponent extends JComponent{
    }It adds a new tab each time the button is clicked, and with each click it moves jLabel2 down. You may test it to see how the size of JTabbedPane grow.
    Does anyone have ideas why it behaves so? Is there any other way to get tabs without content area?

    Indeed. Most obvious solution, but I've forgot about that. Thanks, that resolved the issue.
    Still, I'm curious why the JTabbedPane keeps growing? As far as I understand the size of JTabbedPane equals the size of the biggest component, isn't it?

  • JTable and JTabbedPane questions

    I have an application which has some JTabbedPanes setup, one of which has a table on it.
    What i'm after is a way of having a user select a row from the table and in doing so this will send them to another tabbedpane.
    So what i need is a way of assigning each row an ID number, then being able to extract this ID, and being able to switch to a new tab without having to click on the tab itself.
    I hope someone can point me in the right direction.
    One more question as well.
    I'm designing a networked bulletinboard application (using javaspaces) and i'm having an implementation issue.
    At the moment I can list all the topics in a table which just contains |the author, topic title and date created|.
    I'm having trouble thinking of a good way of displaying the actuall topic itself (and multiple follow-up posts).
    I was thinking of doing this in another table, but i couldnt find a way of customizing the layout enough to display formatted text. So i thought I would just do a loop of JTextAreas for each topic.
    Something along the lines of:
    while (i < number_of_posts)
    Create_JTextArea(post[i]);
    Do you think this would be a suitable way of implementing this? Or is there a better way that i'm missing?

    So what i need is a way of assigning each row an ID numberStore the ID number in the TableModel. You then just remove the TableColumn from the TableColumnModel and the ID will not be displayed in the table. You then simply use model.getValueAt(...) to reference the ID.

  • 24pt Font Size Tab Text for JTabbedPane

    I'm creating an app for use with Touchscreens and need to make the buttons and such, large enough to fit the tip of a finger.
    I'm having trouble with the JTabbedPane font size and am having trouble finding a way to make the text in the tab larger.
    Same issue with text in a border. Just for looks but would be nice.
    And the text in the window title.
    I've searched the forums and the tutorials but couldn't find anything. Thanks in advance for your assistance.
    Stone

    Hi,
    the text in the window's title is managed by the underlying OS. So, I guess there is no possibility to influence this text. Except you change the display properties of the OS on this computer that runs your app.
    Regards,
    Patrick

  • "X" amount of tabs in a JTabbedPane

    Hi. I'm trying to make an app that opens files in tabbed panes (JTabbedPane) which is itself inside a JInternalFrame. So far, every example i've seen has a pre-determined amount of tabs (and they all are give a handle). Problem is: i have no idea how many tabs a user will open: maybe 1, maybe 15, or anything in between, or even more. I haven't seen any such examples, myself. :-/
    Can anyone kidly point me to an example i could use - assuming what i want to do is possible - please?
    Thank you in advance.
    JH

    That sounds like a design issue to me.
    I'm quite sure it's that as well... The original app wasn't designed to handle more than 1 file, and i was given the task to convert it to handle many files. It's a bunch of cut-paste, quickly adapted code: in other words, jungle code.
    Can you post a short,
    self-contained, compileable and executable example which
    shows the problem?
    sigh
    I asked. I cant.
    I guess i'll have to hack through on my own... ;-(
    Thanks anyways...
    JH

Maybe you are looking for

  • Rel Stratgy with classifin -PR-How Pur Ogr know after PR has fully approved

    Dear Expert, We are implementing Release Strategy for PR with classification up to level 6 Release group and 7 Rel code. My question is : When a PR or many PRs have been completely approved, How purchasing department will know that a PR or many PRs h

  • Error-50150 occured at DAQmx Write

    Hello,     I am experiencing a seemingly random error in a large program. The error occurs in a part of the program that simulates tach signals to a CPLD. I have not been able to find out what conditions cause this error, it seems to be random in nat

  • IPhone Software/Recovery Mode Issue

    After updating my iPhone Software a few moments ago, my iPhone appears to no longer work (I can't get past the apple icon start screen, which keeps refreshing) and iTunes is saying that the iPhone is in recovery mode. I now am being offered the optio

  • HT201274 How do I deactivate my iPhone/iMessage?

    I recently switched carriers and to a driod phone.  I am unable to receive messages from iPhone users because it still tries to iMessage me.

  • N79 Profile Setting Problem

    I've just got N79 and I set my profile to "Meeting" and I found that: When I set my Ringing Type to "Beep once" or "Silent" with "Vibrating alert ON". My phone does not vibrate at all. Please suggest Thanks Phitha