awt

Why do I keep getting an [line: 75] Error:must implement the inherited abstract method java.awt.event.ActionListener?

不羁岁月 提交于 2019-12-11 06:42:31
问题 import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.*; import java.io.*; import java.util.*; public class WetBulbByLocationFrame2 extends JFrame { public JLabel countryLabel = new JLabel("Country"); public JPanel countryPanel = new JPanel(); public JComboBox countryBox; public String [] northAmericanCountries = {"Antigua", "Aruba", "Bahamas", "Barbados", "Bermuda", "Canada", "Costa Rica", "Cuba", "Dominican Republic", "Grenada", "Guadalupe",

Clickable image buttons

一个人想着一个人 提交于 2019-12-11 06:38:57
问题 I'm making a puzzle app that needs to assign information to each piece. Here is a photo. In the photo I've just printed each puzzle piece to the screen. The pieces are generated before they are displayed, the pieces vary in amount. e.g. I want a puzzle thats 9x9 pieces... So I need 9x9 or 81 buttons... When selected the button or piece is highlighted. When selected and when other buttons are clicked such as Assign Location than the piece data and the action of the button are executed

Java AWT in scala: (AWT-EventQueue-0) java.lang.NoClassDefFoundError

China☆狼群 提交于 2019-12-11 06:26:14
问题 I'm trying to use java awt in scala to make a simple desktop application. I have been working on it for some days without any problem, until I didn't touch it for 2 days and when I came back, I get a java.lang.NoClassDefFoundError exception. It was working fine before, but now even the simplest of code gives me this error. https://github.com/aganm/NoClassDefFoundError Main.scala import java.awt.{EventQueue} class Bar(val bar: Int) { } object Main { def main(args: Array[String]) { EventQueue

Paint BufferedImage on JFrame and write to File

陌路散爱 提交于 2019-12-11 06:25:36
问题 I'm trying to code a program, that reads an Image into a BufferedImage, paint it on the JFrame, paint circles in it, and writes it to a File. The following code will do all of it except the content of the saved file. The saved image only contains the untouched BufferedImage. No Circles ;) I already treid to figure it out by changing and adding some code, but it didn't help a lot. public class PaintImage extends Component { BufferedImage img; private int pngWidth, pngHeight; public int

Java Paint if x = location do this else do this

蓝咒 提交于 2019-12-11 06:09:32
问题 I'm in computer SCI AP and I can't figure out why this isn't working public static void moon(Graphics g) { for(int k = 0; k < 550; k+=2) { if (k == 550) { g.setColor(Color.blue); g.fillOval(k,50,50,50); for(long delay = 1; delay<10000000; delay++); g.setColor(Color.white); g.fillOval(k,50,50,50); k = 0; } else { g.setColor(Color.black); g.fillOval(k,50,50,50); for(long delay = 1; delay<10000000; delay++); g.setColor(Color.white); g.fillOval(k,50,50,50); } } } So basically is will make the

Java applet displays itself multiple times

前提是你 提交于 2019-12-11 05:46:31
问题 I am making a Java applet for school whose function is to randomly select six numbers for coordinates of three points and connect them to make a triangle. It is only supposed to draw one triangle and find the "length of the sides". However when I put it on my website it will redraw itself multiple times. I made another applet, simpler, that only selects 4 random numbers for coordinates to draw a line. Same problem. The redrawing problem seems to happen when the user moves the screen, e.g.

Cannot move an image

陌路散爱 提交于 2019-12-11 05:41:51
问题 I am trying to move an image from right to left. The image I am trying to move is drawTrain method in another class. I think I have to use drawTrain method with move() method. However, I do not know how to do that.. Or I'm totally wrong and there has to be another solution. So far, I tried to use something like train.drawTrain.move(movex, 0); train.drawTrain(0, 0).move(movex, 0); well.. failed.. I tried to search and google and everything, but I'm just sitting and spending several hours. If

Swing Works different on different Platform

一世执手 提交于 2019-12-11 05:19:45
问题 I have made a Screen Recorder using Java Swing and Xuggler 5.4 . I have developed it in Windows 8 64 bit. It's working excellent for Windows. But at client side on Linux's environment , nothing is working. I have searched thoroughly but not getting any solutions. I have checked this thread , but it didn't work for me. Then I tried to create simple Transparent window in Linux but it's also not working. I was not able to click through the Resizeable Panel. I have used the same JRE version (1.7)

How to capture mouse cursor in Java?

纵然是瞬间 提交于 2019-12-11 05:11:50
问题 Ok, Most of you will think it's a duplicate because it's already written everywhere that it's not really doable and the only option is to do a screenshot using awt robot. But... The issue is that the mouse cursor does not even appear in the picture produced by AWT robot... I tries gnome-screeshots and there I can see the mouse cursor. But from the java screenshot, nothing. The entire picture, but not mouse cursor. It's like it's hidding it before taking the picture. I search for a parameter

Generate AffineTransform from 3 points

半城伤御伤魂 提交于 2019-12-11 05:08:34
问题 Given 3 points (x and y coordinates) in coordinate system A, and 3 corresponding points in coordinate system B, how can I derive an AffineTransform that will convert from A to B. My question is similar to Create transform to map from one rectangle to another?, except that question only deals with 2 points - i.e., it assumes there is no rotation. 回答1: Suppose your transform is of the form x' = px + qy + r y' = sx + ty + u and write your six points as (A1x, A1y), (A2x, A2y), (A3x, A3y), (B1x,