Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
61 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 ...
-2
votes
1answer
53 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 ...
1
vote
1answer
94 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 ...
0
votes
1answer
163 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.
0
votes
1answer
46 views
0
votes
0answers
30 views

Render run update question in Graphics2D

Hello guys we are studying on a Snake / Slither io project. In fact we are nearly finish the project but when we run it we couldn't get any Panel drawing and still trying to solve the problem but we ...
0
votes
0answers
39 views

Why does this code for handling multiple hits on a Breakout block mess up my collision detection?

I have a Java breakout game and the next stage i am implementing is for the bricks to take multiple impacts before being destroyed. It works perfectly at the moment if the brick is hit it is then ...
1
vote
1answer
136 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 ...
3
votes
1answer
806 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...
4
votes
1answer
290 views
1
vote
0answers
81 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 ...
1
vote
0answers
243 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): ...
3
votes
1answer
640 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 ...
3
votes
2answers
97 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 ...
4
votes
2answers
776 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, ...
1
vote
1answer
139 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 ...
0
votes
1answer
80 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 ...
0
votes
1answer
178 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 ...
1
vote
2answers
439 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. ...
0
votes
1answer
347 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 ...
1
vote
1answer
81 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. ...
1
vote
1answer
95 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 ...
4
votes
2answers
90 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). ...
2
votes
1answer
50 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?
2
votes
1answer
182 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 ...
4
votes
1answer
304 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....
4
votes
1answer
203 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 ...
1
vote
1answer
369 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 ...
2
votes
2answers
577 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'...
1
vote
3answers
2k 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 ...
0
votes
0answers
97 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 ...
2
votes
2answers
1k 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 ...
1
vote
2answers
516 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 ...
0
votes
1answer
2k 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: <...
8
votes
2answers
5k 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 ...
2
votes
2answers
951 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 ...
1
vote
1answer
1k 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 ...
1
vote
1answer
3k 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()...
1
vote
2answers
3k 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 ...
5
votes
3answers
29k 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 ...
1
vote
2answers
293 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 ...
0
votes
1answer
297 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?
1
vote
1answer
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 ...
-4
votes
4answers
5k views

Making Video Games In pure Java, where to go? [closed]

I have been programming for about a year now, and have a very good grasp on all the basic of programming in generally and am a pretty decent Java programmer, so now that I have the time I would like ...
0
votes
1answer
117 views

Which Swing control should I use to render graphics with?

I'm using the Swing UI toolkit in Java, and I want to use the Graphics class to draw images and grids in a control. Which is the most appropriate control for this?
0
votes
5answers
1k views

Does Java support OpenGL by itself?

Note: This is long but I explaining everything that you need to know. Don't read half way through it and say "What's the question?". It's simple but long and I need help as soon as possible. So I ...
3
votes
1answer
925 views

Is jButton in Java suitable for a Game GUI?

Recently I have encountered the issue of trying to add a GUI into my game using Swing. The game will randomly & infrequently flash the jButton or Swing component when I add it to my jFrame. I'm ...
-1
votes
1answer
803 views

Animation Trouble with Java Swing Timer - Also, JFrame Will Not Exit_On_Close [closed]

So, I am using a Java Swing Timer because putting the animation code in a run() method of a Thread subclass caused an insane amount of flickering that is really a terrible experience for any video ...
1
vote
2answers
3k views

keyPressed is not working after adding ActionListener to JButton

I have a serious problem while trying to build a menu for my game. I've added two JButton to a main JPanel and added an ActionListener for each of them. The main JPanel also contains the game JPanel ...
0
votes
2answers
2k views

Rendering another screen on top of main game screen in fullscreen mode

my game runs in fullscreen mode and uses active rendering. The graphics are drawn on the fullscreen window in each game loop: ...