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

  • SEARCH
  • Home
  • 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 9257263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:08:30+00:00 2026-06-18T12:08:30+00:00

I currently have the code below. public class cRunningView extends JInternalFrame { static final

  • 0

I currently have the code below.

public class cRunningView extends JInternalFrame {

    static final int xOffset = 30, yOffset = 30;
  public cRunningView() {
    // Get name;
    super("RUNNING", true, // resizable
            false, // closable
            true, // maximizable
            true);// iconifiable

    System.out.println("##" + "p.getName()");
    // ...Then set the window size or call pack...
    setSize(500, 200);

    // Set the window's location.
    setLocation(xOffset * 0, yOffset * 0);


    JScrollPane scrollPane = new JScrollPane();

}

}

My aim is to have a JInternalFrame with a number of buttons and a box/rectangle on half of the screen.

Within this box i want to be able to draw graphics for e.g. Draw oval from x,y to x,y.

I’ve tried looking at examples but see to get my self more confused than i did to begin. All my code is working e.g. Showing the main GUI window and my internal frame opening but i cant seem to find a good tutuirol/starting point to do graphics within a JScrollPane.

Please note i dont have to use a JScrollPane i just thought i would be a good idea cause it would give the graphics a border round it.

Before anyone moans about the question i think it is valid AND I DONT want the code to be given to me on a plate, i’d rather know and understand what im doing so i can advance my knowledge and be able to help others !

Do i have to make another class and do
JScrollPane myPane = JScrollPane(graphicsClass)

then do everything with paint() then or is there someway to create a graphic and do it without another class?

If i do :

JScrollPane scrollPane = new JScrollPane();
    Graphics temp = scrollPane.getGraphics();
    temp.setColor(new Color(1, 22, 33));
    temp.fillOval(60, 0, 120, 60);
    scrollPane.paint(temp);

It throws errors.

Thanks

  • 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-06-18T12:08:31+00:00Added an answer on June 18, 2026 at 12:08 pm

    You don’t do Graphics in a scrollpane. Also, don’t use the getGraphics() method to do custom painting.

    Custom painting is done by overriding the paintComponent() method of a JPanel or JComponent. Then if required you can add the panel to a scrollpane and add the scrollpane to your frame. Don’t forget to set the preferred size of the panel so scrolling will work.

    Start by reading the Swing tutorial on Custom Painting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have code that does the following: private final static ExecutorService pool =
below is the code i currently have for the drawing class, iv been looking
Currently I have a borderContainer layout as shown below: My code for this layout
I have a python psp page code is shown below. Currently it only prints
I currently have the following code below and I want to update the specific
I have the following code: public class Navigation { public Navigation() { SubNavigation =
I currently have this class below which parses json urls and loads images and
I currently have code in objective C that can pull out an integer's most
Using dotnet 2.0. I currently have code like this : DataView dv = new
I currently have this code which stores XML into an XML-type column called data,

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.