Game « Development « Java Swing Q&A





1. Java game questions    stackoverflow.com

I am developing a simple multiplayer 2d game of pacman in java for my assignment at university and I want to be able to draw stuff onto this window as well ...

2. Tips regarding how to create an Java Solitaire game    stackoverflow.com

I got some question regarding the approach to create an solitaire game in java. What is the best way of handling the cards in Swing? How can I drag them, and what ...

3. Custom Swing look and feel vs. custom components?    stackoverflow.com

I'm writing a game using Swing and want to achieve a distinctive "steampunk" inspired look for the GUI. This will require some animated components, chunky metallic borders etc. I know that I ...

4. java guess the number game    stackoverflow.com

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

public class guess extends JFrame implements ActionListener
{
    JLabel title = new JLabel ("SAMPLE 1");
    JTextField txt1 = new JTextField (10);
  ...

5. Does this game have a solution    stackoverflow.com

I am developing a simple game using Java swing. I want to know whether this particular game has a solution in the following scenario. If I am convinced that theoretically a ...

6. Making Grids for a Java Battleship game    stackoverflow.com

I'm having a little trouble building the grids for a Battleship game for my Java class. So far, I can easily make a for loop to add JPanel or JButton objects ...

7. Java Hangman Game    stackoverflow.com

Hi I've been making a hangman game in Java over ther holidays. Im almost done, but i'm having a few problems with repainting/updating the window. So when ever a life is lost, ...

8. issue with my main method in my connect4 game    stackoverflow.com

Im having a problem with my main method, whenevr I run it my code cant compile because of this problem : "Exception in thread "main" java.lang.NullPointerException at UI.ConnectFourFrame.refreshUI(ConnectFourFrame.java:96) ...

9. Creating a Interactive GUI for a java game    stackoverflow.com

Hey guys I'm creating a game similar to farmville in java and I'm just wondering how would I implement the interactive objects/buttons that the user would usually click to interact with ...





10. Issue with Game of Life    stackoverflow.com

I'm working on a Java implementation of Conway's game of life as a personal project for myself. So far it works but the rules are coming out wrong. The expected patterns ...

11. Game Canvus    coderanch.com

12. Beginner game    coderanch.com

To do animation, you are going to need to have a component to draw the animation on, like a JPanel if you are doing this in Swing, or a Canvas if you're using AWT. Override the paintComponent() method of the JPanel, or the paint() method of the canvas and do all your drawing in this method. You also need a thread ...

13. Game!    coderanch.com

WHEN are you creating that object? If it happens the first time an explosion is to take place it may be too late, if so consider creating it during program initialisation. You may also consider preloading the actual image data to a shadow area of video memory. That's how it's done in DirectX native programs, I don't know how you'd accomplish ...

14. Game GUI    coderanch.com

hello i have been trying to layout this game from a picture i have had an attempt and my gui has turned out like this lol I have used a border layout and in the center i have put a gridlayout for each indivdual dice object, using a loop i have entered 24 dice into a 6,4 grid. in the east ...

15. My Games Flashing!!    coderanch.com

I decided to get rid of the flashing in my game by double buffering it. Now there isn't any flshing but... the objects are being repainted and then not being taken away from the applet when they move creating a line where there is suppose to be a ball bouncing up and down. If somebody can help me with this it ...

16. Retrieving tooltiptext from a game....    coderanch.com

i have an application where... the mouse moves around randomly in an 800X600 space. and everytime it moves, it clicks... so it moves and clicks every 6 seconds... and every.... 4 min, it presses F1. now what i want to do is get the cursor to actually look for an object by using the tooltiptext above the object to determine rather ...





17. simon game    coderanch.com

I have to make a simon game. I have all the buttons and things made and I am pretty sure I have the timer made. The thing that I am hung on is that I have to show the sequence of colors in the center square. I have an arraylist that I basicly want to print there a element at a ...

18. warhammer 40k game(some bartender please move this to game forum)    coderanch.com

There are a lot of ways to put these kind of things together. Here's an idea to help you get started. class Pseudo extends JPanel { BufferedImage image; // Switch this on in your button ActionListener // and off in this components MouseListener. boolean followMouse = false; Point loc = new Point(); Pseudo(BufferedImage image) { this.image = image; addMouseListener(...); addMouseMotionListener(...); } ...

19. Game Lobby    coderanch.com

Hi, I'm trying to create a game lobby similar to those you see at yahoo or other game sites. It would be a collection of tables with each table containing among other things, the name of the game and a button to sit, if seats are available, for each available seat(different games may have a different number of total seats). I ...

20. X and O game    coderanch.com

The logic seems correct to me, but for some reason the program does not want to funtion properly, could you take a look at the program and give me some input, and I have a few variables not used in the program, even though they are defined because this is the part I need done in order to use those variables. ...

21. GUI for Mastermind Game - Question    coderanch.com

Hey all, So I created a text-based version of the game mastermind. If you are not familiar with it, here is a link to a pre-existing java game: http://www.irt.org/games/js/mind/ What I want to do now, is to develop a GUI for it. So I downloaded NetBeans, and created a UI for it. Before I start what I believe will be a ...

22. GUI and code in a simple game    coderanch.com

Ok, I am keeping the main method simple to just kick off the process in a simple game I am creating. I am calling a create GUI method with a button that starts a new game. When the button is clicked the start game method is called and the 2 players have their scores reset to 0 and the names are ...

23. Using swing for board game.    coderanch.com

hi. I am making an old traditional board game played on a standard 64 squares square board. The game is not so well known (yet ! ;o) but my question is about strategy for inputting moves. I have made japplet with 64 jbuttons in square. what is a good strategy for captuaring square location ? I am thinking of making my ...

24. GUI number guessing game program    coderanch.com

Ok, so here's the issue. I can compile and run it fine, but when I load the game, it will only take one guess and will let me go no further. In other words, it asks for my guess and I enter say "45", and it says "Too high." Well, I enter another number, but then it won't go anywhere. Can ...

25. which platform is good to do games .    coderanch.com

dear friends , this is naveen .i am working in game project .i have finished my hangman game in java swing using netbeans. but it is not working when i posted that in to the server.i.e i posted jar file in to my server when i call my jar file through jsp from client side my jar file is opening in ...

26. Checkers game.    coderanch.com

Hi, I am creating a checkers/draughts game in swing and am a bit unsure about whether to use MVC or not in the design. This is a project for college and the main focus of it is the algorithms that decide on the next move for the computer, not the UI. There will be a main JPanel onto which the board ...

27. Game simple on Java    coderanch.com

28. sample of guess high and low game    java-forums.org

29. SUDOKU game problem    java-forums.org

Hello I am trying to program an online sudoku game, and the layout of the game is a grid of 9x9 JTextFields. So, I'm arranging these 81 Fields in a panel, however, I need to have some sort of line between each 3x3 block. If anyone has ever played sudoku, you'd know what I mean. Any ideas how to create these ...

30. Help with a dice game.    java-forums.org

import java.util.Random; import java.util.Scanner; public class Dice { public static void main(String args[]){ Scanner input = new Scanner(System.in); int money=400; int offer; int bet; while(money>0 || money>1000){ System.out.println("Your have got "+money+" dollars."); System.out.println("Place your Bet."); offer = input.nextInt(); money = money - offer; System.out.println("Guess wich number the dice will show."); bet = input.nextInt(); Random dice = new Random(); int roll; roll ...

31. guessing game help    java-forums.org

32. need help with a simple game im making    java-forums.org

I am making a game that is similar to a game called ''tiger kycklingstuds'' from the site extrude.se, But more simple. My problem is that it works fine when I only use one ball in the air, but i can't figure out how to put in several balls like in the game that i mentioned. I appreciate if you could help ...

33. Trying to make a functioning Tetris game/ why does my board look weird?    java-forums.org

Hi all. For the final project in my introductory comp sci course, I've been instructed to recreate Tetris in java. I have been having some difficulties getting the board to display properly--the board that shows up on the screen has too many cells (in the paintComponent method of GameBoardPanel, change fillRect to drawRect and you'll see what I mean), and when ...

34. Brick breaker game Code    java-forums.org

35. Help in bow and arrow game    java-forums.org

i have made this program for bow and arrow games. But my problem is, that i am able to shoot only 1 arrow. I want to shoot as much as arrows as i want. wat should i do.... and also, there is lot of flickering, how should i reduce it ??? Java Code: package BowAndArrow; import java.applet.Applet; import java.awt.*; import java.awt.event.*; ...

36. My java game problem!? Help!!!    java-forums.org

Hello, i am haveing a problem with my game, i am trying to move a square around the screen named sci.jpg the problem i am haveing, is i cant get it to show up. i am not sure, but i do think its something wrong with my Board object's paint class, because i can not get anything to show up by ...

37. I need help with my game    java-forums.org

public class GamePanel extends JPanel implements ActionListener { private JTextField textField; private JTextArea textArea; private String longLocation; private String shortLocation; private Game game; private GameMap map; public GamePanel() { super(new GridBagLayout()); game = new Game(); textField = new JTextField(20); textField.addActionListener(this); textArea = new JTextArea(2, 10); textArea.setText(game.printWelcome()); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill ...

38. Roll 2-Dice "Pig" Game Help    java-forums.org

Alright, been working on this game for quite a while, and couple things just cant get straight. MyApp.java import java.awt.*; import javax.swing.*; import java.awt.event.*; public class MyApp extends JFrame { private JLabel _aLabel, _comp, _comproll, _comptotal; private JLabel _user, _userroll, _usertotal; private JPanel _buttonPanel, _labelPanel1, _labelPanel2, _diePanel; private JButton roll; private JButton pass; private Die _leftDie; // component for one die ...

39. game    java-forums.org

40. guessing game using GUI    java-forums.org

Hello i am trying to create a guessing but using GUI. below i have first created a J Frame with a panel and a button that says to "click me", this works fine, after action listener, i then create a second frame and within that frame i have three button, 'click high'. 'click low', 'correct', (if guess is correct). But i ...

41. Help with setting up a GUI for a Rock, Paper, Scissors game    java-forums.org

Hello, I wanted to know if I could get some assistance on getting started with setting up a game simulation of rock paper scissors. I am stuck setting up the GUI part of this. I'm really not sure what to import for this or what part of the GUI is the JPanel, JFrame, etc. I didnt know how to show the ...

42. guess game GUI    java-forums.org

I'm sure you guys have seen this a thousand times but I cannot find the answer anywhere. I am doing the guess game / high low game for a class and we need to be able to have the user enter a number and based on their number, changed the background color of the JFrame to red or blue depending on ...

43. coverting console game to GUI    java-forums.org

coverting console game to GUI Hi there, I am fairly new to Java (started learning it this August) and I have an assignment that I do not know how to approach. One of my first assignments was to create a simple console game and now I have been asked to convert this console game into game with that the ...

44. Creating Tic Tac Toe GUI game.    forums.oracle.com

/*Display X's or O's on the buttons*/ if(e.getSource() == button1){ button1.setIcon(); button1.setEnabled(false); } else if(e.getSource() == button2){ button2.setIcon(); button2.setEnabled(false); } else if(e.getSource() == button3){ button3.setIcon(); button3.setEnabled(false); } else if(e.getSource() == button4){ button4.setIcon(); button4.setEnabled(false); } else if(e.getSource() == button5){ button5.setIcon(); button5.setEnabled(false); } else if(e.getSource() == button6){ button6.setIcon(); button6.setEnabled(false); } else if(e.getSource() == button7){ button7.setIcon(); button7.setEnabled(false); } else if(e.getSource() == button8){ button8.setIcon(); button8.setEnabled(false); ...

45. Building a GUI for game project    forums.oracle.com

hi, for my uni project i need to build a game of snake, so far my lectures has taught me how to make programs that run with the command line but for this i need to create a GUI, it needs to be a 101 x 101 grid, can anyone please show me how to build one in a very simple ...

46. Connecting my GUI class to my Game class    forums.oracle.com

Hi guys I build my GUI with netBeans 6.0 and I used a seperate source package for my number game and for my GUI. Now I know I have to make one of the main classes extending an Action Listener but I don't know which one the main class of the game or the main class of the GUI. And is ...

47. java swing game neighbor recurive search help    forums.oracle.com

48. GUI for Poker game?    forums.oracle.com

I'm trying to do the GUI part of the Poker texas hold em, however, 1. For the table, is it correct to insert a still image as a background then let everything taking place on top of it? 2. I don't know how to insert a picture into a JFrame/JPanel using NetBeans? 3. I don't know how to do the GUI ...

49. I'm writing a mazerace game...I need help from a Java Pro regarding GUI    forums.oracle.com

/** * This class is responsible for: * -Initializes instance variables used to store the current state of the game * -When a player moves it checks if the move is legal * and updates the state of the game if move is allowable and made * -Reports information about current state of the game when asked: * o whether game ...