paintcomponent

JFrame code compiles and runs, but does not open window

我与影子孤独终老i 提交于 2019-12-24 22:57:18
问题 Here you will see my code: I am just trying to make a little window that displays "Hello, Java!". I am currently running on Ubuntu 14.04. To go more in depth with my problem, the icon with the coffee cup shows up when I run the program like there is a window, but there is not window attached to it and if clicked, no window pops up. Any help would be much appreciated! public class HelloJava1 extends javax.swing.JComponent { public static void main(String[] args) { javax.swing.JFrame f = new

Java - repaint(x, y, w, h) doesn't call paintComponent? [duplicate]

拥有回忆 提交于 2019-12-24 13:40:15
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Java - repaint(x, y, w, h) doesn't call paintComponent? (with SSCCE) I'm trying out this neato performance trick repaint(x, y, w, h) and it sure is helping performance a lot. Unfortunately, the special extras I've put into a paintComponent in the same class are now not being painted. I put a System.out.println() test at the beginning of paintComponent and it turns out it's not even called (as our astute

images are not showing up in paint component

馋奶兔 提交于 2019-12-24 10:06:42
问题 it gives me a black screen for setbackground, but it doesnt seem to read the images or draw them, some help would be appreciated, also if you could tell me the information pertaining to my code, i have trouble understanding general r vague answers, thanks. import java.awt.*; import javax.swing.*; import javax.swing.JComponent.*; public class Movie extends JApplet { private String movName1; private String director1; private int yearMade1; private Image movPic1; private String movName2; private

Graphics Not Drawn/Appearing

我怕爱的太早我们不能终老 提交于 2019-12-24 07:17:37
问题 I'm having this problem where an object that I've drawn isn't appearing in the GUI. I know it's being processed because data is being pushed to a log file. However, the graphic isn't appearing. Here's some of my code: public static void main(String[] args) { JFrame window = new JFrame(); window.setLayout(new BorderLayout()); window.setVisible(true); } There's a button and a few other widgets that I've placed here and there. The center pane (BorderLayout.CENTER) is where my DrawnObject is to

Swing not drawing on Mac

自闭症网瘾萝莉.ら 提交于 2019-12-24 05:51:01
问题 I am trying to draw an incredibly basic shape using swing in Java, however for some reason it does not seem to be working. This is code that I downloaded from my lecturer that he showed us in a lecture, but when I run it the window opens but nothing is drawn and I have no idea why. package graphicsEx; import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Lecture1Example extends JPanel{ // This is where the JPanel gets (re-)painted when the screen is refreshed. public

Swing not drawing on Mac

只谈情不闲聊 提交于 2019-12-24 05:50:03
问题 I am trying to draw an incredibly basic shape using swing in Java, however for some reason it does not seem to be working. This is code that I downloaded from my lecturer that he showed us in a lecture, but when I run it the window opens but nothing is drawn and I have no idea why. package graphicsEx; import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Lecture1Example extends JPanel{ // This is where the JPanel gets (re-)painted when the screen is refreshed. public

tooltip text erases panel drawing in java

痞子三分冷 提交于 2019-12-24 00:59:54
问题 I have a JPanel on which some drawing is performed using paintComponent method and after that when ever a user clicks on the JPanel a string is drawn (or any drawing) on it and as the user moves mouse over the JPanel it shows the coordinates in the tooltip of the JPanel . 1) The problem is that when the tooltip comes over the drawn string it erases it but this tooltiptext has no erasing effect on the drawing part which I performed in paintComponent method. I am not able to understand that why

Painting Graphics2D in a JFrame

為{幸葍}努か 提交于 2019-12-23 22:09:02
问题 I'm making a 2d vertical shooter game, in which everything is coded (and working) but the graphics. I have not used the Graphics classes before, so this is all new to me. The following is the code I use to paint everything to the JFrame: public void paintAll() { Graphics h = new Graphics2D(); for(Bullet j : GameState.getEnBullets()){ h.drawImage(j.getImage(),j.getX(), j.getY(), null);} for(Enemy j : GameState.getEnemies()){ h.drawImage(j.getImage(),j.getX(), j.getY(), null);} for(Bullet j :

How to draw a continuous curve of repeated ovals on speedy mouse cursor dragging?

吃可爱长大的小学妹 提交于 2019-12-23 20:56:48
问题 This code is for drawing on a JPanel. In the paintComponent(Graphics) I am trying to draw curves via repeated Graphics2D#fillOval(x, y, with, height) . The app is working OK, and when I drag the mouse cursor slowly; it draws a continuous curve as I need. But when I speed up dragging the mouse cursor, the result is separated dots and not a continuous curve. So how to make it draw a continuous curve even if I speed up dragging? import java.awt.*; import java.awt.event.*; import java.util

Tile Drawing on Canvas based on file with ints

女生的网名这么多〃 提交于 2019-12-23 19:18:10
问题 So im trying to make a map based on a a file which has ints in it 1111111111 1000000001 1000000001 1000000001 1111111111 And so what i get the code to do is display a grass tile (32x32) for 1 and a dirt tile for 0. This is my code for loading and differentiating between the 2. protected void loadMapFile(String string) throws Exception { // TODO Load Map, Put into int array File f = new File(string); BufferedReader in = new BufferedReader(new FileReader(f)); String line = in.readLine(); cols =