Questions tagged [java-canvas]

A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user.

A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user.

118 questions
0
votes
1 answer

How would I draw an array of string letters to a canvas on Java?

I have an array of letters public String[] letters = {"A","J","K","Q"}; and a method I tried creating to draw the letters. public void drawLetterValue(Graphics pane, String[] someValue, int someX, int someY){ someValue = letters; String…
0
votes
0 answers

How can you access the canvas in one class from another?

Basically, I am trying to access the canvas that was created in a method in one class and use that SAME canvas in another class but add stuff to it. How can I reference the canvas. Here is the class that creates the canvas (The important stuff is…
Lifezdioj
  • 17
  • 4
0
votes
0 answers

Canvas shows content only by minimizing and resizing the window

im using the Canvas class to make a screensaver as a schoolproject. But the window generated by Canvas doesnt show my objects on it (current time) until i minimize it an resize it again. After that all things works fine. so what is wrong? thank you…
l_tronic
  • 1
  • 2
0
votes
1 answer

Set up Canvas layouts

How I will get white rectangle in the middle of scene. I wanna preserve my own code and the height and width of it. Probably it should be use to set X and Y layouts. but I do not know how. When I set them, it resize it from upper left corner.…
user3770144
  • 105
  • 1
  • 2
  • 12
0
votes
1 answer

How to save as image an on-screen Canvas3D?

I'm doing a program to create a die (cube) with different image textures based on the input of the user (user choose images on a SWT GUI). Once the user choose the images, it can visualize the dice on a separate dialog, and perform some rotate…
alejandrorg
  • 55
  • 1
  • 7
0
votes
1 answer

How can I expand one viewPort to "Full Screen"?

I'm working on a project using JOGL API. Now I am stuck at a point that is the followed: -I run the program and it shows a Canvas divided in 4 viewPorts. The objective of the project is basically in each of the viewPorts we need to "project" an…
Tito
  • 298
  • 2
  • 5
  • 20
0
votes
1 answer

How to find out which line was selected in one GWT grid canvas?

I'm working on one GWT grid Canvas like this in the fiddle My gridCanvas Object has horizontal lines represent paths. Also the object has vertical lines that represent sections. I want to know how I could get the user's selection, for example, if…
user3410517
  • 295
  • 3
  • 18
0
votes
1 answer

compress text in java if it gets too long

i want to add print functionality to my software, this requires to compress the text not fit them in the textbox (letters should not be shrunk vertically). is this possible with standard java methods or does someboday know good extensions? i want to…
user1857519
  • 119
  • 1
  • 2
  • 8
0
votes
1 answer

Drag and Drop changes in canvas only visible after minimization

public void dropAccept(final DropTargetEvent event) { if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) { final String d=(String)TextTransfer.getInstance().nativeToJava(event.CurrentDataType); GC gc = new(text); //text is the…
Asher
  • 811
  • 3
  • 10
  • 19
0
votes
1 answer

Line is not drawn

I want to draw a dashed line from point A to point B Here is my code: but the path is never drawn paintDotted = new…
AabidMulani
  • 2,325
  • 1
  • 28
  • 47
0
votes
1 answer

Java: Graphics aligning Strings

I'm currently trying to create a rolling text method, in which will take an argument of a String. Soon, it will start to draw, from left to right, and go onto new lines over time so it doesn't draw off of the screen. I am using the FontMetrics to…
CoderMusgrove
  • 604
  • 8
  • 18
0
votes
1 answer

How to avoid flickering with bufferstrategy when updating Canvas

I am programming a platformer game in Java. Everything works fine and there are no bigger problems, except the flickering on the screen when the Canvas is updated. I'll roughly explain how my game "engine" works: In my main method, I have a Loop,…
Nicolas Brauch
  • 497
  • 1
  • 4
  • 10
0
votes
1 answer

Weird Behavior of getHeight()

I am Creating a J2ME game and i've noticed strange behavior of getHeight() function. Instead of Giving the Full Screen's Height in Pixels,it seems to be returning less than that My Code: Gamecanvas.java : package game1; import…
Spikatrix
  • 20,225
  • 7
  • 37
  • 83
0
votes
2 answers

How do I add a button to Canvas without letting the button resize?

I'm working on a login screen for my game. I have a total of two images on it. One is a splash screenshot and the other is the background image. I'm using BufferedImages to render the images to the screen. The problem I get is that when I add a…
0
votes
1 answer

Java - Scaling a canvas about a particular point

I am more or less finished a very simple planetary gravity simulator using Newtonian physics. It can transform and scale the planets for pan and zoom. This works fine, mouse input and everything. The problem I have is more aesthetic than anything…
Jack O'Connor
  • 185
  • 1
  • 4
  • 11