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

The Archive Base Latest Questions

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

In Java SWT, is there a way to draw text on a transparent shell

  • 0

In Java SWT, is there a way to draw text on a transparent shell so that only the text appears visible? What I would like to do is have the text appear on my desktop without any background window. Using shell.setAlpha() will make the entire shell transparent, including any elements that appear on it (which I am trying to avoid).

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

    Here’s an example displaying an image without the shell. You can fairly easily adapt it to display text.

    Update:

    OK I got bored. Here’s a basic example that paints “Hello” on a transparent background:

    package swttest;
    
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.PaintEvent;
    import org.eclipse.swt.events.PaintListener;
    import org.eclipse.swt.graphics.Font;
    import org.eclipse.swt.graphics.FontData;
    import org.eclipse.swt.graphics.Rectangle;
    import org.eclipse.swt.graphics.Region;
    import org.eclipse.swt.widgets.Canvas;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    
    public class Test {
    
        public static void main(String[] args) {
            Test test = new Test();
    
            test.show();
        }
    
        public void show() {
            Display display = new Display();
            // Create a shell with no trim
            final Shell shell = new Shell(display, SWT.NO_TRIM);
            shell.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
    
            //set the transparent canvas on the shell
            Canvas canvas = new Canvas(shell, SWT.NO_BACKGROUND);
    
            //create an area to paint the text
            Rectangle size = new Rectangle(0, 0, 200, 200);
            canvas.setBounds(size);
    
            Region region = canvas.getRegion();
    
            //mucking about with fonts
            Font font = display.getSystemFont();
    
            FontData[] fd = font.getFontData();
    
            fd[0].setHeight(24);
            fd[0].setStyle(SWT.BOLD);
    
            Font bigFont = new Font(display, fd[0]);
            canvas.setFont(bigFont);
    
            // define the shape of the shell using setRegion
            shell.setRegion(region);
            shell.setSize(size.width, size.height);
    
            canvas.addPaintListener(new PaintListener() {
                public void paintControl(PaintEvent e) {
                    e.gc.drawString("Hello", 10, 10, true);
                }
            });
    
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                    display.sleep();
            }
            region.dispose();
            display.dispose();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 172k
  • Answers 172k
  • 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 substr_count($text, "http") http://www.php.net/manual/en/function.substr-count.php Note that isn't sufficient, but neither is… May 12, 2026 at 2:26 pm
  • Editorial Team
    Editorial Team added an answer Get a good profiler like YourKit. It can tell you… May 12, 2026 at 2:26 pm
  • Editorial Team
    Editorial Team added an answer Okay, I've solved it: change the second entry under User… May 12, 2026 at 2:26 pm

Related Questions

Warning: I'm new to GUI building in C# (come from a long history in
I am writing an application in Java that places an icon in the system
I have a performance problem related to string comparison (in Java). I'm working on
In my SWT Java app I often want to return information from inside a

Trending Tags

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

Top Members

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.