Swing/AWT/SWT :: AffineTransform Making Image To Move

Aug 5, 2009

I've been trying to make an image rotate in a panel. I did it. But also i want the image to make a translation.

Here is the code i tryed at paintComponent() :

//////////////////////////

Graphics2D g2 = (Graphics2D) g ;
AffineTransform at = new AffineTransform() ;
// at.rotate ( angle in radians ) ;
at.rotate( this.getAngulo(1, 1) ) ;
g2.drawImage(imgemFlecha, at, this);
/////////////////////////////

I cant change image x,y doing this drawImage(). I want to make that change.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: AffineTransform - Rotation Is Being Ignored When Set Transform

May 31, 2014

I'm experimenting with AffineTransform, Basically I've created just a simple test GUI to see how the code works and all that. Anyway, there are two buttons which turn an image left and right and a third button with moves the image to the right (East). When you first run the program the image is facing down (South). Now to turn left or right I'm using an Affine Transform and the rotate method. That works fine. The issue is when I move the image to the right, it ignore whatever rotation I previously I made (from turn left and right buttons). Therefore when I click to move the image, it faces down again even if it was facing left or up or right before I moved it. It will always be facing down. How do I get it to keep the rotation and just move? Btw I'm using the setTranslate method to move the image.

Below is my code.

Images.java
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
public class Images {
static BufferedImage Icon, Rover;

[Code] ....

View Replies View Related

Trying To Make The Image Move

Oct 27, 2014

I am having trouble making my image move to a certain position in a certain amount of time which is set inside a text file. I was wondering what I'm doing wrong and what I'm missing.

import java.io.*;
import java.util.*;
import java.io.FileReader;
public class Animator {
EZImage HP;

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Move Many Balls At A Time Using Thread

Apr 11, 2014

I am try to move 2 ball at same time in different position but only one ball is display.

Here is my code I used two class one extends JPanel and another for JFrame

package usageThread;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
public class ball extends JPanel implements Runnable {

[Code]...

View Replies View Related

Swing/AWT/SWT :: Image Manipulation - Create Application Where Image Is Displayed On One Label

Apr 7, 2014

Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.

View Replies View Related

Swing/AWT/SWT :: Drawing Arcs And Later Make It Move Anti-clockwise

Nov 12, 2014

I first need to draw this exact shape, which later I will have to make it move anti-clockwise, but for now, how to draw this thing:

First thing I can think of is drawArc, but not so sure...

View Replies View Related

Swing/AWT/SWT :: Alternative To Making Static JList?

Sep 16, 2014

I am currently writing a chess application in Java swing. For the GUI part, I have one MainWindow class, and one ChessBoard class. The MainWindow has a main panel, in which is contained 1) a panel containing the chessboard from the chessboard class (a grid layout array of 64 JLabels), 2) a JLabel status bar, and 3) a JList to hold the moves of the game. I have a movePiece method in the chessboard class, which I would like to add the move and question to the moves list, which is contained in the main window class.

However, since JList is some special type, I can't make it static ( that gives me an error ). I also tried creating a method in the main window class to add a move to the list, which I would then access via the chessboard class. However, I can't make the method static, because it is referencing a non-static variable ( the JList ), and since the Main window class already has an object of the chessboard class, trying to create a main window object in the chessboard class creates a stack overflow error.

View Replies View Related

Swing/AWT/SWT :: Making GUI Application Design Extensible

May 5, 2015

I have to create a Swing application for which i haved a set of requirements as,

1. there will be two JPanels ,left and right, on the main JFrame , left frame would contain a JTextField and a submit JButton ,user can enter values 1,2,3 ,in the JTextField and presses the JButton

a. if user enters 1, a JTextField will be shown on right JPanel
b. if user enters 2, a JTextField and a JRadioButton will be shown on right JPanel
c. if user enters 3, a JTextField and a JComboBox will be shown on right JPanel

So I have done that but when my boss sees the code behind this application he told me to make it more extensible i.e. if there is going to be an additional requirement for values 4 or 5 or 6 and so on , then i have to make minimal changes in my code or no change in my code and it should work . how this can be done ? is it possible make such software design ?

