repaint

Java: Why doesn't this JPanel paint properly?

十年热恋 提交于 2020-01-06 14:51:28
问题 I have a 2D array. I want each pixel to be represented by a total of four in the actual image. I've tried various piece of code but none seem to work and I don't really understand how it works either. So far I have: panel = new JPanel() { @Override public void paint(Graphics g) { Rectangle rect = g.getClipBounds(); g.setColor(Color.white); g.fillRect(rect.x, rect.y, rect.width, rect.height); for (int i = 0; i < m.width(); i++) { for (int j=0; j < m.height(); j++) { g.setColor(Color.red); g

Java: Why doesn't this JPanel paint properly?

99封情书 提交于 2020-01-06 14:50:07
问题 I have a 2D array. I want each pixel to be represented by a total of four in the actual image. I've tried various piece of code but none seem to work and I don't really understand how it works either. So far I have: panel = new JPanel() { @Override public void paint(Graphics g) { Rectangle rect = g.getClipBounds(); g.setColor(Color.white); g.fillRect(rect.x, rect.y, rect.width, rect.height); for (int i = 0; i < m.width(); i++) { for (int j=0; j < m.height(); j++) { g.setColor(Color.red); g

How to repaint out of focus dialog without gaining its focus?

断了今生、忘了曾经 提交于 2020-01-04 09:09:11
问题 I made some menu and it is to update conmmon variables (for text on grid) then the out-of-focus dialog must repaint the grid. Here is the screenshot: The main control panel is always at top position and 'Data Display' panel is always sitting behind it. When press a button on front panel, Data Display must update its grid. Currently, the common variable 0.4 on the grid is updated by adding listener and works fine. But the grid itself is not repainting anymore. How can I repaint the out-of

Delphi - TEdit Labels are not displaying (Windows 7/Vista only)

半腔热情 提交于 2020-01-04 02:44:34
问题 I we got few TEdit forms inserted on another form, but their labels are not displaying until I change size of the window. This happens just on Windows Vista / Windows 7. Windows XP has everything labeled correctly. Ive already tested repaint / refresh (just TEdit / all form etc.) with no result. Delphi 7. Thank you for your answer bad version Correct version code will be added soon enough :) 回答1: May be it is ALT Key press causes controls to disappear under Themes in Vista and XP bug? 回答2: I

Delphi - TEdit Labels are not displaying (Windows 7/Vista only)

谁说我不能喝 提交于 2020-01-04 02:44:31
问题 I we got few TEdit forms inserted on another form, but their labels are not displaying until I change size of the window. This happens just on Windows Vista / Windows 7. Windows XP has everything labeled correctly. Ive already tested repaint / refresh (just TEdit / all form etc.) with no result. Delphi 7. Thank you for your answer bad version Correct version code will be added soon enough :) 回答1: May be it is ALT Key press causes controls to disappear under Themes in Vista and XP bug? 回答2: I

Java repaint not working correctly

回眸只為那壹抹淺笑 提交于 2020-01-02 04:39:10
问题 i use the java repaint method , it repaints, but the update is only seen when I either click on the canvas or resize the panel. How can I fix this ? What causes it? 回答1: You need to call the method revalidate(). This forces the layout manager to update / repaint all its components. 回答2: repaint() isn't actually repainting, it's just requesting a repaint of the component. 回答3: It may be helpful to simply grab the Graphics object from the component you wish to paint. Then just invoke a paint

Difference between Graphics object of getGraphics and paintComponent

谁说胖子不能爱 提交于 2019-12-30 12:13:15
问题 If I'm working with a JPanel, what's the difference between the Graphics object returned by getGraphics, and the Graphics object that is passed in paintComponent method? 回答1: getGraphics Can be null Is a "snap shot" of the last paint process Anything painted to it will be lost on the next paint cycle You should avoid using getGraphics and simply use what is past to the paintComponent method. In theory, there is no difference between them, but if you want what you have painted to survive

How to disable the default painting behaviour of wheel scroll event on JScrollPane

谁说我不能喝 提交于 2019-12-29 05:37:39
问题 I recently purchased the book Filthy Rich Clients and i found it really useful and fun. Building on one example from the book i tried implementing a custom ScrollPane that displays a "shadow" on the bottom of its view over the component to be displayed. I ended up with the code below. It works but not perfectly. Specifically when i scroll the pane by dragging the scroll bar everything works ok and the painting is really smooth. But when i scroll with the mouse scroll the shadow flickers and i

How to search subfolders and repaint a jTable with new data in Java?

泪湿孤枕 提交于 2019-12-28 07:09:13
问题 I'm having a couple problems with my program. I wanted a jTable to display various data points added to its TableModel, but I can't seem to get the table to update with the new data. Also, it seems my search for png images within a directory has fallen short of actually searching the directory completely for all png images and stops only at the first folder's contents. I've placed all data points into appropriate ArrayLists for their data types and converted them to Object arrays before

Error when adding event handler into a JButton to repaint the image inJava GUI

风流意气都作罢 提交于 2019-12-25 17:03:13
问题 I've created 2 JButtons.One of them has the function of a button and the other handles an image.I want that image to change when this button is clicked.So inserted the method repaint() and added a listener to the first JButton to change the image.When trying to add the listener or the event handler to the first JButton nothing happens.So the image doesn't change.Can anyone show me how can I insert this listener in a way that it works(changes the image when the button is clicked)?Here is my