Help with layout managers

I can't seem to understand layouts. Or maybe it's text components. Anyway, this little JFrame class seems to act really strangely, and I cannot figure out why.
Can anybody tell me how to get pack() to do something sensible with the components in the main JFrame (the one with the statistics is just for reference.)
The rest of this message is Java code (plus maybe a signature)
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.awt.Container;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;
import java.awt.Dimension;
public class MyFrame extends JFrame {
private String str;
private JPanel panel;
private JButton button;
private JTextField textField;
private JTextArea afterStatus;
private JFrame otherFrame;
private Container otherStuff;
public MyFrame(String s) {
     // Create companion frame to hold statistics.
     afterStatus = new JTextArea();
     otherFrame = new JFrame("Stats");
     otherStuff = otherFrame.getContentPane();
     otherStuff.add(afterStatus, BorderLayout.CENTER);
     otherFrame.pack();
     otherFrame.setVisible(true);
str = s;
textField = new JTextField();
     panel = (JPanel)getContentPane();
button = makeAButton();
panel.setPreferredSize(new Dimension(200, 30));
panel.add(button, BorderLayout.WEST);
panel.add(textField, BorderLayout.EAST);
     textField.setText("Something or other; long so you can see it resize");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     myUpdate();
private void myUpdate() {
     afterStatus.setText("Message is now: " + textField.getText() + "\n\n");
     afterStatus.append("textField Status Before Last Pack:\n");
     afterStatus.append("PreferredSize: " + textField.getPreferredSize() + "\n");
     afterStatus.append("Current Size: " + textField.getSize() + "\n\n");
     afterStatus.append("Button Status Before Last Pack:\n");
     afterStatus.append("PreferredSize: " + button.getPreferredSize() + "\n");
     afterStatus.append("Current Size: " + button.getSize() + "\n\n");
pack();
     afterStatus.append("textField Status After Last Pack:\n");
     afterStatus.append("PreferredSize: " + textField.getPreferredSize() + "\n");
     afterStatus.append("Current Size: " + textField.getSize() + "\n\n");
     afterStatus.append("Button Status After Last Pack:\n");
     afterStatus.append("PreferredSize: " + button.getPreferredSize() + "\n");
     afterStatus.append("Current Size: " + button.getSize() + "\n\n");
     afterStatus.append("ContentPane Status After Last Pack:\n");
     afterStatus.append("PreferredSize: " + panel.getPreferredSize() + "\n");
     afterStatus.append("Current Size: " + panel.getSize() + "\n\n");
     otherFrame.pack();
public static void main(String[] args) {
String text = "Hello World";
MyFrame frame = new MyFrame(text);
frame.setVisible(true);
public JButton makeAButton() {
JButton b = new JButton("Push Me!");
     final JPanel thePanel = panel;
     final MyFrame thisFrame = this;
class ButtonListener implements ActionListener {
private int count;
public ButtonListener() {
count = 0;
public void actionPerformed(ActionEvent e) {
++count;
textField.setText("A longer than normalouch " + count);
thePanel.revalidate();
          thisFrame.myUpdate();
ButtonListener blist = new ButtonListener();
b.addActionListener(blist);
return b;
public String getText() {
return str;
}

Swing related questions should be posted in the Swing forum.
Use the "code" tags when posting code, so the code retains its original formatting.
panel.setPreferredSize(new Dimension(200, 30));Remove the above line. If you set the preferred size of the panel, then it doesn't care about the preferred size of its contained components.

Similar Messages

  • Help with Layout

    I've got a simple layout but I need to get it looking more like this picture: http://members.lycos.nl/ghanswebsite/Layout.JPG
    Now I got a simple GridBag. I tried a few other layouts but they got me errors so until now I evaded them .. :-(.
    // Fig. 12.26: GridLayoutDemo.java
    // Demonstrating GridLayout.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    import java.awt.Color.*;
    public class GridLayoutDemo extends JFrame implements ActionListener {
         private boolean toggle = true;
         private Container c;
         private GridLayout grid1;
         private JButton zoek;
         private Connection connection;
         private JTextField vDag, aDatum, vTijd, aTijd, vlucht;
         Statement opdracht = null;
        boolean inAnApplet = true;
        final boolean shouldFill = true;
        final boolean shouldWeightX = true;
         Color myPink1 = new Color(254,224,192);
        private JComboBox vertrek, naar, vdag, vmaand, volwassenen, kinderen, babys;
         // vertrekdag
         private String dag[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18","19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"};
         // vetrekmaand+jaar
         private String maand[] = { "April 2003" , "Mei 2003"};
         // volwassenen
         private String volwassen[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
         // kinderen
         private String kind[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
         // baby's.
         private String baby[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
         //vetrekplaatsen-combobox
         private String vPlaatsen[] = { "Amsterdam", "Rotterdam" };
         private String[] plaats = null;
         // aangeven wat in het combobox van Rotterdam mag staan
         private String raPlaatsen[] = { "Alicante", "Faro" };
         // aangeven wat in het combobox van Amsterdam
         private String aaPlaatsen[] = { "Bacelona", "Antalya", "Arrecife", "Alicante", "Bodrun" };
         //thread-safe gui changing with swingUtilities.invokeLater( Runnable )
         private Runnable run = new Runnable(){
         public void run(){
              getContentPane().invalidate();
              getContentPane().removeAll();
              getContentPane().add(vertrek);
              getContentPane().add(naar = new JComboBox( plaats ));
              getContentPane().add(vdag);
              getContentPane().add(vmaand);
              getContentPane().add(volwassenen);
              getContentPane().add(kinderen);
              getContentPane().add(babys);
              getContentPane().add(zoek);
              getContentPane().add(vDag);
              getContentPane().add(aDatum);
              getContentPane().add(vTijd);
              getContentPane().add(aTijd);
              getContentPane().add(vlucht);
              getContentPane().validate();
       public GridLayoutDemo()
         super( "GridLayout Demo" );
              // The URL specifying the Books database to which
                // this program connects using JDBC to connect to a
                // Microsoft ODBC database.
                String url = "jdbc:odbc:vluchtinformatie";
                // Load the driver to allow connection to the database
                try {
                   Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
                   connection = DriverManager.getConnection( url );
                     opdracht = connection.createStatement();
                catch ( ClassNotFoundException cnfex ) {
                   System.err.println(
                      "Failed to load JDBC/ODBC driver." );
                   cnfex.printStackTrace();
                   System.exit( 1 );  // terminate program
                catch ( SQLException sqlex ) {
                   System.err.println( "Unable to connect" );
                   sqlex.printStackTrace();
                   System.exit( 1 );  // terminate program
        grid1 = new GridLayout( 4, 3, 10, 10 );
         Container c = getContentPane();
         c.setLayout( grid1 );
         setSize(500,200);
         vertrek = new JComboBox(vPlaatsen);
         vertrek.setName("vertrek");
         vertrek.setMaximumRowCount(2);
         vertrek.addActionListener( this );
         c.add(vertrek);
        show();
         vdag = new JComboBox(dag);
         vdag.setName("dag");
         vdag.setMaximumRowCount(5);
         vdag.addActionListener( this );
         c.add(vdag);
         show();
         vmaand = new JComboBox(maand);
         vmaand.setName("maand");
         vmaand.setMaximumRowCount(5);
         vmaand.addActionListener( this );
         c.add(vmaand);
         show();
         volwassenen = new JComboBox(volwassen);
         volwassenen.setName("volwassen");
         volwassenen.setMaximumRowCount(5);
         volwassenen.addActionListener( this );
         c.add(volwassenen);
         show();
         kinderen = new JComboBox(kind);
         kinderen.setName("kind");
         kinderen.setMaximumRowCount(5);
         kinderen.addActionListener( this );
         c.add(kinderen);
         show();
         babys = new JComboBox(baby);
         babys.setName("baby");
         babys.setMaximumRowCount(5);
         babys.addActionListener( this );
         c.add(babys);
         show();
         zoek = new JButton( "Zoek vlucht" );
         zoek.addActionListener( this );
         c.add(zoek);
         show();
         vDag = new JTextField( "Vertrekdatum" );
         c.add(vDag);
         show();
         aDatum = new JTextField( "Aankomstdatum" );
         c.add(aDatum);
         show();
         vTijd = new JTextField( "Vertrektijd" );
         c.add(vTijd);
         show();
         aTijd = new JTextField( "Aankomsttijd" );
         c.add(aTijd);
         show();
         vlucht = new JTextField("Vluchtnummer" );
         c.add(vlucht);
         show();
    public void actionPerformed(ActionEvent e)     {
       Object source = e.getSource();
            if (source instanceof JComboBox)
                 JComboBox combo = (JComboBox) source;
                 if (combo.getName().equals("vertrek"))
                      if (((String) combo.getSelectedItem()).equals(vPlaatsen[0]))
                           plaats = aaPlaatsen;
                           SwingUtilities.invokeLater( run );
                           else if (((String) combo.getSelectedItem()).equals(vPlaatsen[1]))
                                plaats = raPlaatsen;
                                SwingUtilities.invokeLater( run );
       Object source1 = e.getSource();
            if (source1 instanceof JComboBox)
                 JComboBox combo1 = (JComboBox) source1;
                 if (combo1.getName().equals("vertrek"))
                      if (((String) combo1.getSelectedItem()).equals(vPlaatsen[0]))
                        String gebruikersVertrekplaats = "Amsterdam";
                           else if (((String) combo1.getSelectedItem()).equals(vPlaatsen[1]))
                        String gebruikersVertrekplaats = "Rotterdam";
                      try
                        ResultSet gegevens;
                        gegevens = opdracht.executeQuery("SELECT * FROM vluchtinformatie WHERE vertrekplaats LIKE '"+ gebruikersVertrekplaats +"' AND aankomstplaats LIKE '"+gebruikersAankomstplaats+"';");
                   catch (Exception e)
                        e.printStackTrace();
       public static void main( String args[] )
                      try {
                            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
                     catch (Exception e) { }
          GridLayoutDemo app = new GridLayoutDemo();
          app.addWindowListener(
             new WindowAdapter() {
                public void windowClosing( WindowEvent e )
                   System.exit( 0 );
    }

    When asking about layout (or any question about how a site works or looks), give us a link to the site. Read the Forum FAQ about it and the reasons why.
    I will say that a quick look indicates that you have gone overboard with Divs--66 of them (!). And most serve no purpose. The point of a Div is to hold a bunch of stuff to make it easy to control them. Divs with only one item in them make no sense. And divs
    that are always paired should be combined into one div (if they are even necessary at all).
    Why isn't this one div? These 3 always appear exactly like this:
     <div class="category">
         <div class="categoryheader">
           <h3>Services</h3>
         </div>
         <div class="categorycontent">
    A horse walks into a bar. The bartender asks "Why the long face?"
    "Because I was born into servitude and when I die my hooves will be used to make glue."
    It was at this point that the bartender realized he would not be getting a tip.

  • Confusing behaviour with layout managers.

    It appears that this page has become my favorite web page, having in mind all the
    questions I come up with.
    In the following page:
    http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html
    a code example is given on how to use a null layout manager. If I use exactly the
    same code, but instead of adding the pane into a frame, I add it into yet another
    JPanel with for example FlowLayout, then the pane with the null layout manager
    gets size 0...it just becomes a pixel in the panel it was added. I am not able to
    fix this even if I in a hard-wired manner try to set the size of the internal pane.
    Can somebody explain to me why the top level pane appears to completely ignore
    the bounds and sizes set by the pane with the null layout manager? This confuses
    me a lot :-/

    hi there
    did you...
    1)set the bounds of each of the components contained by your jpanel?
    2)then set the size of the jpanel?
    if yes then did you:
    3)call pack() on your jframe?
    4)[before calling setVisible(true) on same jframe?
    regards
    lutha                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help with layout of photo thumbnails

    Is there anyway to change the layout of the thumbnails on photo pages created in iWeb? I know how to change the distance between photos, how many rows, etc., but is there a way to change the display? Perhaps a larger photo with tiny thumbnails beside that? I don't like how all the thumbnails are displayed on the page, and then you have to hit "play slideshow" to view them. Many thanks in advance.

    The only way that I know of to increase the size of the thumbnails is to reduce the number of columns and the spacing between them. The largest thumbnail is obtained by 1 column. If you double click on a thumbnail you will bring up a larger version of the photo with a thumbnail tray of the others on the top llike in this example. You don't have to enter the slideshow mode.
    There are other methods of presenting photos. These demo pages have examples of them:
    SimpleViewer and Flash Album Exporter
    Flash Album Exporter Postcard and AutoViewer Slideshow Themes
    Custom iPhoto Album
    OT

  • Using multiple guides to help with layout

    Hi,
    I have seen in lots of Muse and InDesign training videos that the designers are using multi guides which run vertically. The guides are set with a wider gap, then a narrow gap, then a wider gap etc. I know this to aid layout and create a more uniform spacing.
    Can anyone tell me the method used to create the guides and how the gaps (wide and narrow) are calculated.
    Thanks,
    Matt

    In the new site dialog box on the upper right side. The wide ones are the columns and the narrow are the gutters. Hope this helps

  • Issue with adding JPanel objects with layout managers

    Hi. The games I made in the past did not contain any customized menus (ie. not from JOptionPane) different components dividing the display screen... so I thought I would try to on my current game I'm working on. So here's the issue: I'm trying to set the GUI up for the game screen.. but when I try to add in additional JPanel objects into the my main JFrame object, all of the JPanel objects stack up at the very top left corner (their not supposed to because I am using a layout manager). Here's my simplified version of the code:
    public void setUpGame(){
         MainGame game = new MainGame();
         game.setLayout(new BoxLayout(game, BoxLayout.Y_AXIS) );
            playPanel = new PlayPanel(); // don't worry about this.. it's a subclass of JPanel.
         playPanel.setPreferredSize( new Dimension(playPanel.width, playPanel.height) );     
            game.add(playPanel);
            JPanel collections = new JPanel();
            collections.setLayout(new FlowLayout() );
            collections.setPreferredSize( new Dimension( 1280, 256));
            miniMapPanel = new MiniMapPanel(); // subclass of JPanel.
         miniMapPanel.setPreferredSize( new Dimension(miniMapPanel.width, miniMapPanel.height) );
            collections.add(miniMapPanel);
            statsPanel = new StatsPanel();
         statsPanel.setPreferredSize( new Dimension(statsPanel.width , statsPanel.height ) );
            collections.add(statsPanel);
            ... // I do the same thing for StatsPanel and CommandPanel objects
            game.add(collections);
            add(game);
            // referencing to the JFrame object
            this.pack();
            setVisible(true);
            setFocusable(true);
    }Notes:
    -The sum of miniMapPanel.width, statsPanel.width, ... , commandPanel.width add up to 1280 pixels.
    - miniMapPanel.height, statsPanel.height, ... , commandPanel.height all have the same height of 256 pixels.
    - What I'm trying to do is set up a GUI very similar to that of StarCraft, and WarCraft.
    - The game is set up in full screen.
    When I compile the program, I see (and I've tested for it) that all of the JPanel objects that were created are all stacked one on top of each other, in the top left corner of the screen. Any ideas and/or suggestions are welcome.

    Hi weng,
    Try the following code example. I think the issue might be in your overridden methods if you did.
        public static void main(String[] args) {
            JPanel viewPanel = new JPanel();
            viewPanel.setBackground(Color.GREEN);
            viewPanel.add(new JLabel("You see a hut here..."));
            JPanel minimapPanel = new JPanel();
            minimapPanel.setBackground(Color.WHITE);
            minimapPanel.add(new JLabel("Minimap!"));
            JPanel commandPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
            commandPanel.add(new JButton("Characters"));
            commandPanel.add(new JButton("Inventory"));
            commandPanel.add(new JButton("World Map"));
            commandPanel.add(new JButton("Menu"));
            JPanel lifeAndManaPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
            lifeAndManaPanel.add(new JLabel("Life: 999/999"));
            lifeAndManaPanel.add(new JLabel("Mana: 999/999"));
            JPanel statusPanel = new JPanel(new BorderLayout());
            statusPanel.add(commandPanel, BorderLayout.PAGE_START);
            statusPanel.add(lifeAndManaPanel, BorderLayout.CENTER);
            JPanel bottomPanel = new JPanel(new BorderLayout());
            bottomPanel.add(minimapPanel, BorderLayout.LINE_START);
            bottomPanel.add(statusPanel, BorderLayout.CENTER);
            JPanel game = new JPanel(new BorderLayout());
            game.add(viewPanel, BorderLayout.CENTER);
            game.add(bottomPanel, BorderLayout.PAGE_END);
            JFrame frame = new JFrame();
            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(game, BorderLayout.CENTER);
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setSize(800, 600);
            frame.setVisible(true);
        }

  • Help with layout buttons and loops

    Hey,
    I am using mainstage for the first time for my band. We have a bunch of loops that we want to play in the background when i hit each corresponding button on my M-Audio keyboard, but i do not see an option to set a button to do that within Mainstage. Is there any way to set this up? I cant open up logic and press play and pause in the middle of a set.
    Thanks

    Have you tried creating an EXS instrument with the loops? You have to do this in Logic then open it on a channel strip in Mainstage.

  • Please help with layout

    I've tried everything I know. Here's the test page:
    http://tmpsg.servers121.com/~fivemr00/html/test.html
    Can't make the page cell lengthen and follow the content
    (notice the text).
    Any suggestions would be great.

    romeo the 3rd wrote:
    > I've tried everything I know. Here's the test page:
    >
    >
    http://tmpsg.servers121.com/~fivemr00/html/test.html
    >
    > Can't make the page cell lengthen and follow the content
    (notice the text).
    > Any suggestions would be great.
    Only had a quick look and only tested in FF - but try this...
    In your embedded styles remove the min-height and height
    attributes from
    your style7 class. In your emx_nav_left stylesheet remove
    the 100%
    height attribute from the pagecell div.
    That *might* be a *start*
    HTH
    chin chin
    Sinclair

  • Need help with using graphics in swing components

    Hi. I'm new to Java and trying to learn it while also developing an application for class this semester. I've been following online tutorials for about 2 months now, though, and so I'm not sure my question counts as a "new to Java" question any more as the code is quite long.
    Here is the basic problem. I started coding the application as a basic awt Applet (starting at "Hello World") and about a month in realized that Swing components offer better buttons, panels, layouts, etc. So I converted the application, called BsfAp, to a new JApplet and started adding JPanels and JComponents with layout managers. My problem is, none of the buffered graphics run in any kind of JPanel, only the buttons do. I assume the buffered graphics are written straight to the JApplet top level container instead but I'm not entirely sure.
    So as to not inundate the forum with code, the JApplet runs online at:
    http://mason.gmu.edu/~dho2/files/sensor.html
    The source code is also online at:
    http://mason.gmu.edu/~dho2/files/BsfAp.java
    What I would like to do is this - take everything in the GUI left of the tabbed button pane and put it into a JScrollPane so that I can use a larger grid size with map display I can scroll around. The grid size I would like to use is more like 700x1000 pixels, but I only want to display about 400x400 pixels of it at a time in the JScrollPane. Then I could also move this JScrollPane around with layout manager. I think this is possible, but I don't know how to do it.
    I'm sure the code is not organized or optimized appropriately to those of you who use Java every day, but again I'm trying to learn it. ;-)
    Thanks for any help or insight you could provide in this.
    Matt

    Couple of recs:
    * Don't override paint and paint directly on the JApplet. Paint on a JPanel and override paintComponent.
    * The simplest way to display a graphic is to put an image into an ImageIcon and show this in a JLabel. This can then easily go inside of the JScrollPane.
    * You can also create a graphics JPanel that overrides the paintComponent, draw the image in that and show that inside of the JScrollPane.
    * don't call paint() directly. Call repaint if you want the graphic to repaint.
    Here's a trivial example quickly put together:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GradientPaint;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Paint;
    import java.awt.RenderingHints;
    import java.awt.geom.Ellipse2D;
    import java.lang.reflect.InvocationTargetException;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    public class BsfCrap extends JApplet
        private JPanel mainPanel = new JPanel();
        private JScrollPane scrollPane;
        private JPanel graphicsPanel = new JPanel()
            @Override
            protected void paintComponent(Graphics g)
                super.paintComponent(g);
                Graphics2D g2d = (Graphics2D)g;
                RenderingHints rh = new RenderingHints(
                    RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
                g2d.setRenderingHints(rh);
                Paint gPaint = new GradientPaint(0, 0, Color.blue,
                    40, 40, Color.magenta, true);
                g2d.setPaint(gPaint);
                g2d.fill(new Ellipse2D.Double(0, 0, 800, 800));
        public BsfCrap()
            mainPanel.setPreferredSize(new Dimension(400, 400));
            mainPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
            graphicsPanel.setPreferredSize(new Dimension(800, 800));
            graphicsPanel.setBackground(Color.white);
            scrollPane = new JScrollPane(graphicsPanel);
            scrollPane.setPreferredSize(new Dimension(300, 300));
            mainPanel.add(scrollPane);
        public JPanel getMainPanel()
            return mainPanel;
        @Override
        public void init()
            try
                SwingUtilities.invokeAndWait(new Runnable()
                    public void run()
                        setSize(new Dimension(400, 400));
                        getContentPane().add(new BsfCrap().getMainPanel());
            catch (InterruptedException e)
                e.printStackTrace();
            catch (InvocationTargetException e)
                e.printStackTrace();
    }

  • Heavy Fog - Layout Managers and the word "preferred"

    Hello again world.
    While reading the API, the tutorials, and various other documentation dealing with layout managers, I keep coming across the word "preferred" - "preferred size", "preferred width", "preferred height", and so on.
    However, I can't seem to visualize just what "preferred" means in this context.
    Do they pre-suppose that one has used the setPreferredSize() method?
    And if no set*Size() method is used, how does the parent container size its components? The literature just comes back to "preferred" this and that.
    This whole "preferred" business is, to me, circular and confusing, and the more I read, the foggier things get.
    Anyone out there with a fresh breeze?
    Thank you one and all.
    Ciao for now.

    You should never use setSize(). The size of a component is set by the LayoutManager as the components in the container are layed out. For example say you are using a GridLayout and you have 3 buttons: following text:
    small = new JButton("small");
    medium = new JButton("medium sized");
    large = new JButton("the largest button");
    The preferred size of each button is calculated to be:
    a) the size of the text +
    b) the border +
    c) the margin
    When components are added to the GridLayout all components are made the same size. The preferredSize does not change, but the size of each button is set the the largest preferredSize of the three buttons before it is painted. The GridLayout ignores the preferredSize of individual components and only cares about the largest component.
    On the other hand the FlowLayout repects the preferredSize of each component when they are layed out and painted. When using a FlowLayout you can set the preferredSize of each component to be the same by doing the following:
    small.setPreferredSize( large.getPreferredSize() );
    medium.setPreferredSize( large.getPreferredSize() );
    Every LayoutManager has rules it follows with respect to preferredSize, minimumSize and maximumSize. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Using Layout Managers.

  • I need help with the https class please.

    Hello, i need add an authentication field in my GET request using HTTPS to authenticate users. I put the authentication field using the setRequestProperty method, but it doesn't appear when i print all properties using the getRequestProperties method. I wrote the following code:
    try{
    URL url = new URL ("https://my_url..");
    URLConnection conexion;
    conexion = url.openConnection();
    conexion.setRequestProperty("Authorization",my_urlEncoder_string);
    conexion.setRequestProperty("Host",my_loginServer);
    HttpsURLConnection httpsConexion = (HttpsURLConnection) conexion;
    httpsConexion.setRequestMethod("GET");
    System.out.println("All properties\r\n: " + httpsConexion.getRequestProperties());
    }catch ....
    when i run the program it show the following text:
    All properties: {Host=[my_loginServer]}
    Only the Host field is added to my HttpsURLConnection. The authentication field doesnt appear in standar output. How can i add to my HttpsURLConnection an Authentication field?
    thanks

    I have moved this to the main Dreamweaver forum, as the other forum is intended to deal with the Getting Started video tutorial.
    The best way to get help with layout problems is to upload the files to a website and post the URL in the forum. Someone can then look at the code, and identify the problem. Judging from your description, it sounds as though the Document window is narrow, which would result in the final menu tab dropping down to the next row. Try turning on Live view or previewing the page in a browser. Design view gives only an approximate idea of the final layout. Live view renders the page as it should look in a browser.

  • I need help with the navigation menu please?

    I have been working my way through your six part printed instructions and I am styling the header and navigation menu.  The bullet points disappeared which was correct and the tabs moved to the right, as they should, but one tab sits underneath another tab and all tabs are covered up by my main heading.  This is dreamweaver CS6.
    It looks a bit of a mess!

    I have moved this to the main Dreamweaver forum, as the other forum is intended to deal with the Getting Started video tutorial.
    The best way to get help with layout problems is to upload the files to a website and post the URL in the forum. Someone can then look at the code, and identify the problem. Judging from your description, it sounds as though the Document window is narrow, which would result in the final menu tab dropping down to the next row. Try turning on Live view or previewing the page in a browser. Design view gives only an approximate idea of the final layout. Live view renders the page as it should look in a browser.

  • Help with creating a layout.

    I need help creating a layout for my program, but am having tons of problems. I just an't that good at creating this, and it's been driving me insane.
    Here's the link to how I want it to look like. http://s94182144.onlinehome.us/randomstuff/layout.JPG
    In panel 1... that will be a cartesian plain, so it will pretty much be empty until lines and stuff are drawn in there.
    In panel 2, there will be two drop down menus and a couple of buttons
    In panel 3, there will be a bunch of things, with two buttons on the bottom.... and this section has to be scrollable.
    Any help with the basic layout will be helpful... I can put in the buttons myself. For reference, the whole programs size is 400x800.
    Thanks,
    sachit

    Read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers. You can combine multiple Layout Managers to get the effect your want. By default the content pane uses the BorderLayout, so one approach might be:
    JPanel center = new JPanel(new BorderLayout());
    center.add(panel1, BorderLayout.CENTER);
    center.add(panel2, BorderLayout.SOUTH);
    getContentPane().add(center, BorderLayout.CENTER);
    getContentPane().add(panel3, BorderLayout.EAST);
    It turn you would layout panel1, panel2 and panel3 with the appropriate layout manager. Panel2 could be something like:
    JPanel panel2 = new JPanel( new BorderLayout() );
    panel2.add(comboBox1, BorderLayout.WEST);
    panel2.add(comboBox2, BorderLayout.EAST);
    JPanel bottom = new JPanel();
    bottom.add(button1);
    buttom.add(button2);
    panel.add(bottom, BorderLayout.SOUTH);

  • How to get a specific layout with the available layout managers?

    Hi
    Not done java GUI's (approximately 5 and a half years) for a while (I havn't even touched java for ages until a few months ago), and I am a little embarrased by how much I have forgotten.
    After tring unsuccessfully several times with TableLayouts and GridBagLayouts to produce this [ [http://i32.tinypic.com/fl94kp.png] ] sort of layout, I have decided I am either being incredibly stupid, or It's a rather difficult thing to do.
    (Sorry about the crudeness of the drawing)
    Please can someone point me on the right track as to what combination of layout managers + components I should be using to achive this, or even be super kind and post a code snippet for it.
    Preferably, I would like to use just the default layout manages / components that come with java, which will allow me to continue working on the GUI in netbeans without it complaining, but I'll use external libraries if absolutely nesecarry.
    Thanks
    A completely unrelated side note, but where the heck have all my past posts and dukes gone. :(
    Edited by: DarthCrap on Aug 2, 2010 5:14 PM

    Yes, A BorderLayout did solve my problems. It appears I was being stupid after all. :)
    @Encephalopathic. Using a gridbaglayout does indeed help with the centering issue for the smaller panel on the right. I had just worked that out myself when you posted. I had been reluctant to try the gridbaglayout for that, because it caused me a load of pain when I tried using it for the original problem.
    Thanks

  • Help needed with Layout problem

    Hello everybody
    I need to insert components such as buttons in a JPanel using absolute positioning
    I still cant dot this
    even if I used the method setLocation for the component
    I wanna know if I have to change the default layout for JPanel or whatever
    thanks a lot

    i found this quite useful:
    http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html#border
    dont know if it will specifically help with your absolute positioning problem.

Maybe you are looking for

  • Word 2007 - Save as Pdf gives error - This file is in use by another application or user

    I have MS Office 2007 Small Business. For months I have been using the "Save as PDF/XPS" option to save my word documents as PDF files. All of a sudden, when I click on the publish button within the "save as PDF dialog", I get the error: "This file i

  • Email Submit Question??

    I have an EMAIL Submit button added to my form. When I email it to someone it comes in as something other than a .pdf.....is there a way for me to set it to send it as a .pdf so users can open it & view it instead of viewing the code...I think it is

  • Swirling images on a book page

    I somehow got an image to move in a circle and I can't figure out how to replicate it so I can swivel other images to sit at an angle as well. Anyone know how. I check to entire manual and came up with no answer.

  • Sound bitrate not the same. Audio sync problem. Clip not segmenting.

    Hi. I used FCP to edit various wedding videos. I have never had problems edditing my own videos in NTSC dv or hd. Somone asked me to edit their tapes wich have been recorded in PAL ( european) format. I don't know what amera or format they used but w

  • Dimension members were not deleted after refresh in Planning desktop

    Hi A Planning application's outline was restored from backup. It contains some dimension members which were deleted from Planning Web some weeks before and there were made many Planning refreshes after. Full database refresh had been made in Planning