ScrollPane, only vertically

Hello,
I have as ScrollPane with a JPanel inside it. The JPane inside has flow layout and I add some components in there. At the moment all the components end up in one long row. I'd like them not to expand the JPane horizontally, when they reach the border, to start going down and eventually creating a vertical scroll bar, but not a horizontal one. Is that possible? How?
Thanks.

You can use BoxLayout for the main JPanel:
myJPanel.setLayout(new BoxLayout(myJPanel, BoxLayout.PAGE_AXIS));And then if you need some elements going horizontal, have inner JPanels that use FlowLayout. There's a lot of ways to solve this problem.
Edited by: Encephalopathic on Feb 11, 2008 3:01 PM

Similar Messages

  • Building folio with only Vertical view

    Hi experts
    I am trying to build folio file for Adobe content viewer iPad. I have no problem with iPad Horizontal and Vertical version. It works fine.
    Now my problem is I need to view or build a folio with only Vertical version ignore Horizontal version. This is possible?
    thanks in advance

    Hi Prabhjyot Kaur
    Thank you! This helps

  • Show scrollpane only when table has x rows

    Is there any way to not make use of scrollpane when a table currently has less that 5 rows ?
    I have my table embedded in a JScrollPane, but I want to show the scrollpane only if my table has atleast
    'x' number of rows.
    Thanks,

    Something like...
    DefaultTableModel tm = new DefaultTableModel(data, index);
    int size = tm.getRowCount();
    JTable t = new JTable(tm);
    JPanel p = new JPanel();
    if(size > 5)
      JScrollPane jsp = new JScrollPane(t);
      p.add(jsp);
    else
      p.add(t);
    // add p to JFrame

  • Making a JFrame only Vertically Resizable

    How can i make a JFrame vertically resizable but ONLY vertically? This seems to be a hard thing to find information on. I would appreciate any help.

    Well, ideally, i dont want the user to be able to click the side of the window and drag to the right at all, i want the curser to be stuck at the border of the window when resizing but still be able to stretch the bottom. I dont want the window to stretch and then stretch back horizontally, it seems poorly programmed. If somebody knows a "correct" way to do this, it would be nice to know. Thanks for your help.

  • HT4972 How can I zoom the web page only vertically or horizontally ,i.e.,wThen I want to read the web page can I enlarge the page so that the font only increases size ?

    How can I zoom the web page only vertically or horizontally ,i.e.,wThen I want to read the web page can I enlarge the page so that the font only increases size ?

    You can't.  (Fonts increase in size like everything else, not in height alone).

  • I downloaded the Buzz Player HD TWICE from the apple store on my ipad 3, but any of the videos it contais doesnt rotate. i mean, they all play only vertical (any other app rotates fine). Why?

    The Buzz Player HD  on my ipad new, which i bought from the official app store, plays its content, but cant rotate the videos. it plays them only vertically, no rotation ata ll as it normally does with any other app or content. I deleted the app as well as its content and i downoaded again (with no charge) and the same content again, but in vain. i shot a short video with the ipad's camera and this video rotates!!! i contacted the buzz player's site, but no response! Any help, please???

    Before running movie clip
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%202/965f7abe70887a7e0a0 a20b60104ef30.jpg
    After running movie clip
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%202/245fbbf7d2e1e272e44 0f6f7d84a9c40.jpg

  • ScrollPane only adds 1 Checkbox :(

    this is my code
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import java.applet.Applet;
    public class TodSource extends Frame
              implements ActionListener, WindowListener, ItemListener{
         private TextField enter;
         private TextArea contents;
         Button bViewSource;
         Button bEdit;
         Button bList;
         Panel Panel1, Panel2, Panel3, Panel4;
         GridBagLayout gbLayout;
         GridBagConstraints gbConstraints;
         Label info, info2, info3;
         CheckboxGroup urls;
         Checkbox url[] = new Checkbox[10];
         Scrollbar scrollHeight;
         ScrollPane ScrollingPanel = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
         Image icon;
         public static void main(String args[]){
         new TodSource();
         public TodSource(){
              super("TodSource - Beta v0.2");
              gbLayout = new GridBagLayout();
              gbConstraints = new GridBagConstraints();     
              setLayout(new BorderLayout());
              Panel1 = new Panel();
              Panel2 = new Panel();
              Panel3 = new Panel();
              Panel4 = new Panel();
              enter = new TextField("Click \'EDIT URL\' button to enter URL");
              bEdit = new Button("Edit URL");
              bList = new Button("List Files");
              bViewSource = new Button("View Source");
              contents = new TextArea("", 0, 0, TextArea.SCROLLBARS_VERTICAL_ONLY);
              Panel1.setLayout(gbLayout);
              info = new Label("", Label.CENTER);
              info2 = new Label("", Label.CENTER);
              Panel1.add( addComponent(info, 1, 1, 0, 1, 1, 0) );
              Panel1.add( addComponent(enter, 2, 2, 3, 1, 1, 0) );     
              Panel1.add( addComponent(bEdit, 2, 5, 1, 1, 0, 0) );
              Panel1.add( addComponent(bList, 2, 6, 1, 1, 0, 0) );
              Panel1.add( addComponent(info2, 3, 1, 0, 1, 1, 0) );          
              add(Panel1, BorderLayout.NORTH);
              info3 = new Label("", Label.CENTER);
              Panel2.setLayout(new BorderLayout());
              urls = new CheckboxGroup();
              url[0] = new Checkbox("http://localhost/index2.html", urls, false);
              url[0].addItemListener(this);
              url[1] = new Checkbox("http://localhost/index3.html", urls, false);
              url[1].addItemListener(this);
              url[2] = new Checkbox("http://localhost/javaprogs.html", urls, false);
              url[2].addItemListener(this);
              url[3] = new Checkbox("http://localhost/error.html", urls, false);
              url[3].addItemListener(this);
              url[4] = new Checkbox("http://localhost/error2.html", urls, false);
              url[4].addItemListener(this);
              url[5] = new Checkbox("http://localhost/error3.html", urls, false);
              url[5].addItemListener(this);                                                  
              url[6] = new Checkbox("http://localhost/error4.html", urls, false);
              url[6].addItemListener(this);
              url[7] = new Checkbox("http://localhost/error5.html", urls, false);
              url[7].addItemListener(this);
              ScrollingPanel.add( url[0] );     
              ScrollingPanel.add( url[1] );     
              ScrollingPanel.add( url[2] );     
              ScrollingPanel.add( url[3] );     
              ScrollingPanel.add( url[4] );     
              ScrollingPanel.add( url[5] );     
              ScrollingPanel.add( url[6] );     
              ScrollingPanel.add( url[7] );     
              Panel2.add(ScrollingPanel,BorderLayout.CENTER);
              Panel4.setLayout(new BorderLayout());
              Toolkit tkit=Toolkit.getDefaultToolkit();
              icon = tkit.getImage(ClassLoader.getSystemClassLoader().getResource("q2.jpg"));
              add( Panel2, BorderLayout.CENTER );     
              Panel3.add(bViewSource, BorderLayout.NORTH);
              add( Panel3, BorderLayout.SOUTH );
    //rest of code ..............
    seems like my ScrollPane only displays the last link
         ScrollingPanel.add( url[7] );
    why doesn't it display links before that?

    hm i changed the code to this
    Panel2.setLayout(new BorderLayout());
              Panel2.add(Panel4,BorderLayout.CENTER);
              Panel4.setLayout(new BorderLayout());
              Panel4.add(ScrollingPanel, BorderLayout.CENTER);
              urls = new CheckboxGroup();
              url[0] = new Checkbox("http://localhost/index2.html", urls, false);
              url[0].addItemListener(this);
              url[1] = new Checkbox("http://localhost/index3.html", urls, false);
              url[1].addItemListener(this);
              url[2] = new Checkbox("http://localhost/javaprogs.html", urls, false);
              url[2].addItemListener(this);
              url[3] = new Checkbox("http://localhost/error.html", urls, false);
              url[3].addItemListener(this);
              url[4] = new Checkbox("http://localhost/error2.html", urls, false);
              url[4].addItemListener(this);
              url[5] = new Checkbox("http://localhost/error3.html", urls, false);
              url[5].addItemListener(this);                                                  
              url[6] = new Checkbox("http://localhost/error4.html", urls, false);
              url[6].addItemListener(this);
              url[7] = new Checkbox("http://localhost/error5.html", urls, false);
              url[7].addItemListener(this);
              //Panel2.add( addComponent(info3,2,0,2,0,1,0 ) );
              ScrollingPanel.add( url[0] );     
              ScrollingPanel.add( url[1] );     
              ScrollingPanel.add( url[2] );     
              ScrollingPanel.add( url[3] );     
              ScrollingPanel.add( url[4] );     
              ScrollingPanel.add( url[5] );     
              ScrollingPanel.add( url[6] );     
              ScrollingPanel.add( url[7] );     
    but it still shows same thing :(

  • Mouse moves only vertically?

    Yikes, I did a pacman -Syu and restarted -> mouse got broken in X11. It works fine in console mode with gpm, but when I start X I can move the pointer sideways for about 0.5 secs and after that only vertical movement is possible. I tried to change in xorg.conf between normal and evdev driver, but neither works... How should I fix this?
    PS. I tried with stock 2.6.24 kernel and with custom 2.6.23, doesn't work.

    brebs wrote:Look in /var/log/pacman.log and show what happened.
    I checked it through it warned about changing xorg input detection to hal based stuff or something. I found this file related to that message:
    <?xml version="1.0" encoding="UTF-8"?>
    <deviceinfo version="0.2">
    <device>
    <!-- FIXME: Support tablets too. -->
    <match key="info.capabilities" contains="input.mouse">
    <merge key="input.x11_driver" type="string">mouse</merge>
    <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
    string="Linux">
    <merge key="input.x11_driver" type="string">evdev</merge>
    </match>
    </match>
    <match key="info.capabilities" contains="input.keys">
    <merge key="input.xkb.rules" type="string">base</merge>
    <!-- If we're using Linux, we use evdev by default (falling back to
    keyboard otherwise). -->
    <merge key="input.x11_driver" type="string">keyboard</merge>
    <merge key="input.xkb.model" type="string">pc105</merge>
    <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
    string="Linux">
    <merge key="input.x11_driver" type="string">evdev</merge>
    <merge key="input.xkb.model" type="string">evdev</merge>
    </match>
    <merge key="input.xkb.layout" type="string">fi</merge>
    <merge key="input.xkb.variant" type="string" />
    </match>
    </device>
    </deviceinfo>
    It seems like changing something from it might solve it...?

  • How can i create a ScrollPane with vertical scrollbar only ?

    As title,
    Thank you very much !

    class MyPanel
       public Dimention getPreferredSize()
          return new Dimention(width, height);
    ScrollPane sc;
    MyPanel pan;
    sc.add(pan);A scrollpane has an outer size, and a client size. The client size (the inside) of a ScrollPane might be bigger than the outside (its magic isnt it?) The client size is adjusted automatically by the ScrollPane to fit the value returned from the client Components getPreferredSize();
    By overriding the client components getPreferredSize(), you adjust the inner size of the Scrollpane. When its inner width is small enough, the horizontal scrollbar will disapear if you use scrollbars as needed policy.

  • I can see photos on my iPhone iOS5 only vertical, how can i see them in orizontal?

    i can see photos on my iPhone iOS5 only in vertical way, how can i see them in orizontal?

    Welcome to the Apple Community.
    Photostream when enabled will only add photos from the camera roll that were taken post photostream activation. (Photostream does not currently share video)

  • Is there a way of choosing ONLY vertical or horizontal?

    Hi,
    Is there a way of choosing only the vertical shots, or horizontal shots?
    Thanks!

    Use the Sort: Aspect Ratio option and all horizontal/vertical images will be grouped.

  • [LaserJet Pro 200 color MFP M276nw] only vertical lines when scanning, scanner broken?

    Hi all! I have a problem with the scanner in my HP all in one. If I scan (using the printer function or apples ImageCapture: same result) the output is just a lot of vertical stripes (in colors when in color mode). Not a trace of the image I try to scan. The lines are there even if i scan an empty white page. I see the stripes both when doing a preview scan and an actual scan. The problems are very similar regardless of if I use the flatbed or the feeder scanner (they are separate scanner hardware, yes?). I have updated to the latest software for the printer/scanner and I am connecting over bonjour via wireless. I am on Os X 10.9.1. Anybody having similar problems or is my scanner just plain broken? Thanks in advance!Jon

    , , I understand that both of you are seeing vertical lines when scanning from your Laserjet M276nw. First, make sure the printer is plugged directly into a wall outlet and not a surge protector. Now, so I know where to begin I'd need to know the following:If you are seeing the vertical lines when you copy as well as scan?Are you seeing the vertical lines when you copy from the flatbed? The document feeder? both?If you are seeing the lines from both the flatbed and the feeder are they in the same place?Once I know this I'll be better able to assist you.

  • After 10.5 most sites display only vertical I know these sites were both

    Most sites are forced to be viewed vertical. 3/4 of my apps will not rotate to the horizontal position. When you fire off an app. It comes up horizontal but quickly forces to verticle.

    iPad 2

  • Mobile App - transform the screen - only vertical view

    Hi,
    here's my problem:
    My mobile application is a game. I wish that the application does not tailor to the position of the phone and was always vertical. Now screen reacts to automatically change (horizontally and vertically) and my app does not look good in landscape view.
    I would like to set that when I turn rotate the phone, view the application does not change.
    It is possible?
    Lilly

    In your -app.xml file you can set <autoOrients> to false.

  • How to make only vertical scrollbar?

    my codes are shown as the following 2 classes:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JScrollPane.*;
    class showConsole2{
    public static void main(String argv[])throws Throwable{
    consoleFrame csf = new consoleFrame();
    csf.show();
    class consoleFrame extends JFrame{
    public consoleFrame()throws Throwable{
    super("Console"); setSize(150, 200);
    JPanel p1, p2, p3, p4, p5, p6, content ;
    p1 = new JPanel(); p2 = new JPanel();
    p3 = new JPanel(); p4 = new JPanel();
    p5 = new JPanel(); p6 = new JPanel();
    content = new JPanel();
    JLabel l1, l2, l3, l4, l5, l6;
    l1 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
    l2 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
    l3 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
    l4 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
    l5 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
    l6 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
    p1.add(l1); p2.add(l2); p3.add(l3);
    p4.add(l4); p5.add(l5); p6.add(l6);
    content.add(p1); content.add(p2); content.add(p3);
    content.add(p4); content.add(p5); content.add(p6);
    setContentPane(content);

    Here is the code :)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JScrollPane.*;
    class showConsole2{
    public static void main(String argv[])throws Throwable{
         consoleFrame csf = new consoleFrame();
         csf.show();
    class consoleFrame extends JFrame{
         public consoleFrame()throws Throwable
              super("Console"); setSize(150, 200);
              JPanel p1, p2, p3, p4, p5, p6,content;
              JScrollPane content1;
              content = new JPanel(new GridLayout(6,1));
              content1 = new JScrollPane(content);
              content1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              content1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
              p1 = new JPanel(); p2 = new JPanel();
              p3 = new JPanel(); p4 = new JPanel();
              p5 = new JPanel(); p6 = new JPanel();
              JLabel l1, l2, l3, l4, l5, l6;
              l1 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
              l2 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
              l3 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
              l4 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
              l5 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
              l6 = new JLabel("aaaaaaaaaaaaaaaaaaaaaaa");
              p1.add(l1); p2.add(l2); p3.add(l3);
              p4.add(l4); p5.add(l5); p6.add(l6);
              content.add(p1); content.add(p2); content.add(p3);
              content.add(p4); content.add(p5); content.add(p6);
              setContentPane(content1);
    }Good Luck

Maybe you are looking for

  • Is there a way to mute seperate tabs, rather than the whole PC? "Cause that would be nifty.

    I couldn't find a suggestion box, or anything relating to this topic. Is there anyway that on the next Firefox update we will be able to mute tabs separately? Since there are games/adds that have no mute options, and can get annoying while listening

  • How to upgrade from 10.1.5 to 10.2?

    Can anyone out there let me know how to upgrade from 10.1.5 to 10.2? I'm trying to use my new digital camera and I need a minimum of 10.2. Please email me with the answer. Thanks!

  • Problem trying to update - email dropping out, apps no longer working

    I have been having big problems ever since this new update 10.2.1.537 appeared. It never has downloaded, and now my emails are all dropping off, I can't open my Facebook posts and most of my apps quit working. How can I fix this???

  • Terms of payment key in INVOIC01 Idoc

    Hi, We are processing inbound INVOIC01 IDOC types to load suppliers invoices in SAP. In the segment E1EDK01, the field ZTERM ( Terms of payment key ) is filled with a valid value. The problem is the invoice is created with blanks in that field, so th

  • Interactive page links not working in Google viewer

    Hello, I created a PDF from InDesign and wanted to embed jumps from page to page. Specifically, they're arrows with text that the viewer can click on to jump from page to page. I tested them in Acrobat Reader and they work. I test emailed myself the