JScrollPane bars to arbitrary size?

panel.add( scrollPane, BorderLayout.CENTER );
In my app, my panel has no components added to it besides the scrollpane above, BUT the public void paint(..) has painted a huge graphic of 8000 pixels horizontally..
How do you set the horizontal bar of the scroll pane to be 8000 pixels?
Thanks.

http://forum.java.sun.com/thread.jsp?forum=1&thread=1968

Similar Messages

  • Menu and tool bar text font sizes?

    Is there any way to change the menu and tool bar text font sizes?

    If you are talking with refernce to photoshop elements then let me tell  you there is no option in PSE to change "Menu and tool bar text font " sizes. This option exists in Photoshop in  Edit>Preferences>Interface."
    Thanks,
    27Prac

  • JScrollPane content changes preferred size; how to show the bars

    Before I have to delve deeply into the code of JScrollPane... I have a component inside a JScrollPane with as-needed scrollbars that changes its preferred size. I can invalidate and repaint every component in the tree, but the scrollbars don't show until I do a hide and reshow the window. Why?

    if you are happy with an answer - even your own self-muttering <g> please mark the question as answered.
    Cheers
    Jeanette

  • JScrollPane bars problem Help!!!

    There is some problem with my JScrollPane
    I have added components to the JScrollPane but when components exceeds thee size of the JScrollPane the bars of the JScrollPane are not appearing. Please somebody help me... Just drag the JFrame and increase and decrease its size you will understand my problem. i cant see the remaining components because of no scroll bar.
    Here is a working code...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.*;
    public class test2 extends JFrame implements ActionListener
         JPanel mypanes = new JPanel();     
         //Main Heading 1
         JPanel p1 = new JPanel();     
         JLabel l1 = new JLabel("MEDICINE INFORMATION");
         //Medicine General Information
         JPanel genpane = new JPanel();
         JLabel genl1 = new JLabel("General Information ");     
                   //MGI (1)
                   JPanel genpane1 = new JPanel();
                   JLabel nam = new JLabel("Name:");
                   JTextField gentf1 = new JTextField(14);               
                   JLabel genname = new JLabel("Name:");
                   JTextField gen1tf1 = new JTextField(14);
                   //MGI (2)
                   JPanel genpane2 = new JPanel();
                   JLabel genname1 = new JLabel("Generic Name:");
                   JTextField gen2tf2 = new JTextField(14);
                   //MGI (3)
                   JPanel genpane3 = new JPanel();
                   JLabel genname2 = new JLabel("Manufacturers Name:");
                   JTextField gen3tf3 = new JTextField(14);
                   //MGI (4)
                   JPanel genpane4 = new JPanel();
                   JLabel genname3 = new JLabel("Classification:");
                   JTextField gen4tf4 = new JTextField(14);
                   //MGI (6)
                   JPanel genpane5 = new JPanel();
                   JLabel genname4 = new JLabel("Prescription Required:");
                   JComboBox gen5tf5 = new JComboBox();
                   //Medicine Detailed Information
                   JPanel detpane = new JPanel();
                   JPanel detp2 = new JPanel();
                   JLabel detl1 = new JLabel("Detailed Information");
                   //MDI (1)
                   JPanel detpane1 = new JPanel();
                   //MDI (2)
                   JPanel detpane2 = new JPanel();
                   JLabel detl3 = new JLabel("Common Uses:");
                   //MDI (3)
                   JPanel detpane3 = new JPanel();
                   JTextArea dettf2 = new JTextArea(8,68);
         public test2(String title)
              super(title);
              //Main Heading Panel
              p1.setLayout(new GridLayout(3,3));
              p1.setBackground(Color.white);
              p1.add(new JLabel(""));                    
              p1.add(new JLabel(""));                    
              p1.add(new JLabel(""));                              
              p1.add(new JLabel(""));                    
              l1.setFont(new Font("avant garde bk bt",Font.BOLD,20));
              p1.add(l1);          
              p1.add(new JLabel(""));
              p1.add(new JLabel(""));                    
              p1.add(new JLabel(""));                    
              p1.add(new JLabel(""));     
                   //General Information
              genpane.setLayout(new GridLayout(10,1));
              genl1.setFont(new Font("TimesNewRoman",Font.PLAIN,20));
              genpane.add(genl1);
                   //MGI (1)
                   genpane1.setBackground(Color.white);
                   genpane1.setLayout(new GridLayout(1,5));
                   genpane1.add(new JLabel(""));
                   genpane1.add(new JLabel(""));
                   genpane1.add(new JLabel(""));               
                   genpane1.add(new JLabel(""));     
                   genpane1.add(new JLabel(""));     
                   //MGI (2)
                   genpane2.setBackground(Color.white);
                   genpane2.setLayout(new GridLayout(1,5));
                   genpane2.add(nam);
                   genpane2.add(gentf1);
                   genpane2.add(new JLabel(""));
                   genpane2.add(new JLabel(""));
                   genpane2.add(new JLabel(""));
                   //MGI (3)     
                   genpane3.setBackground(Color.white);
                   genpane3.setLayout(new GridLayout(1,5));
                   genpane3.add(genname1);
                   genpane3.add(gen2tf2);
                   genpane3.add(new JLabel(""));
                   genpane3.add(new JLabel(""));
                   genpane3.add(new JLabel(""));
                   //MGI (4)     
                   genpane4.setBackground(Color.white);
                   genpane4.setLayout(new GridLayout(1,5));
                   genpane4.add(genname2);
                   genpane4.add(gen3tf3);
                   genpane4.add(new JLabel(""));
                   genpane4.add(new JLabel(""));
                   genpane4.add(new JLabel(""));
                   //MGI (5)
                   genpane5.setBackground(Color.white);
                   genpane5.setLayout(new GridLayout(1,5));
                   genpane5.add(genname4);
                   genpane5.add(gen5tf5);
                   genpane5.add(new JLabel(""));
                   genpane5.add(new JLabel(""));
                   genpane5.add(new JLabel(""));               
                   //Medicine Detailed Information               
                   detpane.setLayout(new GridLayout(1,1));
                   detl1.setFont(new Font("TimesNewRoman",Font.PLAIN,20));
                   detpane.add(detl1);                         
                   //MDI(1)
                   detpane1.setBackground(Color.white);
                   detpane1.setLayout(new GridLayout(1,5));
                   detpane1.add(new JLabel(""));
                   detpane1.add(new JLabel(""));
                   detpane1.add(new JLabel(""));
                   detpane1.add(new JLabel(""));
                   detpane1.add(new JLabel(""));
                   //MDI(2)
                   detpane2.setBackground(Color.white);
                   detpane2.setLayout(new GridLayout(1,1));               
                   detpane2.add(detl3);
                   //MDI(3)
                   detpane3.setLayout(new GridLayout(1,1));
                   detpane3.add(dettf2);
                   //Adding Heading 2
                   detp2.setBackground(Color.white);
                   detp2.setLayout(new GridLayout(1,1));     
                   detp2.add(new JLabel(""));               
                   //Adding Panels to the Main JPanel i-e genpane
                   genpane.add(genpane1);
                   genpane.add(genpane2);
                   genpane.add(genpane3);
                   genpane.add(genpane4);
                   genpane.add(genpane5);
                   genpane.add(detp2);
                   genpane.add(detpane);
                   genpane.add(detpane1);                                        
                   genpane.add(detpane2);
                   gen5tf5.addItem("Yes");
                   gen5tf5.addItem("No");                    
                   JScrollPane spp = new JScrollPane(genpane);
                   spp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                   spp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
         mypanes.setBackground(Color.white);
         mypanes.add(p1);
         mypanes.add(spp);
         setContentPane(mypanes);
         public void actionPerformed(ActionEvent ae)
         public static void main(String args[])
              test2 t = new test2("Title");
              t.setSize(800,300);
              t.setVisible(true);

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

  • JScrollPane bar alignment

    I posted this to ProjectSwing forum and never got a reply, maybe here someone knows...
    I tried all the suggested methods, and yet I still get the vertical scroll bar aligned somewhere in the middle when the JFrame opens, when top alignment would be preferable... Any suggestion on this is more than welcome. My code is structured with nested components like this:
    JScrollPane scroll
    ---JPanel allJPanels
    ------JPanel a
    ---------JPanel a_1
    ---------JLabel a_2
    ---------JEditorPane a_3
    ------JPanel b
    ---------JPanel b_1
    ---------JLabel b_2
    ---------JEditorPane b_3
    scroll.setViewportView( allJPanels );
    Methods attempted:
    scroll.getVerticalScrollBar().setValue( scroll.getVerticalScrollBar().getMinimum() );
    OR
    scroll.getViewport().setViewPosition( new java.awt.Point( 0, 0 ) );
    OR
    scroll.getVerticalScrollBar().getModel().setValue( 0 );
    OR
    allJPanels.scrollRectToVisible( new java.awt.Rectangle( 1, 1, allJPanels.getWidth(), allJPanels.getHeight() ) );
    Thanks for any suggestion

    Strangely the problem was due to how this JFrame was initialised in another JFrame with the usual .pack() and .setVisible(). By implementing Runnable and initialising with new Thread and .start() in the main application JFrame the scroll bar seemed to obey its settings and aligned correctly to the top.

  • Update JScrollBar Extent when JScrollPane Component Changes Preferred Size

    Hi folks,
    I have an interesting, but concise problem that I've been working on for a few days but haven't had any luck.
    In Java 1.5 or Java6, I have a JScrollPane which contains a JPanel. The settings of the scrollbar (for example, the Extent [the width of the "thumb" or "slider" on the scrollbar]) are determined based on the dimension of the underlying contained component, in particular, the Preferred Size.
    My problem is this. The underlying component has a "zoom" capability, such that the actual size of the component can and does change (i.e., zooming out reduces its preferred size).
    Happily, the consequence of this design is that the "size" or extent of the scrollbar sliders/thumbs adjusts to give visual indication of the proportion of the current view (ViewPort View dimension) to the underlying component's dimension.
    The problem is, the scrollbar sliders do NOT automatically update their size in response to programatically changing the JScrollPane's contained component's PreferredSize. They WILL be updated if I RESIZE the parent JFrame manually.
    But for the life of me, I can't get those sliders to update programatically. I've tried repaint(), update, validate(), etc. on the JScrollPane but no luck.
    I've done a debug to get into the stack trace of the Sun code during run time, and there's a lot going on... there's a doLayout(), a reshape() (deprecated), firing various property changes, but I just can't seem to find a good hook into getting the scrollbar to update its internal Bounds model and repaint accordingly. Calling setBounds() on the JScrollPane I think would trigger it, however, looking at the code.. it seems to ignore firing property events and repainting of the bounds themselves didn't actually change (i.e. no action happens if the current dimension and specified dimension in the argument to setBounds() are the same).
    Any ideas here on how to this to get those sliders to update programatically with a new value for the extent?
    Thanks,
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Understood! It was my intention to give credit and now I'm happy to do so! I've now assigned the Duke Points. Minor usability issue, it was not obvious how to do this the first time (and I did poke around a little before I gave up earlier in the day, reverting to just assigning him the correct question). I've got it now though! Thanks again--definitely knocked out an issue I was having today and allowed me to move on to add'l development work today.
    All the best!
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • JScrollPane bars do not show

    Hi,
    I add the Panel that contains a large image to a scroll pane. However, the image is large, and the scroll bars do not show.
        JScrollPane ScrollPaneScroller = new JScrollPane();
        this.getContentPane().add(ScrollPaneScroller, BorderLayout.CENTER);
        ScrollPaneScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        ScrollPaneScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        ScrollPaneScroller.getViewport().add(PanelwithImage, null);
        PanelwithImage.setCenter(this.getWidth(), this.getHeight());Also, how to display the center of the image?

    Aw h&#101;ll...
    import java.awt.Dimension;
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class BigDukeImage {
      public static final String IMAGE_PATH = "http://"
          + "duke.kenai.com/nyanya/NyaNya.jpg";
      private static final Dimension SCROLLPANE_SIZE = new Dimension(900, 700);
      private static void createAndShowUI() {
        Image image = null;
        try {
          URL url = new URL(IMAGE_PATH);
          image = ImageIO.read(url);
          JLabel label = new JLabel(new ImageIcon(image));
          JScrollPane scrollpane = new JScrollPane(label);
          scrollpane.setPreferredSize(SCROLLPANE_SIZE);
          JFrame frame = new JFrame("Big Duke Image");
          frame.getContentPane().add(scrollpane);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
          JScrollBar vertSBar = scrollpane.getVerticalScrollBar();
          JScrollBar horzSBar = scrollpane.getHorizontalScrollBar();
          vertSBar.setValue(
              (vertSBar.getMaximum() - vertSBar.getVisibleAmount()) / 2);
          horzSBar.setValue(
              (horzSBar.getMaximum() - horzSBar.getVisibleAmount()) / 2);
        } catch (IOException e) {
          e.printStackTrace();
      public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
            createAndShowUI();
    }

  • When I put Pages in fullscreen my bar with fonts, size, and format disappears

    in old pages, in fullscreen i could scroll my mouse up and i would get the fonts, size, and formant, etc. bar. but now it just disapeares?  
                                                                     |
                                                                     |
                                                                    V

    Are other apps working fine in full screen? Just Pages?
    It is working for me, so perhaps a restart to see if that helps?
    But like many, I am sticking with the old Pages for now.

  • Possible to replace jscrollpane bar with something else?

    hi,
    is it possible to change the scrollbar in a jscrollpane? i wanted to replace it with an image, is this possible? i just want to change it's look, i've see some skins but not exactly what i wanted, and i'm not sure how to make my own skin. if it's possible can someone tell me how, or point me to a place that shows how to create look and feel skins for java applications?
    Thank you.

    In JScrollPane, the calls setHorizontalScrollBar(JScrollBar horizontalScrollBar) and setVerticalScrollBar(JScrollBar verticalScrollBar) take a JScrollBar as a parameter. This means it would be much easier to use an object that extended JScrollBar.
    Here's a search of the forums for "extends jscrollbar"
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2B%22extends+jscrollbar%22&col=javaforums

  • Accordion trigger to be arbitrary size and location

    It woud be really nice if the trigger and content area could be disconnected and not necessary of the same size.  Thanks!

    Thanks, I figured it out :o)

  • Numbers 09 error bar size

    I'm new to numbers and am trying to customise error bars on my graphs.
    Is it possible to create error bars of different sizes within a graph? I am using the "standard error" setting but all of the error bars are the same size regardless of sample size.
    Can I select each stack in the graph and create an error bar based on its standard error?
    Thanks in advance

    For custom error bars, you can choose "custom" and select the error data from your table.

  • Removing JScrollPane column header

    Hi
    I have created a JScrollPane containg a table.
    JTable d_pointDataTable;
    JScrollPane pointDataPane;
    d_pointDataTable = new JTable(15,15);
    d_pointDataPane      = new JScrollPane(d_pointDataTable);
    But my scroll pane appears with a column header as A,B, C, etc.
    How can I remove the same. Besides no matter how much I set the JTable to be , my Jscrollpane takes some default size. How do I set the size of the JScrollPane ?
    Regards,
    Anand

    Hi,
    The setTableHeader(null) removes the table header. But somehow I am not getting the horizontal scroll bar. It is only the vertical scroll bar that appears. How can i get both the horizontal and vertical scroll bar considering that my table is larger than the view port size?
    Regards,
    Anand

  • Help - trouble applying JScrollPane

    Hello all,
    With the code following my question I have trouble getting a scrollbar. What I get is a frame with an iteration of radiobuttons and a label (exactly what I want), but the iteration drops out of my frame without a functional scrollbar (the scrollbar drops out of the frame too). Could anyone help me out?
    BTW tempData is a Hashtable filled with Objects.
    final JFrame venster = new JFrame("yada");
    venster.getContentPane().setLayout(new BorderLayout());
    venster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel p4 = new JPanel();
    p4.setLayout(new GridLayout(0, 2, 50, 5));
    JScrollPane bar = new JScrollPane(p4);
    int counter = 0;
    final String [] namen = new String[tempData.size()];
    final JRadioButton [] r1 = new JRadioButton[tempData.size()];
    final JRadioButton [] r2 = new JRadioButton[tempData.size()];
    final JRadioButton [] r3 = new JRadioButton[tempData.size()];
    final JPanel [] panels = new JPanel[tempData.size()];
    final JLabel [] vnaam = new JLabel[tempData.size()];
    for(int i = 0; i < tempData.size();i++) {
    r1[i] = new JRadioButton();
    r2[i] = new JRadioButton();
    r3[i] = new JRadioButton();
    panels[i] = new JPanel();
    for(Enumeration enu = tempData.keys(); enu.hasMoreElements();) {
    namen[counter] = ((String)enu.nextElement());
    Vak v = ((Vak)tempData.get(namen[counter]));
    vnaam[counter] = new JLabel(v.getNaam());
    ButtonGroup b = new ButtonGroup();
    r1[counter].setSelected(true);
    b.add(r1[counter]);
    b.add(r2[counter]);
    b.add(r3[counter]);
    panels[counter].add(r1[counter]);
    panels[counter].add(r2[counter]);
    panels[counter].add(r3[counter]);
    p4.add(panels[counter]);
    p4.add(vnaam[counter]);
    counter++;     
    venster.getContentPane().add(bar, BorderLayout.NORTH);
    venster.pack();
    venster.setSize(900,600);
    venster.show();

    How to use scroll panes

  • JScrollPane setting its viewport view is jerky. WHY?

    Hello,
    I have a JScrollPane with containing a JPanel. Often, this JPanel changes significantly and I need to replace this with another one. When I do this, and I then call myJScrollPane.setViewPortView(myJPanel): I find that this is quite jerky - and you can see the painting taking place from the top left of the panel, and then the JScrollPane's scrollbars are automatically moved to round abouts where they were last (this happens quickly but is noticable and annoying).
    Does anyone know why this is? .. and how I could go about removing this jerky paint?
    Please help me, as you'd be doing me so much by it.
    sincerely, Edward.

    Thanks for the good suggestion and reading. My hope is to retain the JEditorPane as the "text area" may hold more than just text in the future.
    I'll plead ignorance and admit that I don't know what Component(s) widen when the JInternalFrame is elongated horizontally and then contracted. There were no characters added to the end of any line, so the Document itself should be the same as it was before. But, the horizontal scroll bar is not; it seems to be fixing its size to something besides the Document.
    Seeking to understand what Component(s) elongated, and how to have the horizontal scroll bar fix its size to the horizontal width of the Document instead of the elongated Component(s).
    Thanks! -Brett

  • Is there a way to make the Toolbar Icons small size?

    There is an option in almost every app to make the tool bar icons small size. My suppress is this is not the case with AP3.
    Hard to believe.
    Zuowen

    zwzhang wrote:
    There is an option in almost every app to make the tool bar icons small size. My suppress is this is not the case with AP3.
    nope.
    all versions prior to a3 had it but for some reason they removed this option with aperture 3.
    victor

Maybe you are looking for

  • Purchased app does not appear in my list of Purchased Apps

    I have a receipt for the purchase of a Mac App via iTunes, but it doesn't appear in my list of purchased applications. How can I get a copy of the purchased application?A

  • How do you reset your Macbook to factory setting?

    WOndering how to reset my Macbook.

  • Iphone and Windows Live Gallery error code when trying to edit

    Most of my photo's come from my iPhone 4gs.  Fairly resently i haven't been able to edit photos in Windows Live Gallery.  Especially Rotating pictures.  I get an error code "file location" - Error code: (0x80070057)

  • Question about abstract class

    Hi, I am doing some junit tests with given class. However, i cannot touch the original class(or even create any new class). All i can do is to create JUnit test class This class is abstract and has only one public void method. Also, this class is ext

  • MAC OSX Snow Leopard

    1. Have installed CS4 Master Collection about a year ago, had no problems. 2. Upgraded to Snow Leopard 3  After a while, having problems : Illustrator and After effect quit at start-up. 4. Tried to un-install, run the cleaner script, re-install : sam