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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:32:58+00:00 2026-05-15T23:32:58+00:00

I am writing an Eclipse RCP-based application and am trying to draw a rectangle

  • 0

I am writing an Eclipse RCP-based application and am trying to draw a rectangle on top of a ViewPart. However, the rectangle seems to take up the whole screen even when specifiying the bounds. The following is my code.

public void createPartControl(Composite parent) {
        Shell shell = parent.getShell();

        Canvas canvas = new Canvas(parent, SWT.NONE);
        LightweightSystem lws = new LightweightSystem(canvas);
        RectangleFigure rectangle = new RectangleFigure();
        rectangle.setBounds(new Rectangle(0, 0, 10, 10));
        rectangle.setBackgroundColor(ColorConstants.green);
        lws.setContents(rectangle);
}
  • 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-15T23:32:59+00:00Added an answer on May 15, 2026 at 11:32 pm

    I haven’t used Draw2D, but I tried modifying your example by creating another rectangle figure and adding it to the first one, and that one shows up. I.e.

    // from your code
    rectangle.setBackgroundColor(ColorConstants.green);
    
    // new code
    RectangleFigure r2 = new RectangleFigure();
    r2.setBounds(new Rectangle(0,0,10,10));
    r2.setBackgroundColor(ColorConstants.blue);
    rectangle.add(r2);
    
    // back to your code
    lws.setContents(rectangle);
    

    It looks fine to me – there’s a little blue rectangle in the top left corner of the totally green canvas. I guess that the figure you use as the contents of the canvas, by default (and probably by necessity), takes up the whole canvas.

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

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you open a new project you have the option… May 16, 2026 at 12:00 pm
  • Editorial Team
    Editorial Team added an answer You can use h:inputHidden to retain data for the subsequent… May 16, 2026 at 12:00 pm
  • Editorial Team
    Editorial Team added an answer The stream that you're reading from does not support getting… May 16, 2026 at 12:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm writing a wizard for an Eclipse RCP application. After doing some processing on
I'm writing an RCP application plug-in. I want to make a set of objects
The Jobs API in Eclipse RCP apparently works much differently than I expected. I
I am writing Eclipse plugins where there are quite a few running jobs. In
I am writing Eclipse plugins, and frequently have a situation where a running Job
I am writing Eclipse plugins for Java, and have the following problem: Given an
I am developing an Android application where I get the following exception while writing
I writing a php function to check existence of bad whole words (keep in
I´m writing an application for Android in which I have a character that I
Im writing an ipad application. So far what I have is a Delegate and

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.