awt

How can I scroll more than one object at the same time?

橙三吉。 提交于 2019-12-17 02:00:11
问题 New question was asked after this one, found here. I'm new to Java, but I am working on a recreation of "Flappy Bird" to learn more about java and the way that graphics are displayed. Any solutions or suggestions to any of my questions is greatly appreciated. Thanks! Right now, my program makes a random pipe and scrolls it, but I don't need it to keep scrolling when x1-3 = -83 ( this is when the pipe will be off of the screen completely and is no longer needed ). Questions How can I make my

Java Event-Dispatching Thread explanation

独自空忆成欢 提交于 2019-12-16 19:49:15
问题 I've recently started learning and exploring the basics of GUI programming in Java. Having been programming for a while I have only done backend work or work and as a result the closest I've gotten to user interfaces is the command console (embarrassing I know). I'm using Swing and as far as I can gather that means by extension I am also using AWT. My question is based on this piece of code: java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frame.setVisible(true); } } )

opening JFrame from applet

百般思念 提交于 2019-12-16 18:04:20
问题 So I programmed am applet that makes a ball roll in circles for ever, and I wanted to make the user decide what speed the circle should roll in, but something failed when I added the JFrame: applet(the stop,destroy and update do not appear because they aren't important, and in start there is nothing): public class Main extends Applet implements Runnable{ private Image I; private Graphics GfU; int ballX, ballY=249; static int radius=20; double Memory; int changeY ,changeX=1; Speed S = new

Create a ImageIcon that is the mirror of another one

血红的双手。 提交于 2019-12-14 04:20:09
问题 I'll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with Swing ? If not, I'm still having troubles with the AWT method : The ImageIcon I want to mirror is a animated gif (with contain a transparent color) and the AWT method returns a non-transparent (the transparent color is changed to opaque black) and non-animated gif. Any ideas how to keep the

How much memory will java.awt.Image consume if JPEG is 10MB?

眉间皱痕 提交于 2019-12-14 03:59:29
问题 MTOM is usually used to transfer image data over SOAP (attachments). The image is mapped to a java.awt.Image (at least with CXF). Does the Image object consume a lot more memory than the actual image transferred? Let's say a transferred JPEG is 10MB, how much more space will the Image object consume? UPDATE - I'm not so sure it has anything to do with java.awt.Image at all. Focusing on CXF/MTOM more at the moment: http://cxf.547215.n5.nabble.com/MTOM-large-attachments-eating-up-JVM-heap

when i am trying to save the data to mysql, an exception is being thrown( java.sql.SQLException)

主宰稳场 提交于 2019-12-14 03:44:45
问题 import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import com.mysql.jdbc.Connection; public class one implements ActionListener{ JFrame frame = new JFrame("ghar hisab"); JButton b = new JButton("save"); Panel p = new

How to blur an image under the mouse

自闭症网瘾萝莉.ら 提交于 2019-12-14 03:36:13
问题 I am working in java, and have an image being generated. When the mouse passes over the generated image, I need the image to use a blur or pixelation filter. What methods should I use to accomplish this? 回答1: Look in here: http://www.java2s.com/Code/Java/2D-Graphics-GUI/ImageEffectSharpenblur.htm You need define a Kernel with an array of whatever values you want, instantiate the ConvolveOp with the Kernal as an argument, and then filter the desired image. 回答2: public void test(int x, int y){

How close a file opened by java.awt.Desktop

微笑、不失礼 提交于 2019-12-14 03:30:13
问题 How to close an opened excel file? Open excel code is: File file = new File("e:\\aaa.xlsx"); Desktop desktop = Desktop.getDesktop(); desktop.open(file); What would be the close code? just using java open and close Windows application like use mouse. 回答1: Forget it. Open here means that the registered application, Excel, takes over and opens a Window. After that you have no control, but watching. Excel will close. File is a class that represents a file system path. Itself it has no state of

Java Textfield in PopupMenu

那年仲夏 提交于 2019-12-14 02:46:54
问题 I am trying to add a TextField to a PopupMenu in Java. (similar to Spotlight Feature in Mac OS X) But i can't add it to as an item because the PopupMenu only accepts MenuItem. Please help me. That's the code I currently have: import java.awt.AWTException; import java.awt.CheckboxMenuItem; import java.awt.Frame; import java.awt.Menu; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import java.awt.Toolkit; import java.awt.TrayIcon; import java.awt.event

What's wrong with my Java code?

筅森魡賤 提交于 2019-12-13 21:42:49
问题 I am showing my code; I am having problem with to display an output on submit button click. At first, I was not able to use local varible in my inner class, but when I search some guy said use final with it. I did, but still not getting any output this is simple formula behind this button. import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JOptionPane; public