Questions tagged [swing]

Swing is the primary user-interface toolkit in Java and is shipped with the standard Java SDK. It is contained within the package javax.swing.

Filter by
Sorted by
Tagged with
1 vote
0 answers
29 views

trying for a Typewriter effect on a JTextPane [closed]

i'm pretty new to coding (about 5 months) and i've been trying to make a custom terminal for a text based RPG. so far i have the terminal working the way it should but i'm looking for ways to rewrite ...
user avatar
0 votes
1 answer
65 views

Get on what tile has mouse clicked

I am writing a chess game using Java and Swing, And I wanted to get the tile position on which a mouse clicked. I searched through internet, but all of them were really off, and never accurate. When I ...
user avatar
0 votes
0 answers
22 views

Get tile position on what a mouse clicked [duplicate]

I am writing a chess game using Java and Swing, And I wanted to get the tile position on which a mouse clicked. I searched through internet, but all of them were really off, and never accurate. When I ...
user avatar
0 votes
1 answer
163 views

How do I zoom in and out in a fully tiled based game

I am currently developing a tile based game in Java and trying to add the option of zooming. I do the zoom by reducing and enlarging the tiles, but the problem is that it creates spaces between the ...
user avatar
  • 3
0 votes
0 answers
35 views

Trying to create a knockback effect between 2 squares (Code in Java)

I've been in trouble for weeks now and I don't understand why it doesn't work for me! I have tried so many things and I just can not understand. I try to get one player to get a knockback as soon as ...
user avatar
  • 3
0 votes
1 answer
50 views

Looking for tips on how to optimize/debug Java/Eclipse

I made a raycasting engine with wall textures. Before adding the texture the engine was silky smooth. With textures it has small lags (or stutters) when i move around and i would like to know why. My ...
user avatar
1 vote
1 answer
550 views

How do you draw a random irregular polygon in java? (Asteroids)

I am coding an Asteroids game in Java. In the real arcade game, asteroids are made of irregular shapes like this: When I code, I can only set asteroids to 1 or another specific shape, like this: ...
user avatar
0 votes
1 answer
42 views

How do you make a shape slide on a JFrame?

I have some simple code that draws a dot in one of 8 places on a screen. There is a higher chance the dot will appear in some locations more than others. The code works and all, but it feels kind of ...
user avatar
0 votes
1 answer
158 views

How to avoid Singleton/Statics/Injection in my puzzle game

I am developing a puzzle game in java with swing. Purpose of the game to find the all the correct pairs on the board without ur lifes reaching 0 , preety simple etc. I have a class My_Button which ...
user avatar
  • 1
0 votes
1 answer
174 views

Should I use Panels or Frames?

Hi I am creating my first game in NetBeans using Java, the game is going to be an RPG that will look a bit look Undertale on the surface in that there will be a menu, then a load game section and then ...
user avatar
  • 3
-1 votes
1 answer
278 views

Making a Java Swing game a browser based game [closed]

I have made a game in Java using Swing for the GUI. It is a network game relying on the client-server model. Basically the game is a turned-based chess-like game. It has a connection menu, game ...
user avatar
  • 1
1 vote
1 answer
765 views

How to create a split screen display with one frame and canvas

I am creating a 2D Java game, which looks like this: My question is what should I do to my display to create two 'separate' displays. I plan on doubling the height of the program, and have a second ...
user avatar
  • 13
0 votes
1 answer
692 views

How do I split my screen to include a JFrame and a lwjgl screen

I a making a game and I'm going to make a little side GUI to create game items. How can I have a window both include a Canvas element and an lwjgl window.
user avatar
0 votes
1 answer
54 views

Why is the rectangle not moving?

...
user avatar
1 vote
1 answer
584 views

How to remove bricks on collision?

I am on my last stage of creating a simple breakout game in Java using BlueJ. I have added multiple rows of bricks using an ArrayList. However now the task is to ...
user avatar
  • 13
2 votes
1 answer
3k views

How do I get text width and height in Swing/AWT?

I'm making a game engine based on Java Swing and I wonder if I can get the text width/height. Say, what I have is: the text string the font and text size (the Font...
user avatar
  • 282
4 votes
1 answer
561 views

