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 505953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:39:04+00:00 2026-05-13T06:39:04+00:00

I would like to add java’s default questionIcon to a corner button in a

  • 0

I would like to add java’s default questionIcon to a corner button in a Scrollpane, however the image doesn’t fit correctly (since the button is very small). What should i do to make the icon fit correctly?

Here is the code, It works, so you can try it out and see for yourselfs the problem 🙂

import javax.swing.*;

public class CornerButton extends JFrame 
{
    public CornerButton()
    {

        JTextArea area = new JTextArea(20, 20);
        JScrollPane scroll = new JScrollPane(area);
        JButton btn = new JButton(UIManager.getIcon("OptionPane.questionIcon"));
        scroll.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, btn);
        this.add(scroll);
    }

    public static void main(String[] args) 
    {
        // TODO Auto-generated method stub
        CornerButton mainFrame = new CornerButton();

        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainFrame.setVisible(true);
        mainFrame.setSize(200,200);
    }
}

NB. I posted the same question on Sun’s forums but no one answered, hope I find some help from here 🙂

thanks in advance.

  • 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-13T06:39:05+00:00Added an answer on May 13, 2026 at 6:39 am

    You could try increasing the width of the JScrollBars so that the button has more room to be displayed. For example:

    scroll.getVerticalScrollBar().setPreferredSize(new Dimension(30, 30));
    scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(30, 30));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a small game in Java and I would like to add
i have my Java program and i would like to add code that show
I'm making a small game in Java and would like to add a Quake
I create a Jtree in java, I would like to add 2 value to
For Java web app development on GAE, I would like to add users androles
I would like to generically add numbers in java. I'm running into difficulty because
I have own project and i would like add for this class same as
I have a ListView and each item have a TextView. I would like add
I would like to add a GestureDetector to all views (view groups) of an
I would like to add a custom calculation method to a managed object (which

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.