I am creating a Java program to simulate Microsoft Paint in Windows 95. There is a color palette in the bottom. Clicking any color in the palette will change the color of the painting tool like pencil. I tried to use Graphics2D to set each color for the tool according to the button clicked in the palette. I tried to
Tag: paintcomponent
Painting method paints things from other components
I am trying to make a simple Java program with GUI using Java Swing. I have painting panel (gPanel) in the center of the screen, panel with buttons (buttonSet) in the west and panel with labels (labelPanel) in the east. To paint over gPanel I use paintComponent method and since I have two buttons, which are supposed to draw different
How do I print a shape in a loop? [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question I am trying to print shapes in a loop, but when I run
Why using an if statement inside a paintComponent(Graphics g) method invalidates all code inside the method?
I’m trying to create a JFrame object which contains a JPanel object. Inside the JPanel object there are 3 JButtons that when clicked, are intended to change the background color of the JPanel. I also want to draw an image which size equals the one of the JPanel object to give the impression of a background image but as you
How to initialize and draw a Rectangle variable in a paintComponent method? [closed]
I’ve been trying to add collision to my game, it seemed like a piece of cake, I already know how to draw a rectangle. But I need that rectangle to be represented by something, a variable. But it seems …
GlassPane is not showing up on JFrame
I have been trying to implement a GlassPane for my games’ in-game HUD, but right now I cant seem to get the JFrame to set my GlassPane as its own i;ve used setGlassPane() and Ive been reading up a few …
JFrame Image, paint on top of it
I create a frame with an image with this code: That works fine, but now I want to paint something in that opened frame (on top of the image). I’m quite new in Java, and I’ve allready tried to make a class that extends JFrame, with a paint(Graphics g) method in it, but it wouldn’t work, I only see the
how do i use an image in java gui
Hi im making a Gui programme using a null layout and a setBounds() method for lay out . In the programme I want 25 strings printed out on the screen in random locations . I know that i could do this with a for loop however i have been trying this to no avail. I have been trying this and