Swing KeyListener doesn't work when pressing Shift X Z and directions at the same time

My code: ...
user avatar
  • 282
1 vote
0 answers
154 views

Is there a common library for key listener for Java?

I'm making a game engine which supports Swing and JavaFX at the same time. I provided key listener APIs like this: Swing ...
user avatar
  • 282
1 vote
0 answers
444 views

How to implement pixel level collision detection?

I'm developing a simple game engine for practise purpose, and I used codes like this to do collision detection (fake code): ...
user avatar
  • 282
3 votes
1 answer
1k views

Isometric tiles drawing and picking - JAVA

I'm trying to draw isometric tiles in Java and implement a tile picking system using the mouse cursor. I draw the tiles using math formulas I found and adapted to my tile textures which you can find ...
user avatar
3 votes
2 answers
142 views

Why is my Mario clone game sprite getting cut off when I try to change it?

In my Super Mario 3 clone, my sprite draws correctly upon instantiating the JFrame, but when I press one of the buttons I've set to jump, it gets partially cut off. Everything on the screen is a ...
user avatar
  • 131
4 votes
2 answers
2k views

How can I make Diagonal movement?

This is a follow-up question to my last one. I am developing a game which has an Icon on a JLabelwhich the user controls with WASD keys. Right now it can go up, ...
user avatar
1 vote
1 answer
146 views

Why is the movement space increasing?

This is a follow-up question to my previous question. I got my key holding to move, using boolean variables and making another method with a ...
user avatar
0 votes
1 answer
2k views

How to detect if a key is held?

I am trying to make a dodging game, where objects fall from the top of the window that the player must dodge or collect, depending on whether it is a triangle or a circle. Right now I am doing the ...
user avatar
0 votes
1 answer
588 views

When I drag a JLabel, why is it appearing in a different location?

I am making a checkers game, and it is behaving very strangely. As of now, I am just trying to get the basics, such as grid layout, and getting the pieces laid out and moveable. My 8 by 8 grid opens ...
user avatar
1 vote
2 answers
1k views

How to set a Label position after a timer ends, in a repetitive structure?

I have this fragment of code. It moves a pawn on a board. ...
user avatar
  • 23
0 votes
1 answer
566 views

Java Thread.sleep() VS Get last and current time

I am creating a simple game using Java. I'm not using any game library. I just want to know if it is okay to call Thread.sleep(40) before calling ...
user avatar
1 vote
1 answer
139 views

How can I make part of a JLabel visible under mouse movement?

The JLabel has an image of a room. I want the mouse to act as a flashlight, and only display around the mouse the part of the JLabel/image that the mouse is hovering over, in a large circumference. ...
user avatar
1 vote
1 answer
141 views

How do you create dots in a shape of a letter and make them interact-able for a user to connect them?

I am making a game where the user is given a letter on screen such as the below image The user then uses the mouse to draw from one point to another until the shape is drawn. I wanted to know what ...
user avatar
  • 13
3 votes
2 answers
121 views

Make a cell's content 'listens' to another cell (the closest cells)

I'm a newbie in programming and in java and I need some lights and help.I'm developing a game in which two players have to play with tokens (say red and blue) by placing them in cells (75x75 grid). ...
user avatar
  • 133
2 votes
1 answer
59 views

FillRecatangle set Opacity?

I have a game with a HUD which is drawn by fillrectangle. How would I fade these rectangles when the player is on the HUD?
user avatar
2 votes
1 answer
242 views

DrawString and Render graphics after custom time

I want to draw String after some second like "Boss is incoming",and after the string is disappeared i want to draw the Boss.I have the graphics and the string so my question is how to add timer for ...
user avatar
4 votes
1 answer
383 views

When handling key input, I'm getting a negative timeout value in my thread. What's going on?

So I'm programming a game using Swing and AWT and I'm getting a weird error. As I check for input in my MenuState, which is just my Menu screen, it is telling me that the timeout value in my game loop....
user avatar
4 votes
1 answer
274 views

2D Map Editor Tiles Palette - Best suited Java Elements to use?

I'm making a 2D RTS Map Editor and here came the moment to make a Palette which is just a popup frame showing tiles to be clicked on and then applied on the map. I'm wondering which Java Elements to ...
user avatar
1 vote
1 answer
443 views

