repaint

.setVisible(true) immediate repaint

给你一囗甜甜゛ 提交于 2019-12-01 17:45:26
In a short method, I hide a JFrame using setVisible(false). Then I take a screenshot and restore the JFrame with setVisible(true). After made visible again, the window is supposed to show a different picture than before (lets say a part of that screenshot taken). The problem is that after setVisible(true) is called, the window is flashed with the old content for a split second before paintComponent is called and the updated state is drawn. I could probably workaround this in an ugly way, but I wanted to know if there are better solutions. Thanks in advance for any help edit: While preparing an

AlphaComposite Transparency with repaint overlaps into black

拜拜、爱过 提交于 2019-12-01 10:45:11
So I have an image on top of another panel, and that image is transparent so you can see the panel beneath it. What I'm trying to do is use repaint() to fade the image (which is drawn with the drawImage() method in java.awt.Graphics) out until it is completely transparent so you can see the panel beneath it clearly. As of now, the image is just fading into black instead of into a transparent texture. This is a little bit of my code right now: paintComponent method: public void paintComponent(Graphics g) { super.paintComponent(g); float alpha = 1f-(.01f*(float)opcounter); Graphics2D g2d =

Repaint without clearing

拟墨画扇 提交于 2019-12-01 09:51:53
问题 I am working on a program that mimics Paint. The problem is when I draw a new shape the previous shape gets deleted. I tried to comment out my super call of paintComponents which works but leaves behind too much drawing. import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import javax.swing.JOptionPane; import javax.swing.JPanel; public class Canvas1

AlphaComposite Transparency with repaint overlaps into black

安稳与你 提交于 2019-12-01 06:20:41
问题 So I have an image on top of another panel, and that image is transparent so you can see the panel beneath it. What I'm trying to do is use repaint() to fade the image (which is drawn with the drawImage() method in java.awt.Graphics) out until it is completely transparent so you can see the panel beneath it clearly. As of now, the image is just fading into black instead of into a transparent texture. This is a little bit of my code right now: paintComponent method: public void paintComponent

JFrame removing JPanels and adding a new JPanel

倾然丶 夕夏残阳落幕 提交于 2019-12-01 05:21:22
I currrently have a SwingWorker that sends a HTTP Request and I override the SwingWorker's done() method to change contents in a JFrame. I want to basically remove everything and add a new members panel on the JFrame depending on the values returned from the Server. Now, the problem I am facing is that when I invoke the following methods below on the JFrame, it doesn't remove anything from the JFrame nor does it change it's contents contained within the Frame. //TODO: Investigate why JFrame content pane won't repaint. f.removeAll(); //Pass the frame f reference only into MainDisplay, it doesn

Stop flickering in swing when i repaint too much

北慕城南 提交于 2019-12-01 05:18:56
I am making an RPG with a tilemap. To generate the tilemap i loop through a 2 dimensional array but that means that when I repaint I have to do that each time. If I repaint too much the screen flickers how could I stop this. package sexyCyborgFromAnOtherDimension; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Timer; import java.util.TimerTask; import javax

Swing: Can't get JButton to update - repaint() not working

若如初见. 提交于 2019-12-01 04:04:40
I'm using Swing for the first time to create a simple GUI. It consists of a JFrame upon which I have placed a single JButton which, when clicked, calls some other code which takes approx. 3 seconds to return. Just before the call to this code, in actionPerformed() , I want to update the text on the button to inform the user that processing is occuring. My problem is that the text on the button does not update until after the 3-second call has returned. I want the updated text to be present during the call, then I'll change it back afterwards. Calling repaint() on the JButton doesn't do

JFrame removing JPanels and adding a new JPanel

可紊 提交于 2019-12-01 03:46:53
问题 I currrently have a SwingWorker that sends a HTTP Request and I override the SwingWorker's done() method to change contents in a JFrame. I want to basically remove everything and add a new members panel on the JFrame depending on the values returned from the Server. Now, the problem I am facing is that when I invoke the following methods below on the JFrame, it doesn't remove anything from the JFrame nor does it change it's contents contained within the Frame. //TODO: Investigate why JFrame

workaround for display block and css transitions not triggering

白昼怎懂夜的黑 提交于 2019-12-01 02:55:46
问题 Sorry all for so many updates in this question and I'm glad for everyone trying to help me. I think below there is a more clear way to understand this problem: CSS transitions will not apply if you set the display property of an element to block immediately before changing the property with the transition attached. Consider the following code: CSS: #creative { display: none; opacity: 0; transition: opacity 0.5s; } HTML: <div id="creative"> <span>Sample text</span> </div> Javascript: var dom =

Stop flickering in swing when i repaint too much

拜拜、爱过 提交于 2019-12-01 02:22:20
问题 I am making an RPG with a tilemap. To generate the tilemap i loop through a 2 dimensional array but that means that when I repaint I have to do that each time. If I repaint too much the screen flickers how could I stop this. package sexyCyborgFromAnOtherDimension; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.BufferedReader; import java.io.IOException