paint

Java2D removing old pixels after moving image?

房东的猫 提交于 2019-12-13 01:27:32
问题 So I'm moving an image in Java2D and it bounces aswell. For some reason, it always leaves behind a trail of old images. How could I fix this? Main class: package org.main.graphics; import java.awt.Graphics; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import org.main.entity.Entity; import org.main.entity.Loael; @SuppressWarnings("serial") public class GameWindow extends JFrame implements Runnable { private List<Entity> entities =

Image not drawing after sleep java

北城以北 提交于 2019-12-13 01:02:26
问题 I am trying to have a background image draw then have a character draw over it. My code was working until I added sleep do I didn't get 1500 fps. package sylvyrfysh.screen; import javax.swing.*; import java.awt.*; import game.infos.Information; public class ImageLoadDraw extends JFrame{ /** * */ private static final long serialVersionUID = 1L; public static void main(){ DisplayMode dm=new DisplayMode(Information.sX,Information.sY,16,DisplayMode.REFRESH_RATE_UNKNOWN); ImageLoadDraw i = new

JTabbedPane mouseover paint issue

主宰稳场 提交于 2019-12-13 00:23:17
问题 I am working with an application that is experiencing painting issues on some users computers when the mouse passes over the tabs in a JTabbedPane. They also occasionally have similar issues on other interactive components like JButtons. I have only ever seen this error occur on mouse overs. The application is being run with 1.6.0_20 and I have already tried the flag recommended in update 10 in case it was an issue with D3D (-Dsun.java2d.d3d=false). Since I am a new user I cannot post a

Is it possible to blur part of image on touch in Android?

我的未来我决定 提交于 2019-12-12 18:29:28
问题 i want to blur particular area on image view. eg. i want to allow user to draw rectangle similar to crop in android, once user draws that rectangle on image, the area inside rectangle will be blurred or on finger touch. i searched a lot,but most of the examples explain how to blur full image, dint find any tutorial or link that explains about blurring only some part of an image. any help will be really appreciated. 回答1: There's nothing easier! But you can only pixelate it, select the targeted

Change JButton Shape while respecting Look And Feel

风流意气都作罢 提交于 2019-12-12 18:13:13
问题 I know this question has been asked a million times, and can be done by overriding paintComponent() , but what I want to know is how to change the shape while respecting the current Look And Feel. If I want to change the shape to a circle, I also want the button to look like a button, just with a different shape. I tried making a JButton, the overriding paintComponent , then clipping it to a circle, but I didn't get the border effects on Nimbus LAF . Is there a better way? Or is there a

BeginUpdate() EndUpdate for a UserControl

徘徊边缘 提交于 2019-12-12 10:36:30
问题 I have written a UserControl that behaves like a ContainerControl , but is totally painted by WindowsForms (I inherit from UserControl ) I would like to avoid painting the control while I'm filling it, so I would need to write something similar to BeginUpdate() - EndUpdate() . This is easy to do when the control is user-painted, but in this case I'm not sure about how to proceed. 回答1: You could make use of Suspend/Resume layout. e.g. private void BeginUpdate() { this.SuspendLayout(); // Do

What is the simplest way to draw in Java?

∥☆過路亽.° 提交于 2019-12-12 10:11:16
问题 What is the simplest way to draw in Java? import java.awt.*; import javax.swing.*; public class Canvas { private JFrame frame; private Graphics2D graphic; private JPanel canvas; public Canvas() { frame = new JFrame("A title"); canvas = new JPanel(); frame.setContentPane(canvas); frame.pack(); frame.setVisible(true); } public void paint(Graphics g){ BufferedImage offImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Grapics2D g2 = offImg.createGraphics(); g2.setColor(new Color

onDraw fill shape create with canvas.drawLine

☆樱花仙子☆ 提交于 2019-12-12 09:08:59
问题 i draw 4 lines (canvas.drawLine) in order to draw a rectangle. Is there any possibility to fill the area of the rectangle? (I know that android have a rectDraw. Mine is only curiosity) thanks in advance. ok.. I ve also a path created a path segment. Following the code.. Please can u explain how fill the internal area? `Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(2); paint.setColor(android.graphics.Color.RED); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint

JFrame not painting rectangle

谁说我不能喝 提交于 2019-12-12 04:43:04
问题 Have a very simple issue which I haven't come across before. I used a similar layout before when doing a project. import javax.swing.*; import java.awt.*; import java.awt.event.*; class q1 { public static void main (String Args []) { q1Window showMe = new q1Window(); } } class q1Window { q1Window() { JFrame window = new JFrame("Tutorial 1"); window.setSize(600,600); window.setVisible(true); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void paint (Graphics back) { back

Delphi PaintBox without Key Events

好久不见. 提交于 2019-12-12 04:35:19
问题 I see my version of delphi, doesn't have Key Events(OnKeyDown, OnKeyUp, OnKeyPress) events for TPaintBox. I would like to process something like that. Had somebody a paintbox with these events? 回答1: Like TLama said, you'll need to inherit from TCustomControl. But you'll need some additional code to publish all keyboard events. You could choose the easy way and inherit from TPanel since TPanel already exposes a Canvas and a number of keyboard events. But here's some code to show how to create