paint

Java Snake Game: Apple showing while snake is invisible

北战南征 提交于 2021-02-11 14:51:04
问题 I am following a the following video to design a snake game: https://www.youtube.com/watch?v=91a7ceECNTc I am following it step by step, but when I run it, the snake does not show on my screen, just the apple. I think I have something wrong when implementing public void paint(Graphics g); Can someone help me? This is the code my Main class import javax.swing.JFrame; public class Main { public static void main(String[] args) { JFrame frame = new JFrame (); GamePanel panel = new GamePanel();

Java Snake Game: Apple showing while snake is invisible

余生长醉 提交于 2021-02-11 14:50:29
问题 I am following a the following video to design a snake game: https://www.youtube.com/watch?v=91a7ceECNTc I am following it step by step, but when I run it, the snake does not show on my screen, just the apple. I think I have something wrong when implementing public void paint(Graphics g); Can someone help me? This is the code my Main class import javax.swing.JFrame; public class Main { public static void main(String[] args) { JFrame frame = new JFrame (); GamePanel panel = new GamePanel();

How to save a drawing made with java graphics as a independent object

别等时光非礼了梦想. 提交于 2021-02-11 12:20:25
问题 my problem is that I need to save the things that I draw with java graphics as independent objects, to later recolor them, erase them indepently... Here is my eclipse project for you to import. (The main class is the Paint class) This is the method I use to draw: protected void paintComponent(Graphics g) { if (imagen == null) { imagen = createImage(getSize().width, getSize().height); graficos = (Graphics2D) imagen.getGraphics(); graficos.setRenderingHint(RenderingHints.KEY_ANTIALIASING,

How to oepn an image to draw on that

馋奶兔 提交于 2021-02-07 19:50:26
问题 am creating an app in which people can draw a sketch and save to the gallery. This I have done and is working fine. What I would like to be able to do is take an image from the Gallery and be able to draw on that. I have been able to bring up the Gallery to pick the image but I haven't been able to work out how to imbed that image onto the canvas to then draw on but the prob is , it opens up the gallery...but when i click on any pic to open up, it just goes back to app, but not with the

How to oepn an image to draw on that

痞子三分冷 提交于 2021-02-07 19:49:37
问题 am creating an app in which people can draw a sketch and save to the gallery. This I have done and is working fine. What I would like to be able to do is take an image from the Gallery and be able to draw on that. I have been able to bring up the Gallery to pick the image but I haven't been able to work out how to imbed that image onto the canvas to then draw on but the prob is , it opens up the gallery...but when i click on any pic to open up, it just goes back to app, but not with the

How to oepn an image to draw on that

杀马特。学长 韩版系。学妹 提交于 2021-02-07 19:48:32
问题 am creating an app in which people can draw a sketch and save to the gallery. This I have done and is working fine. What I would like to be able to do is take an image from the Gallery and be able to draw on that. I have been able to bring up the Gallery to pick the image but I haven't been able to work out how to imbed that image onto the canvas to then draw on but the prob is , it opens up the gallery...but when i click on any pic to open up, it just goes back to app, but not with the

Java Drawing Multiple Squares in Same JFrame

橙三吉。 提交于 2021-02-05 11:12:05
问题 I am trying to make an animation with multiple thread. I want to paint n squares where this n comes from commend-line argument. Every square has their x-y coordinates, colors and speed. They are moving to the right of the frame with different speed, color and coordinates. Since I am using multi thread I assume I have to control each squares. So I have to store each square object in the ArrayList. However, I am having trouble with painting those squares. I can paint one square but when I try

Java Drawing Multiple Squares in Same JFrame

*爱你&永不变心* 提交于 2021-02-05 11:04:02
问题 I am trying to make an animation with multiple thread. I want to paint n squares where this n comes from commend-line argument. Every square has their x-y coordinates, colors and speed. They are moving to the right of the frame with different speed, color and coordinates. Since I am using multi thread I assume I have to control each squares. So I have to store each square object in the ArrayList. However, I am having trouble with painting those squares. I can paint one square but when I try

Java Drawing Multiple Squares in Same JFrame

江枫思渺然 提交于 2021-02-05 11:03:32
问题 I am trying to make an animation with multiple thread. I want to paint n squares where this n comes from commend-line argument. Every square has their x-y coordinates, colors and speed. They are moving to the right of the frame with different speed, color and coordinates. Since I am using multi thread I assume I have to control each squares. So I have to store each square object in the ArrayList. However, I am having trouble with painting those squares. I can paint one square but when I try

Paint Method is not Called

烂漫一生 提交于 2021-01-29 09:30:56
问题 After making an instance in a previous frame, I'm trying to the background image on the next frame but as a result, I just saw the debugged result and found out that the paint method was not called. From what I know, the paint method is inherited by the JFrame class and with this logic, I've made it overrided. As I guess, the reason happen the logical error is from what I used the event handler and made the instance in the EventHandlerClass. if(e.getActionCommand().equals(ButtonTo)) if