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. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 12 months ago. Improve this question I am trying to print shapes in a loop, but when I run the program nothing shows up. I am using shapes from a custom class I
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: JFrame f = new JFrame(); try { f.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File(“image.jpg”))))); } catch (…
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 …