repaint

paint() and repaint() in Java

一世执手 提交于 2019-11-26 16:33:48
问题 I've spent maybe the last two hours browsing and reading up on these methods and the Graphics class, and maybe I'm stupid, haha, but I'm just not understanding them. What are they for? I understand that they're supposed redraw or update components on the screen, but I have never understood why this is required (I'm new to this). For example, if I'm moving a JLabel around the screen, a call to setLocation() moves it just fine. Is that a scenario in which repaint() isn't required? In which

What's the difference between reflow and repaint?

半城伤御伤魂 提交于 2019-11-26 15:01:47
I'm a little unclear on the difference between reflow + repaint (if there's any difference at all) Seems like reflow might be shifting the position of various DOM elements, where repaint is just rendering a new object. E.g. reflow would occur when removing an element and repaint would occur when changing its color. Is this true? DVK This posting seems to cover the reflow vs repaint performance issues http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/ As for definitions, from that post: A repaint occurs when changes are made to an

Updating ImageIcon in JTree without repainting the Tree?

↘锁芯ラ 提交于 2019-11-26 14:55:05
问题 Basically I edit an attribute private string status="OK" in the UserObject() of a DefaultTreeNode() . I have a CustomRenderer which implements DefaultCellRenderer , which sets the Icon by rendering the "OK" attribute of UserObject of a TreeNode . Originally, when I select a node, the icon changes. I am using Tree.revalidate() & Tree.repaint() , and the change is being reflected. However, I am not sure if this very efficient. What would be the proper way of doing this? I tried doing TreeModel

paintComponent draws other components on top of my drawing

主宰稳场 提交于 2019-11-26 14:48:54
问题 I'm trying to build a simple paint tool. The mouseDrag events creates a new ellipse and causes my JPanel to repaint() . This works fine so far. However, if I press any button (or any other UI component) before firing the mouseDrag event for the first time, the button is painted in the upper left corner of my panel. I have isolated the code into this test application: import java.awt.BasicStroke; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt

repaint() in Java [duplicate]

偶尔善良 提交于 2019-11-26 14:30:20
问题 Possible Duplicate: Java GUI repaint() problem? I write a Java code, but I have a trouble with GUI problem. When I add a component into JFrame object, then I call repaint() method in order to update the GUI but it doesn't work. But when I minimize or resize this frame, the GUI is updated. Here is my code: public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(460, 500); frame.setTitle("Circles generator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

How to improve painting performance of DataGridView?

二次信任 提交于 2019-11-26 14:07:26
问题 (sorry for bad English) I have a big problem with performance of DataGridView when it re-paints. I'm using a DataGridView to show logs from an external application stream. Messages from the stream come in with a high frequency (less than 1 ms). If I add new row to the DataGridView immediately when each new message comes, the DataGridView doesn't have time to re-paint itself before the next message comes. A possible solution is to use a queue to collect messages and re-paint DataGridView every

javafx listview and treeview controls are not repainted correctly

ε祈祈猫儿з 提交于 2019-11-26 11:56:34
i am trying to put elements on a listview and treeview with javafx, but both controls wont refresh theyre content. i am using an obvservable list to control the items and every time i delete one item, the listview or treeview removes it from the datasource. but the view is not updating. i am still seeing all the items. the only difference is, the removed item can not be selected any more. for example link 2 shows the collaped item list. image 1 shows the items before they are collaped. the items are collapsed but the old entry is still visible. does anybody know a solution for this problem.

repaint in a loop

久未见 提交于 2019-11-26 11:39:44
问题 I am writing a game using Java Swing. I want to paint each time a loop executes with a small delay in between to create a cascade effect on screen. I believe that the efficiency routines in the system are collapsing the calls to repaint() into a single call. At any rate, the changes all occur at once after the total delay. Is there some way to force the system to repaint immediately and then delay on each iteration of the loop? My Code: for(int i=0;i<10;i++){ JButton[i].setBackground(Color

JLayeredPane and painting

瘦欲@ 提交于 2019-11-26 11:32:14
问题 I am writing an application which has a JLayeredPane (call it layers) containing two JPanels in different layers. I override the paintComponent method of the JPanel at the bottom (call it grid_panel) so it paints a grid, and the the paintComponent method of the one at the top (call it circuit_panel) so it paints a circuit. Here\'s a summary of the structure: layers - |-circuit_panel (on top) |-grid_panel (at bottom) I want the grid_panel to stay static, ie, not to do any repaint (except the

Problems with Java&#39;s Paint method, ridiculous refresh velocity

て烟熏妆下的殇ゞ 提交于 2019-11-26 07:49:28
问题 I\'m developing a very simple version of R-Type as work for the university, but despite it works, the craft velocity is a lot of slow, so the movement is ugly and clumsy. I use the method repaint for refresh the screen, there are others methods or ways best than it? Video of Movement Paint method at main Panel @Override public void paint(Graphics g) { super.paint(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2