public class DesktopApp extends JFrame {
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(DesktopApp.class);
private JPanel jp, jp2, mainPanel;
private JLabel jl, jl1, jl2, jl3, jl4, jl5;
private JTextField jText, jText2, jText3, jText4;

[Code] ....

What wrong am i doing here in this code which in not considered to be an extensible design ?

View Replies View Related

Swing/AWT/SWT :: Making Ball Bounce Around A Screen

Aug 12, 2014

I've got to make a ball bounce around a screen.... From what I can gather they seem to hold back useful java code.

anyway, i've changed the code over and over, and think this is the most succinct way i can manage it. but i have a problem. where i've marked the code (*****) and the following line are conditional on each other. so one won't provide the correct answer without the other line executing first, and vice versa (ignore the code after, i haven't looked at where that should be yet ). Anyway I don't really want to rip the code apart, again, because i'm pretty sure it's close.

View Replies View Related

Swing/AWT/SWT :: Making Interface - Exception Group Layout

Sep 24, 2014

I am making an expert system using Jess about animals. I wanted to make an interface using Swing and so I did. I have a problem using group layouts. The application works fine but at the end a exceptions is thrown:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,
alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,
preferredSize=,defaultIcon=,disabledIcon=,horizontalAlignment=LEADING,
horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,
text=The animal is a cheetah.,verticalAlignment=CENTER,
verticalTextPosition=CENTER] is not attached to a horizontal group

[Code] ....

The application ask the user some questions about the animal. When the expert system has enough information to know the animal it tells the name of the animal and shows a picture of it. The exception is thrown when the application has guessed the animal and shows the response.

Here is the code:

package xindria;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.GroupLayout.SequentialGroup;
import java.awt.*;
import java.awt.event.ActionEvent;

[Code] .....

I think the problem is related to the group layouts. I will attach the eclipse project too...

View Replies View Related

Swing/AWT/SWT :: Making A Custom Cell Renderer Work In A JTable?

Jan 24, 2014

Now my issue is I have a JTable. The first column will contain Date objects all the way to the bottom. I want the JTable to display only the month and year. I created a custom cell renderer, but it appears the cell renderer method "getTableCellRendererComponent" is never called. (I tested it using System.out.println();) Here is my code for setting the cell renderer and the contents of the first column:

MonthYearTableCellRenderer renderer = new MonthYearTableCellRenderer();
tblView.setDefaultRenderer(Date.class, renderer);
for(int i = 0; i < 60; i++){
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.MONTH, i);
tableModel.setValueAt(cal.getTime(), i, 0);
}

The Date objects are set into the cells of column 0 correctly. The table shows the result of the "toString()" method for each cell in that column.

View Replies View Related

Swing/AWT/SWT :: Making Two JComboboxes To Be In Sync When One Selects Item From Dropdownlist?

Jan 17, 2015

basically I would like to know how to to the following Java. Example... Say I have one JComboBox, and it is populated with 10 items which reads from a text file ("apple","banana","kiwi","orange","grape fruit"), and the other JComboBox holds the price ($1,$2,$4, etc etc...you get the drift).

How do I make in such a way when I select for example banana from the JCombobox that it syncs the other JCombox to the correct price?

Basically syncing the two JCombobox so that you do not need to select the price yourself - it does it automatically for you.

View Replies View Related

Swing/AWT/SWT :: Making A Tetris Clone - How To Get Cube To Visualize In JPanel

Nov 10, 2014

My question is, how do I get my Cube to visualize in the JPanel? I've tried a bunch of add methods but they don't compile. Is there a proper method I can use to add an object to a JPanel?

import javax.swing.*;
import java.awt.Dimension;
import javax.swing.Timer;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.*;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Making JButton That Switches Text From 2 JTextFields On Click With Mouse

Aug 6, 2014

I have made a window using JFrame and on my JPanel I have added 3 components: 2 JTextFields ("field1" and "field2") and inbetween them a JButton ("switch"). My goal is to switch the value of field1 to field2 and vice versa when the JButton is clicked. I thought this ActionListener which I have added to my JButton would achieve my goal:

public void actionPerformed(ActionEvent e) {
field2.setText(field1.getText());
field1.setText(field2.getText());
}

However, it changes the value of field2 into the value of field1 but not the other way around.

View Replies View Related

Swing/AWT/SWT :: How To Move A Object And Make Object Shot Laser

Mar 27, 2015

can a keyevent in java make the space ship and the laser too ?

View Replies View Related

Swing/AWT/SWT :: Move Focus From Specific Jcombobox To Specific Jtextarea?

Nov 5, 2014

How do I move focus from a jcombobox to a specific component say a jtextarea.

My attempt below seems to be moving to a random component not the desired jtextarea.

takenByCombo.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB ) {
e.consume();
dayJTArea.requestFocus(); // focust not moving dayJTArea
}
}
});

