Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4050868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:07:24+00:00 2026-05-20T14:07:24+00:00

I have this interface to create. I have a problem with the JScrollPane: I

  • 0

I have this interface to create. I have a problem with the JScrollPane:

enter image description here

I declared a JPanel with a Gridlayout(8,1,0,2), I want 8 rows appear in this panel.
A row is a JPanel to, I set the size to make the 8 row panels appear in the big panel.
If the number of rows pass 8, I get two columns …
I added a JScrollPane but it doesn’t appear.
Testing button at the place of button, the scrollpane appear but returning to panel it disappear..

How can I do ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:07:24+00:00Added an answer on May 20, 2026 at 2:07 pm

    I found a solution:

    package d06.m03;
    
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JScrollPane;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.SystemColor;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import javax.swing.BoxLayout;
    
    public class ActionExample4 extends JFrame {
        /**
         * Launch the application.
         */
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        ActionExample4 frame = new ActionExample4();
                        frame.setVisible(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    
        /**
         * Create the frame.
         */
        public ActionExample4() {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setBounds(100, 100, 778, 426);
            getContentPane().setLayout(null);
    
            JScrollPane scrollPane = new JScrollPane();
            scrollPane.setBounds(10, 101, 742, 276);
            //scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            getContentPane().add(scrollPane);
    
            JPanel borderlaoutpanel = new JPanel();
            scrollPane.setViewportView(borderlaoutpanel);
            borderlaoutpanel.setLayout(new BorderLayout(0, 0));
    
            JPanel columnpanel = new JPanel();
            borderlaoutpanel.add(columnpanel, BorderLayout.NORTH);
            columnpanel.setLayout(new GridLayout(0, 1, 0, 1));
            columnpanel.setBackground(Color.gray);
    
            for(int i=0;i<32;i++) {
                JPanel rowPanel = new JPanel();
                rowPanel.setPreferredSize(new Dimension(300,30));
                columnpanel.add(rowPanel);
                rowPanel.setLayout(null);
    
                JButton button = new JButton("New button");
                button.setBounds(20, 5, 89, 23);
                rowPanel.add(button);
    
                if(i%2==0)
                    rowPanel.setBackground(SystemColor.inactiveCaptionBorder);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this design: public interface IFactory<T> { T Create(); T CreateWithSensibleDefaults(); } public
I have a set of objects that I want to conform to an interface,
Suppose I have this interface public interface IFoo { ///<summary> /// Foo method ///</summary>
So lets say I have this interface: public interface IBox { public void setSize(int
I have an interface called Dictionary which has a method insert() . This interface
Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have
I have a property called IsSecureConnection that is part of my object's interface. This
so I have a 3rd party application that I have to interface with, this
Let's say I have a class that implements the IDisposable interface. Something like this:
This is probably my naivety showing through, but anyway... I have a generic interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.