paint

How can i repaint a composite in Java (SWT)?

为君一笑 提交于 2019-12-11 20:13:19
问题 When i press a button in my swt program, a new composite should be drawn. But the composite only displays if i resize the window. I have a composite ( compLoad ) in my gui which is assigned a new composite compHELP comHelp_ = new compHELP(compLoad, SWT.RESIZE); i have tried redraw() but nothing happens 回答1: The composite needs to be re-layouted when adding/removing controls , see Composite.layout() // uses Composite.layout(true) Composite.layout(boolean changed) Composite.layout(boolean

Java Applet, get the name of the colour being used in paint()

我与影子孤独终老i 提交于 2019-12-11 20:11:42
问题 When using the graphics object in the paint() method of a Java Applet, Does anyone know how to use a method on the graphics object whereby it will return the name of the color being used? After using g.setColor(Color.red); Then drawing a rectangle Ive tried using g.getColor().toString(); But this only returns a string like this: "java.awt.Applet[r:255 g:0 b:0]" Im looking to get back "Red" if its possible 回答1: It should be possible to do something like this if you really want to. I would

How to draw small dot on every click of the mouse in WinForms PictureBox

北城以北 提交于 2019-12-11 19:31:54
问题 I have a WinForms program where the user clicks on a PictureBox control. I want a small red dot (a few pixels across) every time the user clicks. I also don't want any of the previous dots to go away. I know I will need a generic list of ellipses and rectangles, but am not sure how to execute this. How would I go about doing this? In my program a pictureBox1_Click method handles mouse click events and returns the position of the clicks. A pictureBox1_Paint method handles the graphics to be

Can't paint on directly on JFrame

会有一股神秘感。 提交于 2019-12-11 19:06:48
问题 I have an assignment to create a paint program in Java. I have managed to create something but not exactly what I wanted. My problem is that I cannot create a JFrame in my IDE(NetBeans 7.0.1) from the options that the IDE gives me, and call the paint classes correctly. To be more specific I want to press a button from one panel(ex. Panel1) and paint in Panel2,in the same frame. That's the calling of the class: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

Java Graphics Full Screen Mode not Registering Keyboard Input

拥有回忆 提交于 2019-12-11 13:47:45
问题 I'm trying to write a full screen application that takes keyboard inputs. I've tried adding keylisteners to my JFrame and now to a canvas within the JFrame and setting them both as focusable but it doesn't seem to be registering anything at all. Is there something special I have do to in full screen mode to get it to register my keyEvents? Any help greatly appreciated. (display is just an extension of JFrame with no changes yet) public class chanceCore implements Runnable, KeyListener,

Java Updating Small Circles

早过忘川 提交于 2019-12-11 13:24:43
问题 I need to display a large number (500+) of small circles on a form to simulate LEDs. However, these circles need to be quite small, around 8 or 9 pixels diameter. So far, in my testing, I've put together some code that creates an Led class that uses a Shape (Ellipse2D.Double) and displays it directly on the JFrame from the JFrame's paint method. This has led me to two observations/issues: 1) Firstly, unless there is an alternate method, Java appears to have trouble in drawing small circles.

Toast Immediately

ⅰ亾dé卋堺 提交于 2019-12-11 12:32:40
问题 I would like to have a Toast Message appear while my app is downloading information but even if I put it before my code it doesn't appear until after the download has completed. Putting my code in a separate thread causes many headaches but putting toast in a separate thread doesn't work either. Is there anyway I can have this Toast message come up before this or am I just going to have to work through the headaches? 回答1: You should be putting asynchronous downloads in a separate thread

Repainting an instance of a class from an ArrayList

孤人 提交于 2019-12-11 12:25:52
问题 Ok so I am very new to Java Swing and a beginner in Java in general. My current problem is I have designed a "cityscape". I am working on a UFO flying around, but my randomly generated buildings continue to get regenerated. I am wondering if there is a way to save my instance of buildings to an ArrayList as I have attempted, and paint that selection from that list each time paint is called. I tried what I thought of and I believe it just crashed it when run, because it didn't even open a

Block Mac UI controls painting/redrawing

夙愿已清 提交于 2019-12-11 11:04:05
问题 Hello I was wondering if anyone could shed some light how I may enable/disable redrawing of any class inherited from a nsview? I know Windows has a message you can send to a hwnd to enable/disable gadget painting messages. This also then propagates to child hwnds too. Is there an equivalent method in Mac development? I have an existing GUI library and I was wondering if there is a method to do this that doesn't require modification of the existing source code? 回答1: If the problem is that you

PropertyGrid PaintValue issue: How to remove (and paint outside) the standard rectangle?

这一生的挚爱 提交于 2019-12-11 10:59:20
问题 This might be a straightforward question, even though I haven't found an easy solution to it: I've implemented my custom UITypeEditor with the sole purpose of adding a PaintValue to bools. For the sake of the discussion, let's assume that PaintValue will either paint a checked or unchecked radiobutton. Question 1: Now, here's the problem: It seems like PaintValue automatically inserts a 20x13px rectangle after all paint code has completed. Naturally, a radiobutton inside a black rectangle is