JTabbedPane layout problem

I have a JTabbedPane as shown below:
|                          |
| ----- -----                         |
|  |   | |   |                        |
| ----------------------------------- |
| | --------------- --------------- | |
| | --------------- --------------- | |
| | --------------- --------------- | |
| | --------------- --------------- | |
| | --------------- --------------- | |
| | --------------- --------------- | |
| |_________________________________| |
|                                     |
--------------------------------------|As you can see, each tab has two columns and with 5 rows each column. Each row is a horizontal javax.swing.Box of components.
My problem sometimes I only have, for example, 2 rows in the second column. They become stretched to fill the remaining space and I don't like that.
How do I resolve this so it doesn't do that?
Thnks for any help!
Liam

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
public class Test extends JFrame {
  public Test() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    JTabbedPane jtp = new JTabbedPane();
    content.add(jtp, BorderLayout.CENTER);
    Random r = new Random();
    for (int i=0; i<2; i++) {
      JPanel tab = new JPanel(new GridLayout(6,2));
      jtp.add("Tab "+i, tab);
      for (int j=0; j<6; j++) {
        tab.add(new JLabel("Label-"+i+","+j+":", JLabel.RIGHT));
        if (j==0 || r.nextBoolean()) tab.add(new JTextField("Text-"+i+","+j));
        else tab.add(Box.createHorizontalBox());
    setSize(300, 300);
    setVisible(true);
  public static void main(String args[]) { new Test(); }
class MyCardLayout extends CardLayout {
  public void show();
}

Similar Messages

  • CSS Layout Problem?

    Can someone please help me with a layout problem.
    As far as I can tell the page looks as it should in Netscape,
    Firefox, etc., but IE6 and 7 refuse to work correctly.
    The page I am working on is:
    http://www.vmtampademo.com/localangler/testpage.html
    Most of the picture caption and headline of the middle column
    is behind the picture. I attempted to force the info with a
    seperating div which seems to work sometimes. I doubt that this is
    the correct solution. What am I doing wrong?
    Thank you for the help!

    It looks fine in Firefox 2.0.0.1, Opera 9.10, and IE 7.

  • How to use put Obsever Patterns in JTabbedPane layout

    Hi, I am trying to put Observer Patterns in a JTabbedPane layout so that my program can pass event data to other class. But I don't know how I can accomplish this. Could someone help me?
    Thanks,
    Joanna
    import javax.swing.*;
    public class Restaurant {
         public static void main(String[] args) {
              JFrame frame = new JFrame("168 Restaurant");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JTabbedPane tp = new JTabbedPane();
              pizzaPanel pPanel = new pizzaPanel(); // create pizzaPanel class
              tp.addTab("Order", pPanel);
              double total; String result;
              total = pPanel.getTotal();                       //get total price and order from pizzaPanel class
              result = pPanel.getPizza();
              pricePanel price = new pricePanel(total, result);       //pass to pricePanel class
              tp.addTab("Payment", price);
              frame.getContentPane().add(tp);
              frame.pack();
              frame.setVisible(true);
    //pizzaPanel class
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class pizzaPanel extends JPanel {
         public double total = 0;
         public String order = " ";
         private JPanel titlePanel = new JPanel();
         private JPanel gridPanel = new JPanel();
         private JRadioButton cb1, cb2;
         private JButton submit;
         public pizzaPanel () {
              titlePanel.setPreferredSize(new Dimension(100, 30));
              titlePanel.setLayout(new FlowLayout());
              JLabel label = new JLabel("Please order your food");
              titlePanel.add(label);
              gridPanel.setLayout (new GridLayout(1, 4));
              JLabel b1 = new JLabel("Premium Goats' Cheese $5.00");
              cb1 = new JRadioButton ("1");cb2 = new JRadioButton ("2");
              submit = new JButton("Submit");
              submit.setPreferredSize(new Dimension(50, 20));
              ButtonListener listener = new ButtonListener();
              submit.addActionListener(listener);
              ButtonGroup bg1 = new ButtonGroup ();
              bg1.add(cb1);bg1.add(cb2);
              gridPanel.add(b1);gridPanel.add(cb1);gridPanel.add(cb2);
              setPreferredSize(new Dimension (200, 200));
              setLayout(new BorderLayout());
              add(titlePanel, BorderLayout.NORTH);
              add(gridPanel, BorderLayout.CENTER);
              add(submit, BorderLayout.SOUTH);
         public class ButtonListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
              if (cb1.isSelected()) {                                   
                   total += 5;                         //total is obtained here
                   order += "Goats' Cheese" + " \n";               //order is obtained here
             else if (cb2.isSelected()) {
                   total += 10;                         //total is obtained here
                   order += "Goats' Cheese" + " \n";                //order is obtained here
            if (e.getSource() == submit)
                JOptionPane.showMessageDialog (null, order  + "\t = $" + total + "\n Please click Payment tab");
         public double getTotal(){               //try to pass the total out
              return total;               
         public String getPizza(){                  //try to pass the order out
              return order;
    //pricePanel class
    import java.awt.*;
    import javax.swing.*;
    public class pricePanel extends JPanel {
         public pricePanel (double total, String order) {           //total and order are passed in
              setPreferredSize(new Dimension (300, 200));
              setBackground (Color.green);
              setLayout(new FlowLayout());
              JLabel l1 = new JLabel ("Please pay the amount: ");     
              JLabel l2 = new JLabel (order + ": \t $" + total);   //total & order don't hold values obtained from
                                        //pircePanel class.
              add(l1);add(l2);
    }

    Please don't double post. This is quite rude. I've a mind to delete my recent post in your other thread.

  • Layout problem in PDF conversion

    Hi all,
    i am downloading spool data using the function module CONVERT_ABAPSPOOLJOB_2_PDF. But i am facing layout problem. e.g. RFBILA00(financial statement generation program) has written balancesheet data to the spool. This spool data has some 6 columns. but CONVERT_ABAPSPOOLJOB_2_PDF is writing only first 3 columns to the generated PDF file. i used 'GET_PRINT_PARAMETERS' function module also with values like layout as 'X_65_132' and 'X_90_120'. but no success. if anybody knows the answer, please let me know.
    Thanks in advance,
    Naveen

    Hi All,
    i am following the below approach to download the information from spool.
    program/spool output is an ALV List output data having 8 columns. but below approach is converting only first 5 columns in to PDF format. other 3 columns are getting truncated.
    FUNCTION /ngl/download_spoolinfo_as_pdf.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(I_SPOOL_REQUEST) LIKE  TSP01-RQIDENT
    *"     REFERENCE(I_FILENAME) LIKE  RLGRAP-FILENAME
    *"  EXCEPTIONS
    *"      DOWNLOAD_ERROR
      TABLES tsp01.
      DATA: mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
            mc_filename LIKE rlgrap-filename.
      DATA: mstr_print_parms LIKE pri_params,
            mc_valid(1) TYPE c,
            mi_bytecount TYPE i.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          copies                 = '1'
          cover_page             = space
          destination            = 'locl'
          expiration             = '1'
          immediately            = space
          mode                   = space
          new_list_id            = 'X'
          no_dialog              = 'X'
          user                   = sy-uname
          line_size              = 200
          line_count             = 65
         layout                 = 'X_65_200'
          layout                 = 'X_90_120'
          sap_cover_page         = 'X'
        IMPORTING
          out_parameters         = mstr_print_parms
          valid                  = mc_valid
        EXCEPTIONS
          archive_info_not_found = 1
          invalid_print_params   = 2
          invalid_archive_params = 3
          OTHERS                 = 4.
      IF sy-subrc EQ 0.
        CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid              = i_spool_request
            no_dialog                = 'X'
            dst_device               = mstr_print_parms-pdest
          IMPORTING
            pdf_bytecount            = mi_bytecount
          TABLES
            pdf                      = mtab_pdf
          EXCEPTIONS
            err_no_abap_spooljob     = 1
            err_no_spooljob          = 2
            err_no_permission        = 3
            err_conv_not_possible    = 4
            err_bad_destdevice       = 5
            user_cancelled           = 6
            err_spoolerror           = 7
            err_temseerror           = 8
            err_btcjob_open_failed   = 9
            err_btcjob_submit_failed = 10
            err_btcjob_close_failed  = 11
            OTHERS                   = 12.
        IF sy-subrc EQ 0.
          mc_filename = i_filename.
          DATA: lv_filename TYPE string.
          lv_filename = i_filename.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              bin_filesize = mi_bytecount
              filename     = lv_filename
              filetype     = 'BIN'
            TABLES
              data_tab     = mtab_pdf
            EXCEPTIONS
              OTHERS       = 22.
          IF sy-subrc EQ 0.
            WRITE:/ mc_filename, 'CONVERTED TO PDF AND DOWNLOADED'.
          ELSE.
            WRITE:/ 'PROBLEM WITH DOWNLOAD'.
            RAISE download_error.
          ENDIF.
        ELSE.
          WRITE:/ 'PROBLEM WITH PDF CONVERSION'.
          RAISE download_error.
        ENDIF.
      ELSE.
        WRITE:/ 'PROBLEM GETTING PRINT PARAMETERS'.
        RAISE download_error.
      ENDIF.
    ENDFUNCTION.

  • Layout problem - multiple repeating frames

    Hi, I have a layout problem, pls help!
    Short report description:
    - Repeating Frame1 - gives 1 record, contains all other frames, variable vertical elasticity
    - - Frame2 - contains all frames beneath - variable vertical elasticity
    - - - Frame3 - variable vertical elasticity
    - - - - some boilerplates
    - - - - Repeating Frame 2 - various number of records, fixed vertical elasticity, height 100
    - - - - Repeating Frame 3 - various number of records, fixed vertical elasticity, height 30
    - - - - .. other repeating frames ..
    When reaching the bottom of a page, and there is not enough room to print a record for Repeating frame 2, a record from Repeating frame 3 is printed in the bottom.
    Next page starts with the remaining records from Repeating frame 2.. and then the remaining records from Repeating frame 3.
    For example:
    Page 1:
    Rep frame 2 - Record 1
    Rep frame 2 - Record 2
    Rep frame 2 - Record 3
    Rep frame 3 - Record 1 -- not enough space to print Record 4, so this record is printed
    Page 2:
    Rep frame 2 - Record 4
    Rep frame 2 - Record 5
    Rep frame 3 - Record 2
    How can i ensure that all records from Rep frame 2 is printed before records from Rep frame 3?

    Hi, thanks for helping me out!
    I tried to use anchors, but they had no effect when connecting top of 3 to bottom of 2, got the same layout.
    I then tried to create frames with vertical elasticity expand around both rep frame 2 and rep frame 3, and it seems to do the job.
    - Repeating Frame1 - gives 1 record, contains all other frames, variable vertical elasticity
    - - Frame2 - contains all frames beneath - variable vertical elasticity
    - - - Frame3 - variable vertical elasticity
    - - - - some boilerplates
    - - - - Frame 4 - vertical elasticity expand
    - - - - - - Repeating Frame 2 - various number of records, fixed vertical elasticity, height 100
    - - - - Frame 5 - vertical elasticity expand
    - - - - - - Repeating Frame 3 - various number of records, fixed vertical elasticity, height 30
    and so on..
    Thanks again

  • Layout Problem in swings

    I have an Layout problem. My Applications consists of a label and a panel in which some more labels are present.
    The panel should contain the scrollbar in order to view all the label that excced the size of the panel.This label and a panel should be adjacent to each other.
    My problem is, I am not getting the scroll bar to the panel when I am adding the label that excced the size of the panel, when I am adding the label adjacent to this label.

    Did you use JScrollPanel? If not, use it.

  • [solved] layout problem in amarok 2.02

    Hi,
    Here, I have a bad layout problem with amarok 2.02. Amarok does not fit on my screen which is 1400 pixels large! I cannot reduce the part where the collection is shown. So that it is really unpractical to use.
    I uploaded a snapshot to illustrate the problem (it is the full screen!):
    emmanuelfavrenicolin.free.fr/Public/Sna … ok202.jpeg
    Someone have the same problem ?
    I tried to install svn version but I stopped after 3 hours of compilation, it is quite a big application.
    Last edited by manouchk (2009-05-23 06:28:43)

    Well, I tried amarok2-devel 2.0.90-1 but the problem of graphic layout remains similar, no improvement. Is it normall? Maybe amarok is only available for computer with screen >= 1600x1200  or is there an hidden configuration file where I could tweek this?
    Last edited by manouchk (2009-05-18 02:41:03)

  • Urgent: Layout problem in "light inner page"

    Hi Experts,
    I am facing a problem in portal content area on external facing portal. I see a vertical scroll bar which restricts application from being displayed on entire screen.
    I am getting this problem after a patching of EP 7.0, before patching every thing was running fine.
    To me it looks like a layout problem in "light inner page", When I use "Light - 1: column (Full width)" layout I get a vertical scroll bar on portal. When I use default layout then this vertical scroll bar disappears but I see an empty navigation bar on left side which is not required.
    Can some one advise a solution for this.
    -Lave

    hi,
    Similar problem in this thread. check it out
    Desktop inner page lost
    Regardss,
    Ganesh N

  • Div layout problem

    Hi - stuck on what I think should be a fairly basic layout problem:
    I have 2 divs, equal widths but varying heights, one floated to the left and one to the right so that they appear next to eachother on the page.  The one on the left contains varying amounts of text, the one on the right contains a flash player so never varies.
    Where the text for the left div is long, I want it to start off next to the player, but then flow beneath it rather than continuing downwards at the same width as the div.  If I remove the width of the left div, so that it reverts to the container width, the player div positions itself below it, so I can't work out how to get the effect.
    Can anyone help?

    Hi,
    hope I understood in the right way: I used (translated from German DW) "modify table" and so I got one more row and two columns in your Main_Content. In one of the new columns I copied the image and beneath I took the text (you now can replace with image and text of your choice), like this:
    If that's not a help for your question, please ask me again.
    What concerns the width of the pictures, I would format them with PS or a similar program in the same wide.
    Hans-G.

  • Design/Layout Problem in OOTB SP "Docs I'm following" page

    Hello
    The "Docs I'm following" My Sites page in SP 2013 has the following layout problem:
    Long document titles overlap with other elements (see also screenshot).
    Note: This is default SP, i.e. we have not deployed any custom branding.
    I guess this is a problem which can easily be corrected even without having to wait for a SP update. Since I'm not very good with design changes I would be grateful if you could provide
    us with a quick fix, e.g. an updated css file.
    Thanks a lot.
    Best regards
    John

    Hi  ,
    For your issue, you can add the following code into your MySite MasterPage:
    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    $(".ms-contentFollowing-itemTitle a").each(function(i){
    $(this).text(shorten($(this).text(),32));
    function shorten(text,maxLength) {
    var ret = text;
    if (ret.length > maxLength) {
    ret = ret.substr(0,maxLength-3) + "...";
    return ret;
    </script>
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Layout problem with JTabbedPane

    Hi,
    I'm creating a JDialog with a JOptionPane in it which has a JTabbedPane as its ContentPane
    Supposed to look like the pic below. I've put the JOptionPane into a JScrollPane in case the user makes the Dialog too small.
    Problem is that the JTabbedPane stretches to a very large height (way bigger than the dialog height).
    Using setPreferredSIze(..) on the JTabbedPane doesn't help either. If the dialog is made bigger, then the TAbbedPane doesn't stretch, if it is made smaller, the TabbedPane shrinks to the minimum necessary size.
    Any ideas, tips on getting this layout would be appreciated.
    |                                      |/\|
    |  ----- -----                         |--|
    |  |   | |   |                         |  |
    | -----------------------------------  |  |
    | |                                 |  |  |
    | |  2 Tables and several buttons   |  |__|
    | |  on this JTabbedPane using      |  |  |
    | |  GridBagLayout                  |  |__|
    | |                                 |  |  |
    | -----------------------------------  |  |
    |                                      |  |
    |          | OK | | Cancel |           |--|
    |                                      |\/|
    -------------------------------------------

    Check this: http://forum.java.sun.com/thread.jsp?forum=57&thread=293587
    - ananth
    Hi,
    I'm creating a JDialog with a JOptionPane in it which
    has a JTabbedPane as its ContentPane
    Supposed to look like the pic below. I've put the
    JOptionPane into a JScrollPane in case the user makes
    the Dialog too small.
    Problem is that the JTabbedPane stretches to a very
    large height (way bigger than the dialog height).
    Using setPreferredSIze(..) on the JTabbedPane doesn't
    help either. If the dialog is made bigger, then the
    TAbbedPane doesn't stretch, if it is made smaller, the
    TabbedPane shrinks to the minimum necessary size.
    Any ideas, tips on getting this layout would be
    appreciated.
    |                                      |/\|
    |  ----- -----                         |--|
    |  |   | |   |                         |  |
    | -----------------------------------  |  |
    | |                                 |  |  |
    | |  2 Tables and several buttons   |  |__|
    | |  on this JTabbedPane using      |  |  |
    | |  GridBagLayout                  |  |__|
    | |                                 |  |  |
    | -----------------------------------  |  |
    |                                      |  |
    |          | OK | | Cancel |           |--|
    |                                      |\/|

  • Help needed with a layout problem

    I'm trying to build a JTabbedPane where each tab has a grid of buttons. The number of buttons is variable, and I'd like the buttons to flow sort of like with FlowLayout, with four columns. I need all the buttons to be the same size, even across tabs. I tried GridLayout, which doesn't work when I have too few buttons to fill a row. It fails in different ways, depending on how I set things up. If I try to set the layout to GridLayout(0, 4) (four columns), then if one tab has one row and another has two, the buttons on the one-row tab expand vertically to the height of the two-row tab. If I try GridLayout(2,4), then if a tab has only one button, it expands horizontally to the maximum width of any of the tabs. (It also has the further problem that if the maximum number of buttons on any tab is 6, they are placed in a 2x3 array; I'm trying to get them to be 4 buttons on the first row and 2 on the second.)
    I'm hoping there's a standard layout manager that can do the job, but I'm not too familiar with the Swing manager classes. Can I get what I want without writing my own layout manager?
    Thanks,
    Ted Hopp
    [email protected]

    I didn't think it was specifically a Swing question.Well, its either Swing or AWT, people who develop GUIs are the ones who are going to have experience using layout managers.
    but if someone can point the way to how to do this with GridBagLayout, nested containersSince you finished reading the tutorial, what have you tried? You've explained your problems using a single layout manager, so what problems are you having using nested layout managers?
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Gridbag layout problem on a tabbedpane

    I am not sure whether we can do this or not but, I am trying to have a gridbag layout on a TabbedPane object.
    I have a JFrame on which I am adding a TabbedPane object called "t" and on this TabbedPane I am adding a tab called "Insert" which is an object of class "Insert Data". Then, I add the TabbedPane t on the Container cp, which is inside the JFrame.
    In the InsertData Class (a JPanel), I need to have the gridbag layout. With this gridbag layout object, I am trying to place different objects like buttons, at various places, on this JPanel. But nothing moves on this panel.
    In short, please let me know how can I have a gridbag layout on a Tabbedpane.
    The Main Class is as follows:
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    import javax.swing.JTabbedPane;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Main extends JFrame implements ActionListener, ChangeListener{
         Main(){
                   setPreferredSize(new Dimension(1200,600));
                   Container cp = getContentPane();
                   JTabbedPane t = new JTabbedPane();
                   // insert
                   InsertData insertOptions = new InsertData();
                   t.addTab("Insert",insertOptions);
                   cp.add(t);
                   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   pack();
                   setVisible(true);
              @Override
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
              @Override
              public void stateChanged(ChangeEvent arg0) {
                   // TODO Auto-generated method stub
              public static void main(String args[]){
                   new Main();
         }The InsertDataClass is:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class InsertData extends JPanel{
         InsertData(){
              setPreferredSize(new Dimension(1200,600));
              setBackground(Color.blue);
              //setLayout(new GridBagLayout());
              GridBagLayout gb = new GridBagLayout();
              setLayout(gb);
              GridBagConstraints c = new GridBagConstraints();
              //c.insets = new Insets(2, 2, 2, 2);
              //JPanel p1= new JPanel();
              //p1.setPreferredSize(new Dimension(200,200));
              JButton b1 = new JButton("here i am!!!");
              //p1.add(b1);
              //c.fill = GridBagConstraints.HORIZONTAL;
              //c.anchor = GridBagConstraints.WEST;
              c.gridx=0;
              c.gridy=1;
              add(b1,c);
    }

    how can I have a gridbag layout on a Tabbedpane.Huh? You post an example with just one JButton and no weightx / weighty set and you expect others here to be able to see a problem with your layout?
    Also, there's needless, unused code that is just clutter -- like the unimplemented ActionListener and ChaneListener. Recommended reading: [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://mindprod.com/jgloss/sscce.html].
    Finally, I don't see any need whatsoever to extend JFrame and JPanel as you are not introducing any new behavior of either. Always favor composition over inheritance.
    I plugged in some code I had used for someone else's GridBagLayout problems and this will show you that there's no difference in using GridBagLayout in a tabbed pane component or anywhere else.import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import javax.swing.*;
    public class GridBagInTabbedPane {
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new GridBagInTabbedPane().makeUI();
      public void makeUI() {
        Font fontButton = new Font("Arial", Font.BOLD, 10);
        Font fontLabel = new Font("Arial", Font.BOLD, 15);
        JLabel labelEnter = new JLabel("Enter sentences in the text area ");
        labelEnter.setFont(fontLabel);
        JTextArea textArea = new JTextArea();
        textArea.setPreferredSize(new Dimension(630, 280));
        JScrollPane scrollPane = new JScrollPane(textArea);
        scrollPane.setMinimumSize(new Dimension(630, 280));
        JLabel labelDuplicates = new JLabel("Duplicates will appear here");
        labelDuplicates.setMinimumSize(new Dimension(650, 30));
        labelDuplicates.setFont(fontLabel);
        JButton buttonDisplay = new JButton("Display Map");
        buttonDisplay.setFont(fontButton);
        JButton buttonClear = new JButton("Clear");
        buttonClear.setFont(fontButton);
        JPanel panel = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.gridwidth = 2;
        gbc.fill = GridBagConstraints.NONE;
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.insets = new Insets(5, 5, 5, 5);
        gbc.weightx = 0.5;
        panel.add(labelEnter, gbc);
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.weighty = 0.5;
        panel.add(scrollPane, gbc);
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.NONE;
        gbc.weighty = 0.0;
        panel.add(labelDuplicates, gbc);
        gbc.gridy = 3;
        gbc.gridwidth = 1;
        gbc.anchor = GridBagConstraints.EAST;
        panel.add(buttonDisplay, gbc);
        gbc.gridx = 1;
        gbc.anchor = GridBagConstraints.WEST;
        panel.add(buttonClear, gbc);
        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.add(panel);
        JFrame frame = new JFrame();
        frame.add(tabbedPane);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }db

  • JTabbedPane display problems

    Can someone help me with this? I have a JTabbedPane in an applet with two tabs. Lately I have noticed that when I move the mouse pointer around on one tab, some components from the other tab start to show through and I can even click on them, resulting in other components showing through and a jumbled mess. Can anyone help me?
    Here is how I set up the layout in the init method:
    jPanelUI = new MyUIPanel();
    getContentPane().setLayout(new GridLayout(1,1,0,0));
    jPanelUI.setLayout(new GridLayout(1,1,0,0));
    // add look & feel panel to content pane
    getContentPane().add(jPanelUI);
    // add main panel to look & feel panel
    jPanelUI.add(administrationPanel);
    Here is MyUIPanel:
    public class MyUIPanel extends javax.swing.JPanel implements my.data.MyConstants
         public MyUIPanel()
         super();
         UIManager.put("TabbedPane.selected", CONTROL);
         UIManager.put("TableHeader.background", CONTROL);
         UIManager.put("ScrollBar.arrowColor", Color.green);
         UIManager.put("ScrollPane.background", CONTROL);
         UIManager.put("ScrollPane.foreground", CONTROL);
    I add the JTabbedPane to Administration panel like this...
    jTabbedPaneAdministration.setRequestFocusEnabled(false);
    jTabbedPaneAdministration.setOpaque(true);
    add(jTabbedPaneAdministration, new com.symantec.itools.awt.GridBagConstraintsD(0,2,6,10,0.5,0.5,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.BOTH,new Insets(15,20,20,20),0,0));
    jTabbedPaneAdministration.setBackground(new java.awt.Color(204,204,153));
    jTabbedPaneAdministration.setFont(new Font("Dialog", Font.PLAIN, 12));
    I add my two panels to administration panel like this...
    jTabbedPaneAdministration.add(jPanel1);
    jTabbedPaneAdministration.add(jPanel2);
    Any ideas?
    Thanks a bunch

    Found the problem. On the invisible tab, I was setting visibilities, depending on what components the user had permission to see. I assumed that those visibilities would only take effect on the tab that they were on, but instead they showed right through the selected tab. So it wasnt the resizing but your idea made me look to what I was doing with those panels after adding them, and I found it. Enjoy your duke $s
    Thanks

  • Using null Layout - Problems

    Hullo - I've written a little app that, because of the nature of what it does, prettymuch requires the use of null layout. It works well enough, but there are a few points where it does strange things that I don't understand. I haven't been able to find any good docs anywhere for how exactly layout/rendering works. The Swing tutorial, for example, almost completely ignores the topic.
    Basically, I set the layout to null, add my components, use setBounds...but then nothing happens. In order for anything to be visible, I have to call pack() before I call show(). What is pack? What does it do? How can Sun's null layout examples work even though most of them don't use it?
    Second, if I create JFrame of a certain size, and add a component that goes off the bottom of the JFrame (on purpose), then expand the size of the JFrame to reveal the bottom part of that component, it doesn't paint - there's just a grey area. No amount of repaint() pack() or anything will cause it to show. The only way I've found to do it is to make the JFrame larger to begin with, add the component so that it's visible, then resize to the smaller size, which is kind of ugly and clunky.
    I basically do not understand why Swing is doing the things it does; why it paints sometimes and not other times, where it paints, when it paints, where it shows objects, how it packs them, etc. I would be very grateful if someone could englighten me!

    Hullo - I've written a little app that, because of the
    nature of what it does, prettymuch requires the use of
    null layout. It works well enough, but there are a
    few points where it does strange things that I don't
    understand. I haven't been able to find any good docs
    anywhere for how exactly layout/rendering works. The
    Swing tutorial, for example, almost completely ignores
    the topic.
    Basically, I set the layout to null, add my
    components, use setBounds...but then nothing happens.
    In order for anything to be visible, I have to call
    pack() before I call show(). What is pack? What
    does it do? How can Sun's null layout examples work
    even though most of them don't use it?
    Second, if I create JFrame of a certain size, and add
    a component that goes off the bottom of the JFrame (on
    purpose), then expand the size of the JFrame to reveal
    the bottom part of that component, it doesn't paint -
    there's just a grey area. No amount of repaint()
    pack() or anything will cause it to show. The only
    way I've found to do it is to make the JFrame larger
    to begin with, add the component so that it's visible,
    then resize to the smaller size, which is kind of ugly
    and clunky.
    I basically do not understand why Swing is doing the
    things it does; why it paints sometimes and not other
    times, where it paints, when it paints, where it shows
    objects, how it packs them, etc. I would be very
    grateful if someone could englighten me!Okay, I think you should call setVisible(true); instead of pack then show. Pack basically organizes the components so they take up the least amount of room, and then it shrinks the frame to as small as it will go without hiding any components. It think if you call revalidate() instead of repaint(), should solve your problem.
    The other thing to do, is (hehe) make your own components

Maybe you are looking for

  • Problems with local DNS after 10.6.8

    Have a Snow Leopard server that's been running quite well. After (I think) the 10.6.8 update, I've encountered a really weird error regarding dns - the internal DNS doesn't recognize the top level DNS domain (companyname.net), so internally we can't

  • Issue with determing table name runtime

    Hi All, I have a problem in determing the table name during runtime TABLES : ekko. DATA : test TYPE REF TO lcl_test. DATA : itab TYPE STANDARD TABLE OF ekko. IF test IS INITIAL.     CREATE OBJECT test.   ENDIF. test->cmeth( EXPORTING itab1 = itab ).

  • WMV Import/Export Issues (Odd Resulting Video)

    Hello all, I've been plagued with a problem that has had me scratching my head for days now. My scenario is I need to create a number of short slideshows. I've been using PhotoStory 3 to create the basic slideshow, then importing the video from PS to

  • 9i and 10g architecture

    Hi , What is the difference between Oracle 9i and Oracle 10g Architecture?

  • Error when running EP5 iView on EP6

    Hi all.  We have to migrate quickly from EP5 SP3 to EP6 SP9.  We have a number of custom coded iViews which use the deprecated jcoclient methods.  From the Netweaver developers studio we import and export a Java iView thats running fine on our EP5 SP