How to create 2D cameras in swing?

What is the best way to create a camera for a 2D platformer using swing, and I want to create a camera that moves instead of moving the background. This is because I'm going to have objects rotated by ...
user avatar
2 votes
2 answers
631 views

Swing GUI for games (performance) [closed]

I'm developing a game in Slick2D and I'm trying to make GUI. I've already tried TWL library, but it seems to me a bit complicated and it doesn't cover what I need. In my own implementation of GUI I'...
user avatar
  • 165
1 vote
3 answers
3k views

Java 2D Game Hitbox Detection & Rounded Corners

I am working on a simple 2D game with Java, Swing and no framework. I have a rectangular player that the user can move around. On the map are few obstacles which the player should not be able to go ...
user avatar
  • 111
0 votes
0 answers
113 views

In Java swing, while handling a 2D top down game, how should I handle scaling for quality transformations (mainly screen rotation)

For my top down game, I plan to have screen rotation where entities don't rotate, but everything else does. I am using a raster array to store my image so I don't have to render things stacked on each ...
user avatar
  • 223
2 votes
2 answers
2k views

How does rendering with Swing compare to rendering with openGL?

[summary: Is the performance of Swing at least in the same dimension as openGL [through LWJGL]? If yes, what percentage would you give it? What possible other problems can I expect from Swing in the ...
user avatar
1 vote
2 answers
825 views

Swing for game development - regarding threads

For those of you who use Swing to develop their real-time Java games. (Meanign a game that constantly updates game state and redraws the screen using a constant loop). As I see it, there are three ...
user avatar
  • 903
0 votes
1 answer
3k views

How do I double-buffer renders to a JPanel?

I'm trying to make a little breakout game with Java and Swing. The only issue so far is that drawing on the JPanel causes lots of flickering! The relevant code: <...
user avatar
  • 117
8 votes
2 answers
6k views

Smooth movement in a tile based game

How can we make our character move smoothly across tiles? He moves tile by tile, but that looks unprofessional. In addition, when you hold down the arrow keys he zips across the screen. How can we ...
user avatar
  • 81
2 votes
2 answers
1k views

fast java2d translucency

I'm trying to draw a bunch of translucent circles on a Swing JComponent. This isn't exactly fast, and I was wondering if there is a way to speed it up. My custom JComponent has the following ...
user avatar
  • 123
1 vote
1 answer
2k views

I'm not sure why my shape is not moving

So I am trying to teach my self how to my develop games with java by cloning older games. At the moment I am cloning Pong, and I can not figure out why my paddle is not moving. The move method should ...
user avatar
1 vote
1 answer
4k views

How to detect whether my Java application is active?

I want to pause my game (written in Java Swing), when the player switches to another application. But I did not find a way to detect this switch. window.isActive()...
user avatar
  • 11
1 vote
2 answers
5k views

How to create a main menu using java swing

I have been trying to figure out for quite some time on how to create a basic main menu for a game that just has a couple clickable labels, but I don't know how to write them. I have created a class ...
user avatar
  • 163
5 votes
3 answers
35k views

Java - Best Implementation KeyListener For Games

I am working on a game using only the swing and awt packages. Note I can only use the default Java libs. Meaning I have to use KeyListener. I have imported KeyListener properly, however, it is still ...
user avatar
  • 173
1 vote
2 answers
432 views

Calling opengl32.DLL from java?

I don't like LWJGL in some cases, so I prefer to use Swing. The thing is that Swing doesn't have OpenGL. I have tried JOGL and it's a mess to install, needs external jars, and I have yet to get it ...
user avatar
  • 1,351
0 votes
1 answer
695 views

Are there shaders or at least shader like things in Swing?

Is there? Because I'm wondering if it supports GLSL, HLSL, or it's own shading language? I don't know much about Swing graphics. Does anyone know?
user avatar
  • 1,351
1 vote
1 answer
2k views

Tile Maps in Java JFrame Game

I am making a 2D Java game with Java's own drawing library. I was wondering how I would make a tile map display on the screen. I would prefer to use a GUI application to make the maps. I'm looking for ...
user avatar