paint

Getting drawable area of an AWT frame in Mac OS X?

只谈情不闲聊 提交于 2019-12-13 13:25:00
问题 I have subclassed java.awt.Frame and have overridden the paint() method as I wish to draw the entire contents of the window manually. However, on the graphics object, (0,0) corresponds to the upper left hand corner of the window inside the title bar decoration, not the first drawable pixel. Can I determine the co-ordinate of the first drawable pixel (ie, the height of the decoration) in a cross-platform manner, avoiding using a Mac OS X-specific fudge factor? Will I be forced to nest a Panel

Java snake game

 ̄綄美尐妖づ 提交于 2019-12-13 09:55:17
问题 Well starting off i must admit there are countless snake questions out there, though every Programmer even if newbie or expert writes his code differently so i decided to open another one case, import java.awt.Color; import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JFrame; public class Game1 extends JFrame { float x; float y; int[][] tileKati = new int[30][30]; int keyCode; int body; boolean Right = true; boolean Left = false;

Using the paint or repaint method to paint lines over an applet JAVA

送分小仙女□ 提交于 2019-12-13 09:21:59
问题 I am wondering if it's possible to paint lines over an applet. I am loading the applet from an external source, but I'd like to paint lines where the cursor is on the screen. Can someone tell me how I'd do this please? Here's an example. g.drawLine(mouse.getLocation().x - 6, mouse.getLocation().y, mouse.getLocation().x + 6, mouse.getLocation().y); g.drawLine(mouse.getLocation ().x, mouse.getLocation().y - 6, mouse.getLocation().x, mouse.getLocation().y + 6); 回答1: I am wondering if it's

Zoom my drawing on the background [duplicate]

爷,独闯天下 提交于 2019-12-13 08:30:53
问题 This question already has an answer here : HTML5 canvas zoom where mouse coordinates (1 answer) Closed 5 years ago . I make program like a paint with HTML5 canvas and javascript. Drawing takes place on the background image. How to zoom my drawing on the background together. Before zoom it: After zoom it (need this result) : Note: zoom should be where clicked with the mouse on the background image 回答1: I've done this before! First of all, I set a zoom level attribute on my canvas. Main.canvas

How to reset graphics with paintComponent on transparent JFrame?

好久不见. 提交于 2019-12-13 04:58:49
问题 Usually when I want to make animation, I reset all the graphic screen by drawing rectangle: @Override public void paintComponent(Graphics g) { g.setColor(Color.white); g.fillRect(0,0,1000,1000); // now im drawing the animation on empty screen } After I drawed the Rect I can draw the animation on empty screen so the animation will move instead of spread. Right now I want to draw animation on Transparent JFrame. How can I empty the component from Precedings drawings, and still keep the JFrame

How to call paint event from a button click event?

大城市里の小女人 提交于 2019-12-13 04:48:02
问题 I have a pictureBox with the event "paint" and I also got code in there to draw graphics. such as: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.DrawEllipse(Pens.Blue, 10, 10, 100, 100); } private void button1_Click(object sender, EventArgs e) { pictureBox1.Invalidate(); } } } My question is. How to fire these events of from a button_click event? I

How do I change the size of a rectangle while painting a histogram?

随声附和 提交于 2019-12-13 04:42:50
问题 Actually I am new to java gui, and here I want to change the rectangle height whenever we put something in text field and press button, but I don't know how to do it, actually I checked in a ton of sited but I couldn't find an easy way.Actually I can't find how to change rectangle size that is inside paintComponent inside the MyPanel class. (The logic for height change is how many vowels capital and small,and consonents and other things are there in string) import java.awt.*; import javax

What is WPF equivalent of Windows Forms Region.Xor in Paint event?

点点圈 提交于 2019-12-13 04:35:04
问题 I'm trying to move this WinForms code to WPF, but there is no Paint event. private void OnPaint(object sender, PaintEventArgs e) { var region = new Region(new Rectangle(0, 0, this.Width, this.Height)); var rectangle = new Rectangle(0, 0, 50, 50); region.Xor(rectangle); e.Graphics.FillRegion(Brushes.Black, region); } 回答1: WPF doesn't work like WinForms in terms of graphics. You can't actually draw shapes, you have to place them into your content. Geometry should serve as a good replacement for

Basic paintComponent not being called by repaint()?

回眸只為那壹抹淺笑 提交于 2019-12-13 04:24:09
问题 I'm using the book Headfirst java , and I have put together a program that I thought would compile fine. But when the window is created, the background or oval isn't showing up. import javax.swing.*; import java.awt.*; public class setup { public static void main(String[] args) { JFrame f = new JFrame(); System.out.println("Created Frame"); JPanel myJPan = new JPanel(); System.out.println("Created Panel"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300,300); System.out

can't invoke paint

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:58:42
问题 I created my own control and overwritten the onpaint event, the problem is that the paint event stopped working Any ideas why? And how to restore it? 回答1: Let's have a telepathic guess here: You forgot to call base.OnPaint(...) inside your override. Meaning that the base functionality is no longer invoked. 回答2: Maybe the control is obscured. I had a similar problem, and the problem was that the form in the Designer view was bigger than the actual form when the application was run. My custom