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


ADVERTISEMENT

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

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

How To Make Green Selection Box To Move Around

Feb 16, 2014

I'm making a simple game where there's a 10x10 grid and you can move around a selection box and you can move around. I've been trying to make the green selection box to move around but it won't move! I only have right movement in the code but it won't work so far. Here are the classes that have to do greatly with each other.

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.image.BufferStrategy;
import java.util.Random;
 
public class Game extends Canvas implements Runnable{
private static final long serialVersionUID = 1L;
 
[Code] ....

I also tried an approach where you click with the move and it snaps to a tile grid but that didn't work either.

View Replies View Related

How To Make Shapes Move At Same Time When User Enter Up

Oct 1, 2014

How to make shapes move at same time when user enter up it should move up. It works for rectangle but i don't know how to move the others like that. (btw i am new to java). How can i do that?

import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.geom.Ellipse2D;

[Code] .....

View Replies View Related

How To Make File Reader Object Move To Next Line If There Is No More Input On Line

Feb 18, 2015

How do I make the file reader object move to the next line if there is no more input on the line. Here is my text and output file as you can see that my text file column cuts off on the 2nd line after 70. I want to read that next line which is 100 into my labs variable however its reading it into my final exams variable. I'll also post the code but I didn't think it was necessary.

textfile:
100908095
1008070
10070

output:
Labs Projects Tests Final Exams
100908095
1008070100
70

[import java.util.Scanner;
import java.io.*;
public class MyGrades
{
public static void main (String[] args) throws IOException
{
int lab, project, test;
int finalExam;//Par and Player values

[Code]...

not sure if I code wrapped it correctly

View Replies View Related

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 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 :: Why Delays In Drawing Images

Jun 17, 2014

I have a question about the execution of code to draw images relative to code that comes after that. I don't normally do this sort of thinghere's the problematic code:

int stn = 0;
while (stn < 10)
{
glb1.xOfText += 20;
glb1.yOfText += 20;
gc1.drawImage(glb1.img1 , glb1.xOfText , glb1.yOfText);
TimeKeeper.pause(500);
stn++;
}

Where glb1 is a final reference to an object that holds common data for the game.while its x and y values say they are for text, they are also used for image placement (at least during this testing phase.)

gc1 is the "graphics context" of the canvas that the images are being drawn on.

The person who wrote this said, "When the attached code is run, the calls to TimeKeeper.pause(500), which in turn call Thread.sleep(500), are all executed in row, and then the results of drawing the image 10 times is displayed. (I know because some of the previous image pastes left some visual data behind.)"

I recall from reading about drawing graphics (a long time ago) that drawImage() could take time, but I don't know why the thread does not indeed sleep between calls to drawImage().

View Replies View Related

Swing/AWT/SWT :: Drawing Images That Are GIFs

Dec 20, 2014

how to phrase the question. I created a small applet in java.. it allows me to move a toon around a blank applet window. I am using four gif files that have a walking animation in them. The issue i am having is after moving around the gif just flashes in and out really quickly.. when i start the program, moving up and down seems to be working perfectly fine, but the moment i move left or right it starts messing up for all directions. here is my code.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CharactorMove extends JApplet implements KeyListener

[code]....

View Replies View Related

Drawing Multiple Objects Swing

Jun 30, 2014

I have to do an assigment using Swing, where I have to make a Board(extends JPanel) and add multiple instances of moving elements to it, with following requirements:

By adding a new object to the Board, the others must not slow down. Also the user interface must not be blocked by the moving objects. So, the movement of the objects must be handled in a separate thread.

and

The application must support adding lots of objects, so it is not okay if every object has its own thread, as this would take too many resources. Design the application in such a way that it uses a constant number of threads, meaning that the number of threads does not grow when adding more objects.

The question is:

How to do this thing with constant number of threads?

View Replies View Related

Swing/AWT/SWT :: Add Free Hand Drawing To ArrayList

Nov 6, 2014

I am buildning a paint application in java, where the user can choose from a combobox wheather he/she wants to draw a rectangle or by free hand. The objects are stored in an arrayList. The user can also choose in the menubar to go back one step, which means to remove the last drawn item from the arrayList and then loop through the arraylist to draw the remaining objects.

It works fine with rectangles. When I create a rectangle it creates only one rectangle, which I add to the arrayList.
My problem is with the free hand. When I draw by free hand (using mousePressed and mouseDragged) I add every "dot" of the line as an object. Which means that when I remove the last item in the arrayList it only removes one dot of the line, not the whole line.

I need to add the dots together as one line, but how can I do that?

if (e.getSource().equals(comboBox)) {
JComboBox cb = (JComboBox)e.getSource();
if (cb.getSelectedItem().equals("Rectangle")) {
this.addMouseListener(new MouseAdapter() {

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Drawing Various Shapes - Repaint Not Working

Jan 16, 2015

I'm trying to make a simple program that will feature some graphics. It will have a JCombobox that the user selects to draw various shapes. I can't get the repaint function to work however.

package selectingshapes;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JPanel;
import java.awt.Graphics2D;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Drawing A Semicircle Using Formula For The Equation Of A Circle

Sep 19, 2014

So Ive got to make a turtle on an image draw a semicircle that starts at the top of a circle and goes down and to the left, changing colors halfway through. I've got everything down, I can draw the turtles and make them do straight lines. My problem is more math related. I need to use the equation of a circle, give it points, and figure out how to write that code in java.

We use the equation for a circle: (x - a)^2 + (y - b)^2 = r^2

amanda.setName("amanda");
amanda.setShellColor(Color.BLUE);
amanda.setBodyColor(Color.RED);
amanda.setPenColor(Color.YELLOW);
amanda.setPenWidth(3);
amanda.forward();
amanda.turn(-90);
amanda.setPenColor(Color.BLUE);
amanda.forward(???);

the question marks are where I need to draw a line on an arc, like in the picture.

View Replies View Related

Swing/AWT/SWT :: Graphics2D / Drawing Double Rounded Corners Border?

Mar 26, 2014

I am struggling to make a double border which has rounded corners. The border should be 2 parallel lines.

I made something which looks almost good, but if you look closer there are a few wrong things.To achieve this, I made 2 paths, then painted them in 2 different colours.

The main problem is painting with AA, because the colours overlap and are affected.

I think it would be smoother to paint a single path using 2 colours.

For the first problem, I think some kind of a stroke would be enough. But, if I build a stroke, it's almost same thing like drawing the path twice, like I did before. Anyway i think that would fix AA problem. But still, maybe I can achieve a smoother effect for the corners.

Question:Maybe something with a 2x1 Texture ? It's possible to achieve this ? I know I tried this before and when a curve was encountered the direction of the texture was wrong and looked messy.

PS: Ignore the blueish thing, it's a dragged component to activate the highlight border.

View Replies View Related

Swing/AWT/SWT :: Double Drawing Pixels When Manipulating DataBuffer Of BufferedImage

Feb 9, 2014

I've been working my way through a tutorial to build a simple 2D tile-based engine that also allows the code to manipulate the colour of pixels on the screen based on a monochrome map read from a file. I've got the code right line for line, but I seem to have a bug when it comes to draw to the screen! At regular intervals, despite what is held in the pixel array of ints (which I have confirmed to be correct when debugging), I get the same row of pixels being draw twice in a row. I figured there was some loop issue somewhere, but after attempting to debug this for some time, I haven't come up with the answer.

Original tilesheet:As rendered:

Game.java:
package igg.engine.game;
import igg.engine.game.gfx.Screen;
import igg.engine.game.gfx.SpriteSheet;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Reading Point Objects From DRW File And Drawing Lines On Panel

Sep 15, 2014

I am trying to read Point objects from .drw file which contains endpoints of line segments, and draw lines making a square on panel when I run the program. This is what I have got so far. how to get the points using array for drawing ?

// inside the method to read points objects from .drw file
try {
fos = new FileInputStream("square.drw");
oos = new ObjectInputStream(fos);
// creating an object of Point class
endPoints = new Point[sampleSize];

[code]...

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 :: How To Make A Row Of JTable Not Editable

Feb 8, 2014

When I click on a row in a JTable, I want to have a row appear above it. For now I'm just making that row be a duplicate of the row I clicked on, but eventually this will be some sort of previous history of that row, so as you are editing the row you actually clicked on you can look directly above it and see what the data used to look like.

I"m not having any problem creating the row, nor am I having an issue getting it positioned correctly. What I want to do with this added row is made it so you can't edit the entire row, and also really make this row stand out. I'd like to say make this row stand out or "POP" so to speak so there is no confusing what it is. I'd almost like to make it look like the row header or even better... Most of what I am seeing are ways to make particular cells uneditable, so I think my backup plan is that, but Is there a good way to do what I described?

View Replies View Related

Swing/AWT/SWT :: How To Make JTextField Editable

Jul 10, 2014

I'm having a hard time finding out the way to make JTextField editable. In what circumstances it can be disabled to write? [even the text in the field can't be selected, not to mention being uneditable. I did the followings to make it editable.

1. In its Properties panel(frame or whatever), checked the "editable" item.
2. In the code I made it run the code below :

void makeFieldsEditable(Boolean flag) {
Left_Name_field.setEditable(flag);
Left_Name_field.setEnabled(flag);
...
}

Is it related with the properties of the control(JTextField)'s surrounding panel, or even the largest containing frame? Using Netbeans ....

View Replies View Related

Swing/AWT/SWT :: How To Make GUI Look The Same On All Screen Resolutions

Feb 11, 2015

I had developed small GUI using swing group layout, which is nice to see on windows, but when I tried it on Linux the GUI look is varied. Then I set the GUI height and width by taking screen resolution, still it is varies the screen look. How I can make the GUI such that it looks the same on all screen resolutions.

View Replies View Related

Swing/AWT/SWT :: How To Make Restart Button Work

Mar 19, 2014

how to make this restart button work. This is what I have so far. I have put the restart button code in red and bold...

package Game;
public class Buttons extends javax.swing.JPanel {
private GameWorld world;
private int restart;

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Make Expand / Collapsable Panel

Oct 29, 2005

Is it possible to make Expand/Collapsable panels in Java without writing huge amounts of code? I want something like this Expand/Collapse How would I go about it?

View Replies View Related

Swing/AWT/SWT :: Possible To Make Graphics Such As FillRect Into A Variable?

Aug 16, 2014

I want to do a simple background which is only rendered once onto my screen. I want to use

G.fillRect(0, 0, getWidth(), getHeight());

and make the whole background black, but only once. I wanted to try out making the fillRect into a variable so I can do:

if (background == null) { //background is the variables name.
G.fillRect(0, 0, getWidth(), getHeight());
}

The point is, I want G.fillRect(0, 0, getWidth(), getHeight()); to be a variable, even if this is the wrong way to approach what I want to accomplish, is it possible to make this line of code into one variable? The rest of my code if you need info:

package com.game.blobber;
import java.util.Random;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;

[Code] .....

View Replies View Related

How To Make A Flat GUI Design With Java Swing

Apr 26, 2014

Here is an example of a GUI. Is it possible to make this kind of a thing using Java Swing? Is it possible to have a picture on the entire background of the JFrame, and then other Swing components like buttons, labels etc. sitting on it?Is it possible to have action listeners behind pictures? In other words, they will behave like buttons: the user clicks on them and they do something.

View Replies View Related

Swing/AWT/SWT :: Make Submit Button Smaller

Nov 12, 2014

make this button:

look more like this one:

I'm using GridLayout for my main JFrame.

View Replies View Related







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