I applied the above logic to move focus from a specific jtextarea to another jtextarea as seen below and it works as desired.

dayJTArea.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB ) {
e.consume();
monthJTArea.requestFocus();
}
}
});

View Replies View Related

Swing/AWT/SWT :: Making Flipbook In Java Similar To Flash Flipbook

Mar 16, 2012

Is there a way to create a flipbook using swings similar to flash flipbook.

View Replies View Related

Swing/AWT/SWT :: How To Scroll Image

Sep 30, 2014

I have a java swing application.

1. The human user of my application asks it to fire up a scanner which scans a paper document. The document is a filled in form.
2. The application then displays the scanned image to the human user.The image is displayed in a JScrollPane since it may be larger than the scroll pane.
3. The human user needs to locate a certain item in the form, for example a social security number, and enter it into a field in a data entry screen.Note that the image and the field appear on the same screen.

Of-course the social security number always appears in the same location in the image. Also the image needs to be the appropriate magnification and resolution to allow the human user to easily read and understand the item he is searching for in the image.

What is the best way to present the scanned image to the user such that he immediately sees the item he requires and can enter it into the data entry field.

View Replies View Related

Swing/AWT/SWT :: Why Isn't Image Loading

Jun 20, 2014

I have added the image in the src and bin directories and cross-checked that the name of the image file is correct..Here is the main class

import javax.swing.*;
public class apples
{
public static void main(String args[])
{
JFrame frame = new JFrame();
MyDrawPanel wid = new MyDrawPanel();
frame.add(wid);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setSize(300,300);
}
}

and here is the class that does the image adding part

import java.awt.*;
import javax.swing.*;

public class MyDrawPanel extends JPanel
{
public void paintComponent(Graphics g)
{

Image image = new ImageIcon("b.png").getImage();
g.drawImage(image,20, 20, this);
}
}

View Replies View Related

Swing/AWT/SWT :: JComboBox With Image

Apr 14, 2014

My database contains path of images that I want my jComboBox to diaplay. I have written the following code but it does not work for comboBox but works fine when I display image on jLabel etc. How should I go about this

try {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(updatedetail.class.getName()).log(Level.SEVERE, null, ex);

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Image Not Being Displayed In Jpanel

Feb 19, 2014

Trying to get an image to display in a GUI.

try {
ByteArrayInputStream in = new ByteArrayInputStream(
transferWorker.bOutput
.toByteArray());
BufferedImage bufferedImage = ImageIO
.read(in);

[Code] ....

But nothing is happening in the GUI. I have stepped through and bufferedimage contains the data, but its not being displayed. Whats happening is, an image is being transmitted to serial port of laptop, so i'm taking it in and storing it in a BufferOutputStream and then trying to open it in my GUI class.

View Replies View Related

Swing/AWT/SWT :: Get Image To Show Up On Compiled GUI?

Feb 16, 2014

trying to get my image to show up on my compiled GUI.

Here is my GUI, I just need to know how to get the image to show, where do I save an image file so that it comes up in my GUI.

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

[code]...

View Replies View Related

Swing/AWT/SWT :: How To Load Image To JFrame

Jul 23, 2014

How to load an image to a swing application?? I want to load it to myframe(JFrame)..

View Replies View Related

Swing/AWT/SWT :: How To Update Image In Java GUI

Jul 10, 2014

I have a GUI with several buttons and I'm using NetBeans GUI Builder to do. At the click of one of these I would like for it to open another frame containing a picture. So I associate a listener (actionPerformed) the button and when clicked it opens actually post the new frame.

In the new frame I waxed a JLabel and then I associate the image of the label. I saw that to do that NetBeans generates this code:

label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/tree.png")));

My problem is that the picture is overwritten several times during the execution of the program is not changed yet in the frame. That is, in the new frame is always displayed an old version of the image.

I have an image that is created every time I click on the button (it always has the same name and same path). Basically I have a generic tree on which I perform the operations (add, remove, etc..). When I click on the button I call a method that generates the image of the tree (using Graphviz). So I have one image that changes over the time...

How can I do so that the image is always up to date?

The Code:

package View;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class AlberoIpotesi extends javax.swing.JFrame {

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Doesn't Display Image

Mar 28, 2015

why this code, doesn't display the image?

import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

[code]...

View Replies View Related

Swing/AWT/SWT :: How To Resize Image Icon

Aug 15, 2001

Any way to resize an ImageIcon when placing it on a Button so that I don't have to physically rezize the image file?? I am writing an Application, not an applet, so the getImage method won't work.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved