awt

The lines that I draw get removed when another line is drawn

心不动则不痛 提交于 2019-12-23 06:38:25
问题 The lines that I draw get removed when another line is drawn. I am using mouse event to draw lines but when ever i draw the second line the first one get removed. I believe it has something to do with my points which keep changing the location of the coordinates where i want to draw the line as my click keep changing the points but i am not sure that's the reason; please help thanks in advance public class DrawOnComponent { public static void main(String args[]) throws Exception { JFrame f =

using double buffering kinda ruin my applet. and it has java uses or overrides a deprecated API

☆樱花仙子☆ 提交于 2019-12-23 05:32:33
问题 this is my code actually it's just a moving space invader game. i search the internet for the animation i have tried the double buffering, it gets rid the flickering but its ruining the entire output. it also has java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. this is so hard... import javax.sound.sampled.*; import java.applet.*; import java.awt.*; public class SpaceInvaders extends Applet implements Runnable{ AudioClip soundFile1; int Xposition

How do I implement Java swing GUI start screen for a game with drawString and drawImage?

痞子三分冷 提交于 2019-12-23 05:13:17
问题 I'm not sure how I would fix the errors in my program and how I would highlight the option the user is hovering on. I want it to highlight the code for each position, i.e position 1 would be highlighted(as a different color) to start game,etc. and up/down would change position and I would change the position with up ,down, left, right. This is what I have so far. At the moment its bugged and when compiled with my window it comes out as: Which works for the main game and altered for this

Java - CardLayout show() IllegalArgumentException

ⅰ亾dé卋堺 提交于 2019-12-23 04:51:37
问题 I have a problem with the CardLayout show method So I declare my CardLayout and apply it to my JPanel CardLayout cl = new CardLayout(); panel.setLayout(cl); Then I add a 2 panels into the CardLayout cl.addLayoutComponent(panel, "menuScreen"); cl.addLayoutComponent(panel1, "gameScreen"); I then have a JButton that when is clicked, I show the gameScreen public void mouseClicked(MouseEvent e) { if(e.getSource() == (startGame)) scenechange.show(panel,"gameScreen"); } The only problem is that it

Java swing/awt component to draw chessboard [closed]

旧街凉风 提交于 2019-12-23 04:30:12
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I don't have much experienc with swing/awt. My problem is: I need to draw something like chessboard (NxN). In general I need to get

Display tables of a database in java

点点圈 提交于 2019-12-23 04:25:03
问题 I'm working on a java application, and I want to display the list of the tables in a Mysql database, I searched on the net and I found that "SHOW TABLES FROM [DB]" is the appropriate request, but how can I dispaly the result of this last on a java swing/awt application, PS : I tried to put the result of the request on a resultset, res = sta.executeQuery("SHOW TABLES FROM sinpec "); but it doesnt work ... How can I proceed ? 回答1: Please try this query:- SELECT TABLE_NAME FROM INFORMATION

Repaint() is not being called in Java while loop

有些话、适合烂在心里 提交于 2019-12-23 03:41:48
问题 I'm attempting to create a simple animation in Java that displays a blue ball moving horizontally part way across a 500 x 500 window. The ball is supposed to move at a rate of 1px/30ms. The problem is, is that the window is only being painted when the while loop exits and not during every iteration of the while loop as I intended. This results in the blue ball being painted in its final location. Could you please tell me what I'm doing wrong here? I've also tried executing this code on the

java add image to canvas

北慕城南 提交于 2019-12-23 03:26:08
问题 I'm trying to add a image to a java canvas. I'm using the "ImageIO.read" to get the image source. The problem i'm facing is that i don't know how to display it on the canvas after reading the image location. Also later i will need to load a different image(e.g. after a button pressed) how can i do this. The update (canvas.update) method needs a "Graphics" parameter instead of an image. Below you'll find my code simplified (i left out all code that's not relevant to the canvas issue.) public

Event dispatching filter chain in Swing

大兔子大兔子 提交于 2019-12-22 19:53:52
问题 I'm trying to organize filter chain of EventQueue.dispatchEvent. Something like java.io.FilterInputStream or javax.servlet.Filter. Found EventQueueDelegate.Delegate to be intended for this?.. But in case of exception in EventQueue.dispatchEvent EventQueueDelegate.Delegate it knows nothing about this and ugly java.awt.EventDispatchThread .handleException appears on the scene. Is this 'temporary hack' not yet solved since Java SE 1.1???!!! I've also looked toward EventQueue.dispatchEvent to

Event dispatching filter chain in Swing

白昼怎懂夜的黑 提交于 2019-12-22 19:52:48
问题 I'm trying to organize filter chain of EventQueue.dispatchEvent. Something like java.io.FilterInputStream or javax.servlet.Filter. Found EventQueueDelegate.Delegate to be intended for this?.. But in case of exception in EventQueue.dispatchEvent EventQueueDelegate.Delegate it knows nothing about this and ugly java.awt.EventDispatchThread .handleException appears on the scene. Is this 'temporary hack' not yet solved since Java SE 1.1???!!! I've also looked toward EventQueue.dispatchEvent to