Possible to add scrollPane to entire JFrame?

hi,
I have a frame that consists of couple of images, labels and other stuff. I've set the default size to be small so when the application comes up first..not everything is seen. now the user has to maximize the swing frame in order to see everything. Is there a way I can add scrollPane to my entire JFrame. currently I have scrollPane just for some textAreas which are inside the JFrame.
Also, If I add an image in the ScrollPane..is there way to set the dimensions of the image which is seen by default. Then the user will have to use scrollBar to see more. Currently I have a JLabel, containing an ImageIcon, in a scrollBar but scrollBars are never used because image by default comes in a size where scrollBars aren't required.
Thanks for any help!

1. Put everything on a JPanel, put the JPanel in a JScrollPane and add the JScrollPane to the JFrame. Scrollbars will be active whenever the JPanel is larger than the viewport.
2. Similar situation: if the JPanel on which the JLabel bearing the image is larger than the viewport, scrollbars will be active.
If this doesn't help, please post a SSCCE and tell us what it's not doing that you want it to do.
luck, db
edit And you've been a member long enough to know that Swing questions should be posted to the Swing forum.
{color:0000ff}http://forum.java.sun.com/forum.jspa?forumID=57{color}
Edited by: Darryl.Burke

Similar Messages

  • If I edit an item in a datagrid is it possible to add an effect to that entire row?

    If I edit an item (default ItemRenderer) in a datagrid is it
    possible to add an effect to that entire row?

    If you are using the mail app - Tap and hold down on the attachment icon in the email and that should bring up a window that says Open In. Do you not get that? Then you can select Pages from that window - assuming that you have Pages on the iPad.
    The attachment should open when you tap on it anyway, even if you don't have Pages.

  • IS IT POSSIBLE TO ADD A SCROLL PANE TO A PANEL??

    Hi, Im trying to add a scroll pane to a panel but when I compile the code and try to open the form - a 'Illegal Argument Exception' is produced. Can anyone tell me whether it is possible to add a scroll pane the actual panel itself and also the code to do this.     
    Many Thanks, Karl.
    I have added some sample code I have created -
    public RequestForm(RequestList inC)throws SQLException{
              inRequestList = inC;
              displayForm();
              displayFields();
              displayButtons();
              getContentPane().add(panel);
              setVisible(true);
         public void displayForm() throws SQLException{
              setTitle("Request Form");
              setSize(600,740);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              getContentPane().setLayout(new BorderLayout());
              Border etched = BorderFactory.createEtchedBorder();
              panel = new JPanel();
              panel.setLayout( null );
              //panel.setBackground(new Color(1,90,50));
              Border paneltitled = BorderFactory.createTitledBorder(etched,"");
              panel.setBorder(paneltitled);
              scrollPane1 = new JScrollPane(panel);
              scrollPane1.setBounds(0, 0, 600, 740);
              panel.add(scrollPane1);
    }

    Hi all,
    I am still having trouble here. would it be posible to add a scrollpanel to this form? Can anyone provide me with a working piece of code so I see how it actually works.
    Any help would be greatly appreciated.
    Many Thanks, Karl.
    Code as Follows:
    /* ADMIN HELP Manual*/
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.*;
    public class AdminHelp extends JFrame implements ActionListener{
         private JButton exit;
         private JLabel heading1, help;
         private JPanel panel;
         Font f = new Font("Times New Roman", Font.BOLD, 30);
         private JScrollPane scroll;
         public AdminHelp(){
              setTitle("ADMIN Help Manual");
              setSize(400,325);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              panel = new JPanel();
              panel.setLayout(null);
              exit = new JButton("Close");
              exit.setBounds(280,260,100,20);
              exit.addActionListener(this);
              panel.add(exit);
              exit.setToolTipText("Click here to close and return to the main menu");
              getContentPane().add(panel);
              show();
              public void actionPerformed(ActionEvent event){
              Object source = event.getSource();
                   if (source == exit){
                        dispose();
              public static void main(String[] args){
                   AdminHelp frame = new AdminHelp();
                   frame.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                   System.exit(0);

  • Is it possible to add a JToolBar to JSplitPane?

    When I try to add Jtoolbar to JSplitPane, it gives me the following exception:
    Exception in Thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: cannot add to layout: unknown constraint: null
    Is it not possible to add a JToolBar to a JSplitPane? Is it because I have not defined what is supposed to happen when the user clicks "next" or "previous" yet? What I ultimately want to happen is for something to move up in all the components of the split pane (it's a nested pane) when I hit "next," and to move back when i hit "prev" (buttons in the jtoolbar)

    I believe that you don't want to add the JToolBar to the JSplitPane, but instead you want to add the JToolBar to the Panel that holds the JSplitPane. For eg:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.JToolBar;
    class FuSwing1
        private JPanel mainPanel = new JPanel();
        private JSplitPane splitpane;
        public FuSwing1()
            JToolBar toolbar = new JToolBar();
            toolbar.add(new JButton("foo 1"));
            JPanel redPanel = new JPanel();
            JPanel bluePanel = new JPanel();
            redPanel.setBackground(Color.red);
            bluePanel.setBackground(Color.blue);
            splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, redPanel, bluePanel);
            mainPanel.setPreferredSize(new Dimension(400, 400));
            mainPanel.setLayout(new BorderLayout());
            mainPanel.add(toolbar, BorderLayout.NORTH);
            mainPanel.add(splitpane, BorderLayout.CENTER);
        public JPanel getMainPanel()
            return mainPanel;
        public void setDividerLocation(double loc)
            splitpane.setDividerLocation(loc);
        private static void createAndShowUI()
            FuSwing1 fu1 = new FuSwing1();
            JFrame frame = new JFrame("FuSwing1");
            frame.getContentPane().add(fu1.getMainPanel());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            fu1.setDividerLocation(0.6);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    createAndShowUI();
    }

  • Rotating entire JFrame to simulate portrait mode

    Hi
    I need to rotate the entire jframe into portrait mode.
    I cannot use the graphics chip, or linux graphics device manger to change the rotation CW 90 degress - due to hardware design and limitation.
    So basically, I have to render the graphics myself, quite easily done with fllowing code at the the top level panel.
    protected void paintComponent(Graphics g)
    // center of rotation is center of the panel
    Graphics2D g2d =(Graphics2D)g;
    int xRot = this.getWidth() / 2;
    int yRot = this.getHeight() / 2;
    g2d.rotate(Math.toRadians(-90), xRot, yRot);
    super.paintComponent(g);
    This does the job nicely, however the screen is still using landscape co-ordinates, and hence when clicking on the swing components they are in the pre-rotation position.
    I have looked and cannot find, is there a simple way to switch a jframe into portrait mode. If not, is there a simple way to intercept the screen coordinates and translate the mouse coordinates to the appropriate JComponent?
    thanks in advance
    Steve

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    public class TransformPoints extends JPanel {
        List<PointStore> list = new ArrayList<PointStore>();
        AffineTransform at = new AffineTransform();
        String s = "Hello World";
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            Color color = g2.getColor();
            drawPoints(g2);
            g2.setPaint(color);
            FontRenderContext frc = g2.getFontRenderContext();
            Font font = g2.getFont().deriveFont(36f);
            Graphics2D copy = (Graphics2D)g.create();
            copy.setFont(font);
            LineMetrics lm = font.getLineMetrics(s, frc);
            float height = lm.getAscent() + lm.getDescent();
            float width = (float)font.getStringBounds(s, frc).getWidth();
            int w = getWidth();
            int h = getHeight();
            System.out.printf("w: %d  h: %d%n", w, h);
            float x = (w - width)/2;
            float y = (h - height)/2 + lm.getAscent();
    //        copy.rotate(-Math.PI/2, w/2, h/2);
            at.setToRotation(-Math.PI/2, w/2, h/2);
            copy.transform(at);
            copy.drawString(s, x, y);
            // draw some reference lines
            copy.setPaint(Color.pink);
            copy.draw(getBounds());
            copy.drawLine(w/2, 0, w/2, h);
            copy.drawLine(0, h/2, w, h/2);
            copy.dispose();
        private void drawPoints(Graphics2D g2) {
            for(int i = 0; i < list.size(); i++) {
                PointStore store = list.get(i);
                Point p = store.loc;
                g2.setPaint(Color.blue);
                g2.drawString(store.viewLoc, p.x+3, p.y);
                g2.setPaint(Color.red);
                g2.drawString(store.xformLoc, p.x+3, p.y+12);
                g2.fill(new Ellipse2D.Double(p.x-1.5, p.y-1.5, 4, 4));
        public static void main(String[] args) {
            TransformPoints test = new TransformPoints();
            JFrame f = new JFrame("click me");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(500,300);
            f.setLocation(100,100);
            f.setVisible(true);
            test.addMouseListener(test.ml);
        private MouseListener ml = new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                String viewStr = String.format("[%d, %d]", p.x, p.y);
                Point2D.Double xp = getInvertedPoint(p);
                String xfStr = String.format("[%.1f, %.1f]", xp.x, xp.y);
                list.add(new PointStore(p, viewStr, xfStr));
                repaint();
            private Point2D.Double getInvertedPoint(Point2D p) {
                Point2D.Double xp = new Point2D.Double();
                if(at.getDeterminant() != 0) {
                    try {
                        at.inverseTransform(p, xp);
                    } catch(NoninvertibleTransformException  e) {
                        System.out.println("invert error: " + e.getMessage());
                return xp;
    class PointStore {
        Point loc;
        String viewLoc;
        String xformLoc;
        public PointStore(Point p, String view, String xform) {
            loc = p;
            viewLoc = view;
            xformLoc = xform;
    }

  • Is it possible to add markups to a PDF that I am not the author of

    Most of the PDFs I generate are from other applications (like Autocad) where I "print to PDF" to create the file.   Most of the PDFs I recevie are generated the same way.   Prior to Acrobat Reader 8, it was simple for me and my collueges to exchange information on these PDFs by using markup tools and resending them with markups.   Since Acrobat 8 has come along, I now find it impossible to markup a drawing (no matter if I have created it using Print to PDF or if someone has sent it to me).  I went to the knowledge base and see that the drawing has to be enabled for markup in one of 2 ways
    In an open PDF, choose Comments > Enable For Commenting In Adobe Reader, and then save the PDF.  
    Start the wizard to initiate a shared review or an email-based review and follow the on-screen instructions. When you’re finished, commenting is enabled in the PDF that you specify for the review. 
    Well, there is no Comments selection in my toolbar.   Second method is given by
    Quickstart: Start an email review
    An email-based review lets you track review status and merge received comments into the PDF.
    Click Review & Comment and choose Attach For Email Review.
    If prompted, enter your identity information to create a reviewer profile.
    Follow the on-screen instructions to select the PDF, invite reviewers, and send the email invitation.
      If your email application doesn’t send email automatically, you may need to answer alert messages and switch to your email application to finish sending the message
    But there is no Review & Comment button to click.
    So, can someone tell me, can I still do a simple markup of any PDF?   Even if I have to jump through hoops can I?    I guess I can understand Why Adobe has done away with this feature in their free tool, as they were not getting any revenue off of it, but it greatly diminishes the usefulness of Acrobat Reader and therefore all PDFs for me.
    Thanks in advance for your response.

    To enable this right you need Acrobat, not the free Reader.
    However, starting from Reader X it is possible to add simple markups to any file, unless it has been specifically disallowed by the creator of the file.

  • In contacts there is the possibility to add a new event, as the birthdays, but they do not appear in iCal. Is there any way to make that possible? It is normal to have a person with his birthday, anniversary and others key dates you want to link to him.

    In contacts there is the possibility to add a new event, as the birthdays, but they do not appear in iCal. Is there any way to make that possible? It is normal to have a person with his birthday, anniversary and others key dates you want to link to such person, but the only one shows up is the birthday. How to be able to show all those dates linked to people in the agenda in the iCal?
    Thanks

    Hi,
    I sugggest you try my application, Dates to iCal. It is shareware with a 2 week trial period.
    Dates to iCal 2 is a replacement for Apple's birthday calendar for iCal. It has a range of features to allow the user to choose what, and what not, to sync to iCal from Address Book.
    As well as automatically syncing birthday dates from Address Book, Dates to iCal 2 can sync anniversary and custom dates. It can set up to five alarms for each date in iCal and can also set different alarms for birthdays and anniversaries. It allows the option of only syncing from one Address Book group. This application also allows for the titles of the events sent to iCal to be modified to the user's preference.
    Best wishes
    John M
    As I sell software on my site and ask for donations, the Apple Support Communities Use Agreement requires that I state that I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • Is it possible to add a graphics card to the back of my HP

    Hello  I want to know if it's possible to add a new graphics card to the back of a Laptop not inside of it but on the back of my laptop ???  my graphics Card is a Intel 4000 graphics card is a terrible for gaming TERRIBLE !!!  

    Not sure where it would go on the back, but no the system is closed. There is no place to insert a graphics card or attach it. You will find some hokey stuff on the internet where people say you can plug a video card in the wireless card slot but those are a hoax at worst and at best they do not tell you that such a thing would not even perform as well as what you have and is likely to damage the motherboard. 

  • Is it possible to add a backlit keyboard to an hp envy touchsmart 15

    is it possible to add a backlit keyboard to an hp envy touchsmart 15?

    Daevid.
    Yes you can.
    Your manual here.
    http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB8QFjAA&url=http...
    Page 20 chapter 3.
    REO
    HP Expert Tester "Now testing HP Pavilion 15t i3-4030U Win8.1, 6GB RAM and 750GB HDD"
    Loaner Program”HP Split 13 x2 13r010dx i3-4012Y Win8.1, 4GB RAM and 500GB Hybrid HDD”
    Microsoft Registered Refurbisher
    Registered Microsoft Partner
    Apple Certified Macintosh Technician Certification in progress.

  • Is it possible to add a hdmi port? Hp envy 23-d010ea all-in-one

    I wanted to get a Ps4 soon but i dont have a tv, and on my computer i dont have a hdmi port. i see on other models of my computer they have it for example on the 23-d052 its like this 
    Where as on my one is like this
    so that part is just an empty space. i was wondering if it were possible to add the hdmi port or if there was a way i could still play the ps4 on my computer?
    This question was solved.
    View Solution.

    The USB 3.0 to HDMI adapter referenced above, is only designed to connect to a USB port on you computer and output an HDMI signal to an HDTV or monitor. It will not allow you to connect the HDMI output of a game console to your computer.
    It may be possible to purchase all the components necessary to add that functionality to your computer, however the cost would far exceed the price of a new monitor or HDTV. Please purchase an inexpensive HDTV or monitor to use with your PlayStation.
    If you have any further questions, please don't hesitate to ask.
    Please click the White KUDOS "Thumbs Up" to show your appreciation
    Frank
    {------------ Please click the "White Kudos" Thumbs Up to say THANKS for helping.
    Please click the "Accept As Solution" on my post, if my assistance has solved your issue. ------------V
    This is a user supported forum. I am a volunteer and I don't work for HP.
    HP 15t-j100 (on loan from HP)
    HP 13 Split x2 (on loan from HP)
    HP Slate8 Pro (on loan from HP)
    HP a1632x - Windows 7, 4GB RAM, AMD Radeon HD 6450
    HP p6130y - Windows 7, 8GB RAM, AMD Radeon HD 6450
    HP p6320y - Windows 7, 8GB RAM, NVIDIA GT 240
    HP p7-1026 - Windows 7, 6GB RAM, AMD Radeon HD 6450
    HP p6787c - Windows 7, 8GB RAM, NVIDIA GT 240

  • Is it possible to add a new graphics card to my macbook pro 2011 13"

    Is it possible to add a new graphics card to my macbook pro 2011 13"?

    Hi W,
    Sorry, but no. It's soldered onto the logic board.

  • When creating a custom SearchPlugin, is it possible to add more code such as uppercase conversion of the SearchText and IF statements that change the URL depending on what is typed?

    When creating a custom SearchPlugin, is it possible to add more code such as uppercase conversion of the searchTerms and IF statements that change the URL depending on the searchTerms? Every time I try to add something firefox doesn't want to add it as a search plugin. I need to create a more powerful search tool for personal use.

    I've found some external software applications that will do it, so that leads me to believe its not possible within ID CC.

  • Is it possible to add more than one page at a time in pages - word processing?

    Is it possible to add more than one page at a time in pages - word processing?

    I haven't been able to find a way to add more than one page at a time.  I think you'll have to add them one at a time. 

  • Is it possible to add 16GB (2x8GB) of ram to the stock 8GB (2x4GB)  that is already in the iMac?   A total of 24GB (2x4GB, and 2x8GB)

    Purchasing the new 27" iMac
    Is it possible to add 16GB (2x8GB) of ram to the stock 8GB (2x4GB)  that is already in the iMac?
    A total of 24GB (2x4GB, and 2x8GB)
    upgrading memory on the new iMac 27"3.4GHz Quad-core Intel Core i7,
    8GB 1600MHz DDR3 SDRAM - 2x4GB
    3TB Fusion drive

    You can do it without any problem, but make sure you put the memory horizontally, so you will get the advantages of the Dual Channel. You can buy the memory in OWC or Crucial to make sure you have a compatible memory

  • Is it possible to add value item and non stock item in one billing?

    Is it possible to add value item and non stock item in one billing?

    Hi,
    Yes,it is possible .Take example of service scenario,where material used in servicing and service charges(labour) can be billed in single invoice.
    Billing document type,Customer and other header data should be same.
    Reward points if useful
    Regards,
    Amrish Purohit

Maybe you are looking for

  • Error in SmartForm to PDF while Saving with Preview option.

    Hi, I have created a report to convert Smartform to PDF. I want the user to Preview data, if user is interested, then they can save the file. When user clicks the Back button in SmartForm Print Preview, user can select the path of PDF file to save th

  • Help Needed Creating AppleScript for Dial Up Access and Updates

    Hello, Due to my location I can only access the internet via Dial Up. I would like to create a script that wakes up my Mini early in the AM, dials my ISP and checks to see if there are any Apple Updates. I'd like to do this at night so my family does

  • How can I submit the page from javascript in html header?

    I followed http://www.oracle.com/technology/products/database/htmldb/howtos/htmldb_javascript_howto2.html#client It says "doSubmit('Delete');" to submit the delete action. If I do the same in the java script that is embededed in html header, it does

  • "Organizational Unit for the vendor" not defined in SRM portal

    Hi, Iu2019m trying to create a supplier from the vendor list that appears in SRM portal in u201CStrategic Purchasingu201D u2013 u201CBusiness Partneru201D u2013 u201CCreate business partner: Supplieru201D u2013 u201CAdd external Supplier fromu201D. W

  • Disk Utility shows 0,00 Bytes (0 Bytes) for 2.73 TB Array

    I have an Xserve Raid connected to an Xserve G4 dual 1GHz 10.2.8 Server. I have had a 700 Meg Raid 5 volume for several years with no problems. I just purchased 7 500 GB ADMs to add to the second controller. I first upgraded the firmware to "firmware