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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:37:07+00:00 2026-05-27T12:37:07+00:00

I want to build a gui application, which should be completely drawn on a

  • 0

I want to build a gui application, which should be completely drawn on a canvas, no other widgets will be used.

package cn.ggfan.fun.music.gui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class GGPlayerGUI {

    private static Shell shell;

    /**
     * @param args
     */
    public static void main(String[] args) {
        final Display display = new Display();

        shell = new Shell(display, SWT.NO_TRIM | SWT.RESIZE);
        shell.setLayout(new FillLayout());
        shell.setSize(300, 500);
        shell.setAlpha(200);
        Canvas canvas = new Canvas(shell, SWT.NONE);
        canvas.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
        canvas.addPaintListener(new PaintListener(){

            public void paintControl(PaintEvent e) {
                e.gc.setAlpha(255);
                e.gc.setAntialias(SWT.ON);
                e.gc.setLineWidth(2);
                e.gc.setForeground(new Color(display, 187, 30, 136));
                e.gc.drawLine(0, 80, 300, 80);
                e.gc.drawLine(0, 450, 300, 450);
                //gc.fillPolygon(new int[] { 25,5,45,45,5,45 }) 
                e.gc.setBackground(new Color(display, 187, 30, 136));
                e.gc.fillPolygon(new int[]{100,470,90,475,100,480});
                e.gc.fillPolygon(new int[]{110,470,100,475,110,480});
                //e.gc.fillPolygon(new int[]{100,470,90,475,100,480});
                e.gc.fillRoundRectangle(145,470,3,10,2,2);
                e.gc.fillRoundRectangle(152,470,3,10,2,2);

                e.gc.fillPolygon(new int[]{200,470,210,475,200,480});
                e.gc.fillPolygon(new int[]{190,470,200,475,190,480});
                e.gc.setForeground(new Color(display, 250, 250, 250));
                //e.gc.setLineWidth(1);
                e.gc.drawOval(80, 455, 40, 40);
                e.gc.drawOval(130, 455, 40, 40);
                e.gc.drawOval(180, 455, 40, 40);
            }
        });

        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }

        display.dispose();
    }

}

it looks like this:
enter image description here
what should I do to make the “buttons” can be clicked and have hover effect?

  • 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-27T12:37:07+00:00Added an answer on May 27, 2026 at 12:37 pm

    If I understand your code correctly, your buttons are circles (ovals) on a Canvas.

    You need to write a position method that determines whether or not a particular x, y point on the Canvas is inside or outside of one of the ovals. You use a MouseMoveListener, the mouseMove method together with your position method, to determine when the mouse is inside or outside one of your ovals.

    If the mouse is inside an oval, you draw the “hover” version of the oval. If the mouse is outside an oval, you draw the regular version of the oval.

    You use a MouseListener, the mouseDown method together with your position method, to determine when the user has left clicked on one of the ovals.

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

Sidebar

Related Questions

I want to build my own custom view which should look like the Crysis-GUI.
Possible Duplicate: Socket Thread and PyGTK i want to build a GUI chat application..
I have visual studio 2008, and want to build an GUI application that on
I am using PyGTK to build a GUI application. I want to update the
I want to build a website that uses Flex/Flash as the GUI, and Java
i want to do test and build simple debugger GUI in c++ that debugging
I am developing a GUI application in Qt Creator and want to write some
I want to use Qt to create a simple GUI application that can play
We have a command line application that could benefit from a GUI. We want
I have implemented a standalone java application which uses the swing framework for GUI.As

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.