Box layout

used BOX LAYOUT
I have two panels, one header having two labels
another panel inside scrollpane,
but first panel by default comes to center
so,
i set panelHeader.setAlignmentX(Component.LEFT);
now first panel comes slightly to left side but still not aligned with second panel

JUst Add yout comp[onents on that panel ok
panel2 & panel 3
Panel2 is  the left panel & panel3 is the right panel ok
Dear Bye
import javax.swing.*;
class layout
     BoxLayout box;
     JFrame frame;
     JPanel panel1 , panel2 , panel3;
     layout()
          frame = new JFrame();
          panel1 = new JPanel();
          panel2 = new JPanel();
          Panel3 = new JPanel();
          box = new BoxLayout(panel1,BoxLayout.X_AXIS);     // horizontal Layout   And Y_AXIS For vertical
          frame.getContentPane().add(panel1);
          panel1.setLayout(box);
          panel1.add(panel2);
          panel1.add(panel3);
     public static void main(String ss[])
          layout ll = new layout();
}

Similar Messages

  • IMovie 11 picture box layouts

    Can you alter, or create your own photo box layouts in iMovie 11. If so how, or where can you do this.
    I can't find that option. I don't want to use the canned, preset photo layouts. Any options available?

    It has been happening to me, but it doesn't change the final video itself, if it is previewed in full screen mode, it will sometimes freeze, but to see the scene that freezes, just play it (in fullscreen mode) and click back a few seconds before it freezes and it should play normally.
    You can also bring the mouse over the clip to preview it or:
    Duplicate the whole project
    2. Export it to Quicktime
    Hope this helps

  • Box Layout problems

    Hello,
    I am having difficulty with my box layouts in my form applet.
    I have a JFrame with two panels. The left panel will allow the user to enter some parameters via text boxes, drop down menus, etc for a shape, which will appear on the right panel.
    To arrange the form entry boxes on the left panel, I implemented a box layout. Here is where my trouble lies. I am not sure if I am using them correctly.
    In the left panel, I added a box objectentitled entrySideBox, which has a createVerticalBox() orientation. I further added 7 boxes to this box layout, which had a createHorizontalBox() orientation. I have the form elements within the array of horizontal boxes. In summary, I hoped to create a box layout column with 7 horizontal rows to house the form entry elements.
    Can I do this with the Box Layout? My form elements do not appear to be appearing as expected!
    I have my code below. What is wrong?
    //import the necessary java classes
    import java.awt.*;   //for the awt widgets
    import javax.swing.*;  //for the swing widgets
    import java.awt.event.*;  //for the event handler interfaces
    public class DemoShape extends JFrame
        //declare private data members of the DemoShape class
        //requires seven control buttons
        private JTextField xShapeText, yShapeText, messageText, fontSizeText;
        private JComboBox shapeTypeDrop, shapeColorDrop, fontTypeDrop,fontColorDrop;
        //declare the entry and display panel containers
        private Panel entryPanel;
        private Panel displayPanel;
        //declare public data members of the DemoShape class
        //constructor to initialize private data members
        public DemoShape()
            //call the superclass (JFrame) constructor with the name argument
            //this must be done first (as in C++)
            super("DemoShape Applet");
            //arrays of string to be used later in combo boxes
            //some are used more than once
            String fonts[] = {"Dialog", "Dialog Input", "Monospaced",
                                "Serif", "Sans Serif"};
            String shapes[] = {"Rectangle", "Round", "Oval"};   
            String colors[] = {"Black", "Blue", "Cyan", "Dark Gray",
                                "Gray", "Green", "Light Gray", "Magenta", "Orange",
                                "Pink", "Red", "White", "Yellow"};
            //get the content pane of the class outside
            Container entire = this.getContentPane();
            entire.setLayout(new GridLayout(1,2));
            //create the entry panel and add it to the entire pane
            //this will be 7 rows, 1 column
            //each row will have a panel with the form entry elements
            entryPanel = new Panel(new FlowLayout());
            entire.add(entryPanel);
            //create the display panel and add it to the entire pane
            //this will display the output
            displayPanel = new Panel();
            entire.add(displayPanel);       
            //entry panel code
            //use a box layout to add the boxes in a row fashion on the entryPanel
            Box boxes[] = new Box[7];
            //create a main box for the entry side
            Box entrySideBox = Box.createVerticalBox();
            //iterively create a box layout for each row
            for(int b = 0; b < boxes.length; b++)
            {   boxes[b] = Box.createHorizontalBox();  }
            //add the form elements to the boxes
            //the first row should have the shape label
            JLabel shapeHeader = new JLabel("Enter Shape Parameters:");
            boxes[0].add(shapeHeader);
            //second row should have the shape type and color
            JLabel shapeTypeLabel = new JLabel("Select Shape:");
            boxes[1].add(shapeTypeLabel);
            shapeTypeDrop = new JComboBox(shapes);
            boxes[1].add(shapeTypeDrop);
            JLabel shapeColorLabel = new JLabel("Select Shape Color:");
            boxes[1].add(shapeColorLabel);
            shapeColorDrop = new JComboBox(colors);
            boxes[1].add(shapeColorDrop);
            //third row should have the x and y coords
            JLabel xShapeLabel = new JLabel("Enter X:");
            boxes[2].add(xShapeLabel);
            xShapeText = new JTextField("200", 3);
            boxes[2].add(xShapeText);
            JLabel yShapeLabel = new JLabel("Enter Y:");
            boxes[2].add(yShapeLabel);
            yShapeText = new JTextField("200", 3);
            boxes[2].add(yShapeText);
            //fourth row should have the message label
            JLabel messageHeader = new JLabel("Enter Message Parameters:");
            boxes[3].add(messageHeader);
            //the fifth row should have the message       
            JLabel messageLabel = new JLabel("Enter Message:");
            boxes[4].add(messageLabel);
            messageText = new JTextField(50);
            boxes[4].add(messageText);
            //the sixth row should have the font type and size      
            JLabel fontTypeLabel = new JLabel("Select Font:");
            boxes[5].add(fontTypeLabel);
            fontTypeDrop = new JComboBox(fonts);
            boxes[5].add(fontTypeDrop);
            JLabel fontSizeLabel = new JLabel("Enter Font Size:");
            boxes[5].add(fontSizeLabel);
            fontSizeText = new JTextField("12", 2);
            boxes[5].add(fontSizeText);
            //the seventh row should have font color       
            JLabel fontColorLabel = new JLabel("Select Font Color:");
            boxes[6].add(fontColorLabel);
            fontColorDrop = new JComboBox(colors);
            boxes[6].add(fontColorDrop);
            //add the boxes to the entrySideBox
            for(int e = 0; e < boxes.length; e++)
            {   entrySideBox.add(boxes[e]); }
            //add the entrySideBox to the entry panel
            entryPanel.add(entrySideBox);
            //display panel code
            //debugging
            JLabel test = new JLabel("Display Output Here");
            displayPanel.add(test);      
            //set the size of the entire window and show the entire applet
            this.setSize(800,600);
            this.show();
        }   //end the DemoShape constructor
        //call the main class
        public static void main(String args[])
            //create an instance of the DemoShape class
            DemoShape DemoShapeRun = new DemoShape();
            //add the window listener to the applet
            DemoShapeRun.addWindowListener(
                new WindowAdapter()
                    public void windowClosing(WindowEvent e)
                        System.exit(0);
        }   //end main
    }   //end DemoShape class

    The problem with GridLayout is the form elements sizes
    change relative to the size of the panel. I want the
    form elements to remain in a consistent state.
    Should I quit using the box layout?Ok, try to set the layout of the upper content pane to BorderLayout and place the left panel with your components in the WEST part of it (the panel for the drawings goes to CENTER). I don't know if this will produce the result that you want, but it's an idea.
    You should use a GridLayout for this panel and only
    specify 2 columns (don't specify the number of rowsor
    the number of columns will be ignored, see theclass
    documentation for further details).
    Hope this helps,
    Pierre2 Columns? For what?The first column is for the labels (e.g. "Select Font Color") and the second is for the input component (e.g. textarea).

  • Box layout error

    getting error
    cannot resovle symbol createRigidArea location class Box
    same thing is there in java tutorials pls help me.
    pAnswer.add(Box.createRigidArea(new Dimension(0,5)));

    Here is the code which is working Fine i am working on it It's Tested Ok Injoy dear
    & after Compiling this code u can able to get correct layout Then u have to chack your
    PATH variable ehere u set your java PATH OK Dear Bye
    import javax.swing.*;
    import java.awt.*;
    public class bookdata
         JFrame frame;
         JPanel panel , panel2 , panel3;
         JButton but1,but2,but3,but4,but5,but6;
         Color cc;
         BoxLayout bak;
         ImageIcon icon;
         FlowLayout flo;
         public bookdata()
              icon = new ImageIcon("book/book.jpg");
              frame = new JFrame("Book Database");
              frame.setResizable(false);
              frame.setIconImage(new ImageIcon("book/logo.gif").getImage());
              Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              int x = (d.width - 550)/2;
              int y = (d.height - 500)/2;
              frame.setBounds(x,y,400,300);
         public void main1()
              JLabel label = new JLabel(icon);
              flo = new FlowLayout();
              panel3 = new JPanel();
              but1 = new JButton("NEW BOOK");
              but2 = new JButton("EDIT");
              but3 = new JButton("DELET");
              but4 = new JButton("SHOW");
              but5 = new JButton("LONE");
              but6 = new JButton();
              panel = new JPanel();
              bak = new BoxLayout(panel,BoxLayout.Y_AXIS); // BOX Layout
              panel.setLayout(bak);
              // 1st 220 is for R
              // 2nd 177 is for G
              // 3rd 162 is for B
              // 4th 255 is for Alpha
              cc = new Color(51,51,255);
              panel2 = new JPanel();
              panel2.setLayout(flo);
              panel2.setBackground(cc);
              panel2.add(label);
              JSeparator hh = new JSeparator(SwingConstants.VERTICAL);
              SpringLayout layout = new SpringLayout();
              panel3.setLayout(layout);
              panel3.add(but1);          // pp1
              panel3.add(but2);          // pp2
              panel3.add(but3);          // pp3
              panel3.add(but4);          // pp4
              panel3.add(but5);          // pp5
              panel3.add(hh);
              layout.putConstraint(SpringLayout.WEST, but1, 15,SpringLayout.WEST, panel3);          // pp1
         layout.putConstraint(SpringLayout.NORTH, but1, 25,SpringLayout.NORTH, panel3);
              layout.putConstraint(SpringLayout.WEST, but2, 15,SpringLayout.WEST, panel3);          // pp2
         layout.putConstraint(SpringLayout.NORTH, but2, 55,SpringLayout.NORTH, panel3);
              layout.putConstraint(SpringLayout.WEST, but3, 15,SpringLayout.WEST, panel3);          // pp3
         layout.putConstraint(SpringLayout.NORTH, but3, 85,SpringLayout.NORTH, panel3);
              layout.putConstraint(SpringLayout.WEST, but4, 15,SpringLayout.WEST, panel3);          // pp4
         layout.putConstraint(SpringLayout.NORTH, but4, 115,SpringLayout.NORTH, panel3);
              layout.putConstraint(SpringLayout.WEST, but5, 15,SpringLayout.WEST, panel3);          // pp5
         layout.putConstraint(SpringLayout.NORTH, but5, 145,SpringLayout.NORTH, panel3);
              layout.putConstraint(SpringLayout.WEST, hh, 100,SpringLayout.WEST, panel3);
         layout.putConstraint(SpringLayout.NORTH, hh, 500,SpringLayout.NORTH, panel3);
              frame.getContentPane().add(panel);
              panel.add(panel2);
              panel.add(panel3);
              frame.setSize(600,500);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

  • Box Layout, JTextFields, vertical glue, ect

    How do you make it so that your text field on a graphics page dose not expand when you use Box Layout and maximise it?

    thanks a lot it worked ^_^ my classmates thank you as well

  • Box layout help

    i know how to use a box layout on panels but i am having a problem applying box layout on jframe,
    what i do basicaly is extends jframe first and then in the constructor i put setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
    it gives an error that box layout cant be shared...this method works with all other layouts...
    please help me and please dont tell me to go read the sun online tutorials...

    To speak truely. All the j2se default layout manager will be replaced by the default layoutmanager in NetBeans ---group layout manager.
    I suggest you download a NetBeans IDE and start working with the new layout manager.

  • How to have a box layout on a JDialog, with an image set as background

    Hi,
    I need to have a JDialog in which there is a background image set (I already did this part, but only with the default layout). I further need to add text to the lower part of the JDialog. (For this, I guess I need to have a box layout.). I am not able to do so, because if I do so, I wont be able to set image background to the entire JDialog. Please help me out with how to solve this issue?
    Thanks,
    Joby

    Hi jduprez,
    Thanks for the reply. I checked Rob Camick's blog. It gives a nice way to add an image to a panel (*master panel*) and to use it.
    I still have my problem open. The above solution gives panel that I can add to my JDialog. But on the bottom half of the image (as you said, BorderLayout.South), I need to add another structured set of components using a Border Layout again.!, ie, one more panel with a BorderLayout. So when I add
    this panel, to the master panel containing the image, then the image gets cut off, at that point. I tried using component.setOpaque(false) on my sub-panel, still it does not work. Any idea, how to achieve this...?
    Following is the code I have adapted.
    public class BackgroundPanel extends JPanel
         public static final int SCALED = 0;
         public static final int TILED = 1;
         public static final int ACTUAL = 2;
         private Paint painter;
         private Image image;
         private int style = SCALED;
         private float alignmentX = 0.5f;
         private float alignmentY = 0.5f;
         private boolean isTransparentAdd = true;
         public static void main(String[] args) {
              Image img = getImage("D:/imgs/Snowdrop.jpg");
              BackgroundPanel panel = new BackgroundPanel(img);
              JDialog dlg = new JDialog();
              dlg.setLayout(new BorderLayout());
              dlg.add(panel);
              panel.setTransparentAdd(true);
              Panel nPanel = new Panel();
              nPanel.setLayout(new BorderLayout());
              JLabel label = new JLabel();
              //label.set
              label.setText("<html>HI<br>This is another line<br><br><br><br><br><br><br><br><br><br></html>");
              nPanel.add(label, BorderLayout.NORTH);
              panel.add(nPanel/*label*/,BorderLayout.SOUTH);
              dlg.setSize(600, 500);
              dlg.setVisible(true);
         private static Image getImage(String fileName){
              File file = new File(fileName);
             Image image = null;
             try{
                  image = ImageIO.read(file);     
             catch(IOException ioe){
                  /*JOptionPane.showMessageDialog(dlg, "Error in loading image file",
                            "Error", JOptionPane.ERROR_MESSAGE, null);*/
             return image;
          *  Set image as the background with the SCALED style
         public BackgroundPanel(Image image)
              this(image, SCALED);
          *  Set image as the background with the specified style
         public BackgroundPanel(Image image, int style)
              this(image,style,-1,-1);
          *  Set image as the backround with the specified style and alignment
         public BackgroundPanel(Image image, int style, float alignmentX, float alignmentY)
              setImage( image );
              setStyle( style );
              if (alignmentX  > 0){
                   setImageAlignmentX( alignmentX );     
              if (alignmentY  > 0){
                   setImageAlignmentY( alignmentY );     
              setLayout( new BorderLayout() );
          *  Use the Paint interface to paint a background
         public BackgroundPanel(Paint painter)
              setPaint( painter );
              setLayout( new BorderLayout() );
          *     Set the image used as the background
         public void setImage(Image image)
              this.image = image;
              repaint();
          *     Set the style used to paint the background image
         public void setStyle(int style)
              this.style = style;
              repaint();
          *     Set the Paint object used to paint the background
         public void setPaint(Paint painter)
              this.painter = painter;
              repaint();
          *  Specify the horizontal alignment of the image when using ACTUAL style
         public void setImageAlignmentX(float alignmentX)
              this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
              repaint();
          *  Specify the horizontal alignment of the image when using ACTUAL style
         public void setImageAlignmentY(float alignmentY)
              this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
              repaint();
          *  Override method so we can make the component transparent
         public void add(JComponent component)
              add(component, null);
          *  Override method so we can make the component transparent
         public void add(JComponent component, Object constraints)
              if (isTransparentAdd)
                   makeComponentTransparent(component);
              super.add(component, constraints);
          *  Controls whether components added to this panel should automatically
          *  be made transparent. That is, setOpaque(false) will be invoked.
          *  The default is set to true.
         public void setTransparentAdd(boolean isTransparentAdd)
              this.isTransparentAdd = isTransparentAdd;
          *     Try to make the component transparent.
          *  For components that use renderers, like JTable, you will also need to
          *  change the renderer to be transparent. An easy way to do this it to
          *  set the background of the table to a Color using an alpha value of 0.
         private void makeComponentTransparent(JComponent component)
              component.setOpaque( false );
              if (component instanceof JScrollPane)
                   JScrollPane scrollPane = (JScrollPane)component;
                   JViewport viewport = scrollPane.getViewport();
                   viewport.setOpaque( false );
                   Component c = viewport.getView();
                   if (c instanceof JComponent)
                        ((JComponent)c).setOpaque( false );
          *  Add custom painting
         protected void paintComponent(Graphics g)
              super.paintComponent(g);
              //  Invoke the painter for the background
              if (painter != null)
                   Dimension d = getSize();
                   Graphics2D g2 = (Graphics2D) g;
                   g2.setPaint(painter);
                   g2.fill( new Rectangle(0, 0, d.width, d.height) );
              //  Draw the image
              if (image == null ) return;
              switch (style)
                   case SCALED :
                        drawScaled(g);
                        break;
                   case TILED  :
                        drawTiled(g);
                        break;
                   case ACTUAL :
                        drawActual(g);
                        break;
                   default:
                     drawScaled(g);
          *  Custom painting code for drawing a SCALED image as the background
         private void drawScaled(Graphics g)
              Dimension d = getSize();
              g.drawImage(image, 0, 0, d.width, d.height, null);
          *  Custom painting code for drawing TILED images as the background
         private void drawTiled(Graphics g)
                 Dimension d = getSize();
                 int width = image.getWidth( null );
                 int height = image.getHeight( null );
                 for (int x = 0; x < d.width; x += width)
                      for (int y = 0; y < d.height; y += height)
                           g.drawImage( image, x, y, null, null );
          *  Custom painting code for drawing the ACTUAL image as the background.
          *  The image is positioned in the panel based on the horizontal and
          *  vertical alignments specified.
         private void drawActual(Graphics g)
              Dimension d = getSize();
              Insets insets = getInsets();
              int width = d.width - insets.left - insets.right;
              int height = d.height - insets.top - insets.left;
              float x = (width - image.getWidth(null)) * alignmentX;
              float y = (height - image.getHeight(null)) * alignmentY;
              g.drawImage(image, (int)x + insets.left, (int)y + insets.top, this);
    }Thanks,
    Joby

  • Using box layout?

    Hello,
    I wondered if anyone could advise? In this code I was trying to display a column of buttons each the same size. And next to these buttons, a single button, and textfield.
    Something like:
    Button 1
    Button 2
    Button 3 "some space" SearchButton ////Text field ///
    Button 4
    Button 5
    But when the textfield is displays it becomes the height of the 5 buttons, but the searchbutton did not. Is there any method to change the textfield to the height of the searchButton? Or could anyone possibly demonstrate a different layout manager?
    Thank you
    JButton button1, button2, button3, button4, button5;
    JPanel panel = new JPanel(new GridLayout(0,1));
    panel.add(button1 = new JButton("Button 1"));
    castleGreen.addActionListener(this);
    panel.add(button2 = new JButton("Button 2"));
    runTown.addActionListener(this);
    panel.add(button3 = new JButton("Button 3"));
    highHill.addActionListener(this);
    panel.add(button4 = new JButton("Button 4"));
    luckNow.addActionListener(this);
    panel.add(button5 = new JButton("Button 5"));
    littleHaven.addActionListener(this);
    Box leftCol = Box.createVerticalBox();
    leftCol.add(panel);
    Box rightCol = Box.createHorizontalBox();
    rightCol.add(searchBt = new JButton("Search"));
    searchBt.addActionListener(this);
    rightCol.add(Box.createHorizontalStrut(10));
    rightCol.add(searchTf = new JTextField(20));
    Box topDisplay = Box.createHorizontalBox();
    topDisplay.add(leftCol);
    topDisplay.add(Box.createHorizontalStrut(40));
    topDisplay.add(rightCol);

    Thank you for replying.
    In my version of the code the name shown on the left
    buttons are all differenet sizes. When I built these
    into a vertical box, the buttons were displayed
    uneven. I resolve this by using a panel.By default the system sizes buttons according to the ammount of text in them.
    >
    I wondered to achieve this layout, would be easier to
    use a gridbaglayout?Personally I've gone right off GridBagLayout. It's complicated to use and seems unstable in resizing.
    I've got much more reliable results from BoxLayout.

  • How to center Text Box on Web Page? -- Web dev with Word 2013

    I'm trying to assist a user who wants to use Word 2013 for simple web page development.
    There are many tools but they want to use Word 2013.
    Actually have it working by saving the Word 2013 files as web pages... like index.htm, about.htm, etc.
    The problem is when we use the "Insert" tab in Word to create a "Text Box" or a "Shape" ...
    And align it centered on the page... it looks fine in Word but when we open it with a web browser the "Text Box" or "shape" are no longeer centered.
    We thought we had it fixed by making the "Text Box" Layout Options "In Line with Text" but again... looks fine in Word but not in a web browser.
    The question: How can we get a "Text Box" in Word 2013 to appear centered on a web page?
    thanks for any help.

    Hi:
    For webpage design, I would suggest customized form under develop tab on the Ribbon over insert object directly. I tested from my side, using customized form will lock the object position on the
    page.

  • Cannot save Crystal report layout or view new layout of report

    I am trying to make a change to a system crystal report (cust. recievables detailed aging). I had to make the date feild a little wider, so I edited the "system layout" that came with SAP (in my test DB of course), and I go to add-ins>sap business one>save. I get the following error "current user has no permissions for this operation". I am logged in as a superuser and full perm.
    If I "save-as" and save it to a layout in sap....when I go to open the aging with my newly created layout it freezes and asks for DB logon info to connect to my server from crystal. I do not normally have to do this when I preview my reports in the out of the box layouts. WHat am I doing wrong? I am new to crystal.

    The system will not allow me to export the system crystal report....it is grayed out, and it IS a crystal report. HOwever I can open it in crystal, then save it to my desktop, then from INSIDE of SAP in the report and layout manager I import the crystal report I made the changes to from my desktop into SAP and it saves and imports no problems. However when I go to view the report (and this is only the ones I import), it prompts me with the db login for our server to connect, and it is only with that report, once I enter sa credentials it is fine and shows up from there on in, but not if I log out of SAP and back in...then I have to put in my credentials again. Is this something having to do with the report when I make changes to it? I cant have users entering login info each time they run the new aging details report. Please advise what I may be doing wrong when I make changes to a crystal report. It was a very minor change....just moved a feild width.

  • Box in JApplet?!

    Just a quick question.. I have no problems with using Box Layout in a Java application, but the minute I try to use Box in an applet nothing appears! Can I use Box in JApplets?!
    Thanks :-)

    I found the answer in
    http://www.jguru.com/faq/view.jsp?EID=27423

  • Custom Report layout

    I have a simple question to ask (simple I hope a tleast). In the past, I have been able to use the out of the box layout for most reports. However at my current job, we will be needing some custom layouts done to the report region to show parent child style reports.
    I know that the region is just HTML with some CSS thrown in along with placeholder columns, but am confused as to if I can get the formatting to look like this:
    Name ID # DOB Race Office Location (Parent row of data)
    Appt Loc Appt Date/Time Appt Descript Appt Meet With (Child Row)
    Where there will be a number of child rows per employee. I could do this manually (HTP.p processing), but would prefer to have the pagination and other features the product provides.
    Can any suggest a solution here?
    Thank you,
    Tony Miller
    UTMB/EHN

    Guess I will look at customizing the HTML layout, or doing it via htp.p output. My main goal is getting reports for the users, and it works well with the PDF out option with BI Publisher..
    Thank you,
    Tony Miller
    UTMB/EHN

  • GUI - How do i merge two diffrent layout managers into one tab?

    Hello
    I want to create a cellphone, and when you click a button it will be displayed in a textfield
    the buttons are in a grid layout (4,3) and the textfield is in a border layout (NORTH)
    I have the layouts in two seperate tabs, but how do i merge two diffrent layouts in to one tab ?
    textfield:
    package guitelefon;
    import java.awt.*;
    import javax.swing.*;
    public class BorderPanel extends JPanel
       public BorderPanel()
          setLayout (new BorderLayout());
          setBackground (Color.green);
          JTextField output = new JTextField(5);
          add (output, BorderLayout.NORTH);
    }Buttons:
    package guitelefon;
    import java.awt.*;
    import javax.swing.*;
    public class GridPanel extends JPanel
        public GridPanel()
          setLayout (new GridLayout (4, 3));
          setBackground (Color.green);
          JButton b1 = new JButton ("1");
          JButton b2 = new JButton ("2");
          JButton b3 = new JButton ("3");
          JButton b4 = new JButton ("4");
          JButton b5 = new JButton ("5");
          JButton b6 = new JButton ("6");
          JButton b7 = new JButton ("7");
          JButton b8 = new JButton ("8");
          JButton b9 = new JButton ("9");
          JButton bs = new JButton ("*");
          JButton b0 = new JButton ("0");
          JButton bf = new JButton ("#");
          add (b1);
          add (b2);
          add (b3);
          add (b4);
          add (b5);
          add (b6);
          add (b7);
          add (b8);
          add (b9);
          add (bs);
          add (b0);
          add (bf);
    }driver:
    package guitelefon;
    //  LayoutDemo.java       Java Foundations
    //  Demonstrates the use of flow, border, grid, and box layouts.
    import javax.swing.*;
    public class LayoutDemo
         public static void main (String[] args)
          JFrame frame = new JFrame ("Cellhpone");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          JTabbedPane tp = new JTabbedPane();
          tp.addTab ("Grid", new GridPanel());
          tp.addTab ("Border", new BorderPanel());
          frame.getContentPane().add(tp);
          frame.pack();
          frame.setVisible(true);
    }

    a simple example with compilable code:
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import javax.swing.*;
    public class Main {
      public static void main(String[] args) {
        JFrame frame = new JFrame("Cellhpone");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new FooPanel(), BorderLayout.CENTER);
        panel.add(new BarPanel(), BorderLayout.NORTH);
        frame.getContentPane().add(panel);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    class FooPanel extends JPanel {
      private static final String[][] BTN_STRINGS = {
        {"1", "2", "3"},
        {"4", "5", "6"},
        {"7", "8", "9"},
        {"*", "0", "#"}};
      public FooPanel() {
        setLayout(new GridLayout(BTN_STRINGS.length, BTN_STRINGS[0].length, 5, 5));
        for (int row = 0; row < BTN_STRINGS.length; row++) {
          for (int col = 0; col < BTN_STRINGS[row].length; col++) {
            JButton btn = new JButton(BTN_STRINGS[row][col]);
            add(btn);
    class BarPanel extends JPanel {
      private JTextField field = new JTextField();
      public BarPanel() {
        setLayout(new BorderLayout());
        add(field, BorderLayout.CENTER);
    }Edited by: Encephalopathic on Oct 29, 2009 7:56 AM

  • Flex-box model not correctly implemented in Dreamweaver CS5.5, pleas improve!

    Hi all,
    there is a good introduction to: Flexible Box Layout module
    see: http://www.css3.info/introducing-the-flexible-box-layout-module/
    I tried the same example in my new Version of Dreamweaver CS5.5
    --> surprise: Dreamweaver CS5.5 cannot show in a correct manner a following div:
    <div class="flex_box flex_stretch flex_vertical">
    where css are:
        .flex_box {
                            background: url('./img/box-model.png') no-repeat center center;
                            height: 180px;
                            margin-top: 16px;
                            width: 180px;
                .flex_stretch {
            display: -moz-box;
                            display: -webkit-box;
                            display: box;
            -moz-box-align: stretch;
                            -webkit-box-align: stretch;
            box-align: stretch;
                .flex_vertical {
            -moz-box-orient: vertical;
                            -webkit-box-orient: vertical;
                            box-orient: vertical;
    CS5.5 can only strech in 1 direction, when shown as in a browser (German "ENTWURF").
    In Firefox, sam is ok:
    I need a correct representation of these boxes, when will there be an improvement??????????
    WSteiner

    John,
    I misundrstood you response
    I entered http://localhost in my browser and recieved the following page:
    Asd you can see everything is working. I thought that when you called local host, it went to the www/ directory where I have my sites
    I still don't see a problem with my settings
    Server Folder: C:\TNG813onMowesII\www\
    Web URL: http://localhost/genealogy/
    I hate it when the tool is more trouble than the work.
    Larry Voyer
    Site Creator/Administrator
    http://larryvoyer.com/genealogy/

  • Determine the best width for ListCellRenderer - Multi-column combo box

    Currently, I am having a multi column combo box. In order for the column to align properly during show popup, I use box layout to do so. However, the short coming for box layout is that, the size for each column is fixed. This makes me have a difficulty, when I have a long string to be displayed. The problem is shown through the following screen shoot.
    http://i.imgur.com/4Nfc6.png
    This is because in 2nd column,
    1) All the 3 rows must be in same size so that they are aligned.
    2) But 1st row and 2nd row cell renderer, do not know 3rd row is holding such a long string.
    The code (2 files) to demo this problem is as follow. Is there any way the size of the cell will be adjusted automatically? Yet, all the row will be aligned properly.
    ResultSetCellRenderer.java
    package javaapplication24;
    import java.awt.Color;
    import java.awt.Component;
    import javaapplication24.NewJFrame.ResultType;
    import javax.swing.JList;
    import javax.swing.ListCellRenderer;
    import javax.swing.UIManager;
    * @author yccheok
    public class ResultSetCellRenderer extends javax.swing.JPanel implements ListCellRenderer {
        /** Creates new form ResultSetCellRenderer */
        public ResultSetCellRenderer() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
            jLabel1.setText("jLabel1");
            jLabel1.setMaximumSize(new java.awt.Dimension(88, 14));
            jLabel1.setMinimumSize(new java.awt.Dimension(88, 14));
            jLabel1.setPreferredSize(new java.awt.Dimension(88, 14));
            add(jLabel1);
            jLabel2.setText("jLabel2");
            jLabel2.setMaximumSize(new java.awt.Dimension(100, 14));
            jLabel2.setMinimumSize(new java.awt.Dimension(200, 14));
            jLabel2.setPreferredSize(new java.awt.Dimension(100, 14));
            add(jLabel2);
        }// </editor-fold>
        // Variables declaration - do not modify
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        // End of variables declaration
        // Do not use static, so that our on-the-fly look n feel change will work.
        private final Color cfc  = UIManager.getColor("ComboBox.foreground");
        private final Color cbc  = UIManager.getColor("ComboBox.background");
        private final Color csfc = UIManager.getColor("ComboBox.selectionForeground");
        private final Color csbc = UIManager.getColor("ComboBox.selectionBackground");
        private final Color cdfc = UIManager.getColor("ComboBox.disabledForeground");
        // For Nimbus look n feel.
        private final Color nimbus_csfc;
             Color c = UIManager.getColor("ComboBox:\"ComboBox.renderer\"[Selected].textForeground");
             // Pretty interesting. Applying "c" directly on the component will not
             // work. I have the create a new instance of Color based on "c" to make
             // it works.
             nimbus_csfc = c != null ? new Color(c.getRed(), c.getGreen(), c.getBlue()) : null;
        private final Color nimbus_csbc;
            Color c = UIManager.getColor("ComboBox:\"ComboBox.renderer\"[Selected].background");
             // Pretty interesting. Applying "c" directly on the component will not
             // work. I have the create a new instance of Color based on "c" to make
             // it works.
            nimbus_csbc = c != null ? new Color(c.getRed(), c.getGreen(), c.getBlue()) : null;
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            final Color _csbc = csbc != null ? csbc : nimbus_csbc;
            final Color _csfc = csfc != null ? csfc : nimbus_csfc;
            this.setBackground(isSelected ? _csbc : cbc);
            this.setForeground(isSelected ? _csfc : cfc);
            jLabel1.setBackground(isSelected ? _csbc : cbc);
            jLabel1.setForeground(isSelected ? _csfc : cfc);
            jLabel2.setBackground(isSelected ? _csbc : cbc);
            jLabel2.setForeground(isSelected ? _csfc : cfc);
            final ResultType result = (ResultType)value;
            jLabel1.setText(result.symbol);
            jLabel2.setText(result.name);
            return this;
    NewJFrame.java
    package javaapplication24;
    import java.awt.Container;
    import java.awt.Dimension;
    import javax.swing.JComboBox;
    import javax.swing.JList;
    import javax.swing.JScrollBar;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    import javax.swing.event.PopupMenuEvent;
    import javax.swing.event.PopupMenuListener;
    import javax.swing.plaf.basic.BasicComboPopup;
    * @author yccheok
    public class NewJFrame extends javax.swing.JFrame {
        public static class ResultType {
             * The symbol.
            public final String symbol;
             * The name.
            public final String name;
            public ResultType(String symbol, String name) {
                this.symbol = symbol;
                this.name = name;
            @Override
            public String toString() {
                return symbol;
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
            this.jComboBox1.addPopupMenuListener(this.getPopupMenuListener());
            this.jComboBox1.setRenderer(new ResultSetCellRenderer());
            this.jComboBox1.addItem(new ResultType("Number 1", "Normal"));
            this.jComboBox1.addItem(new ResultType("Number 2", "Normal"));
            this.jComboBox1.addItem(new ResultType("Number 3", "A VERY VERY VERY VERY long text"));
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            jComboBox1 = new javax.swing.JComboBox();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
            jComboBox1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox1ActionPerformed(evt);
            getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 110, -1));
            pack();
        }// </editor-fold>
        private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    final NewJFrame frame = new NewJFrame();
                    frame.setVisible(true);
        private PopupMenuListener getPopupMenuListener() {
            return new PopupMenuListener() {
                @Override
                public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    // We will have a much wider drop down list.
                    adjustPopupWidth(jComboBox1);
                @Override
                public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                @Override
                public void popupMenuCanceled(PopupMenuEvent e) {
         * Adjust popup for combo box, so that horizontal scrollbar will not display.
         * Resize JComboBox dropdown doesn't work without customized ListCellRenderer
         * http://www.camick.com/java/source/BoundsPopupMenuListener.java
         * @param comboBox The combo box
        public static void adjustPopupWidth(JComboBox comboBox) {
            if (comboBox.getItemCount() == 0) return;
            Object comp = comboBox.getAccessibleContext().getAccessibleChild(0);
            if (!(comp instanceof BasicComboPopup)) {
                return;
            BasicComboPopup popup = (BasicComboPopup)comp;
            JList list = popup.getList();
            JScrollPane scrollPane = getScrollPane(popup);
            // Just to be paranoid enough.
            if (list == null || scrollPane == null) {
                return;
            //  Determine the maximimum width to use:
            //  a) determine the popup preferred width
            //  b) ensure width is not less than the scroll pane width
            int popupWidth = list.getPreferredSize().width
                            + 5  // make sure horizontal scrollbar doesn't appear
                            + getScrollBarWidth(popup, scrollPane);
            Dimension scrollPaneSize = scrollPane.getPreferredSize();
            popupWidth = Math.max(popupWidth, scrollPaneSize.width);
            //  Adjust the width
            scrollPaneSize.width = popupWidth;
            scrollPane.setPreferredSize(scrollPaneSize);
            scrollPane.setMaximumSize(scrollPaneSize);
         *  I can't find any property on the scrollBar to determine if it will be
         *  displayed or not so use brute force to determine this.
        private static int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) {
            int scrollBarWidth = 0;
            JComboBox comboBox = (JComboBox)popup.getInvoker();
            if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) {
                JScrollBar vertical = scrollPane.getVerticalScrollBar();
                scrollBarWidth = vertical.getPreferredSize().width;
            return scrollBarWidth;
         *  Get the scroll pane used by the popup so its bounds can be adjusted
        private static JScrollPane getScrollPane(BasicComboPopup popup) {
            JList list = popup.getList();
            Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
            return (JScrollPane)c;
        // Variables declaration - do not modify
        private javax.swing.JComboBox jComboBox1;
        // End of variables declaration
    }Edited by: yccheok on Jan 13, 2011 9:35 AM

    Are these two lines intentionally or is it just a mismatch?
    jLabel2.setMaximumSize(new java.awt.Dimension(100, 14));
    jLabel2.setMinimumSize(new java.awt.Dimension(200, 14));
    2) But 1st row and 2nd row cell renderer, do not know 3rd row is holding such a long string.There is only one cell renderer for all rows, so no need for the rows to know each other.
    To calculate the exact maximum width of column two, you have to check each entry.
    If you can do this BEFORE creating the combo, you could do this in a loop similar to this pseudo code
    FontMetrics fm= jComboBox1.getFontMetrics(jComboBox1.getFont());
    foreach (column2String) {
      int length= fm.stringWidth(column2String);
      if (length>max) max= length;
    }Now you have a max value to dimension jLabel2 in your renderer.
    If you don't fill your combo in one go, but rather at runtime, you have to check at each
    jComboBox1.addItem(...)
    whether the string for label2 is extending the current max, redefine max, and repaint the combo.
    This second approach I haven't done so far, but that's how I would try.

Maybe you are looking for

  • Access enforcer and User Data Source for HR

    We are on Access Enforcer 5.2 - service pack 2: My problem is that when creating a new request in AE, I able to get a list of all users when I point my User Data Source to either SAP or UME. However when I attempt to create a request whilst pointing

  • Problem in Sales Opportunity to display the all completd activities

    Hi All, We have a scenario. AFTER completing opportunity A (which is shown in sales assistant tab Flagged completed for Activity), we have to create another opportunity B. while creating B, the system should check if it same BP then it should reflect

  • Error in Extraction through RSA3

    Hello, I am trying to extract data from my DataSource through RSA3, but Iam getting Error while Extraction data,. The display log error says"S:RSSDK:300 [DataDirect][SQLServer JDBC Driver]Object has been closed." Regards, Mayank Points -> Thanks

  • Pérdida de portabilidad al añadir seguridad en v7.0.1

    Acabo de actualizarme de Adobe Acrobat 6.0 Professional a 7.0.1 y resulta que al añadir seguridad a los PDF generados para evitar el Copy & Paste, independientemente de la opción de portabilidad (Acrobat Reader 3.0, 5.0, 6.0 o 7.0) que seleccione, ac

  • Z-87 G45 No Sound with Windows 8

    Just built a new computer from scratch.  Z-87-G45 mobo gtx 670 ftw i-5 4670k 8gb ram windows 8 600w psu Its up and running perfectly, except for my audio.  The front panel is connected properly, headpones don't work in the jacks or in the back (green