Im making a Uno card game in java as an application(not an applet), my first challenge is figuring out what layout
i will be using. I decided to use the Border layout, since it deals with the directions: North,South,East,West. This is the layout and the positioning as planned: player 1 (north,top of the screen),player 2(bottom, south of the screen),and deck of cards (east, side of screen).
this is where i have my problem, I want to display each Unocard as a JButton, so when i click it, it is played.....
when I use a boarder layout alone, the Jbuttons are too big, i need the buttons to be smaller individual buttons ... what can i do to change this.
Please be specific, im pretty much starting from ground zero, with the layout first.
Be specific please....
Examples or anything would help...:eek:
HEREs CODE:
_____________________________________________________
import javax.swing.*;
import javax.swing.JFrame;
import java.awt.*;
public class Layout {
public static void main(String [] args){
JFrame frame = new JFrame("UNo"); // sets JFrame to say UNO
frame.setSize(600 ,400 ); // set width and height of frame
frame.setLocationRelativeTo(null); // center it in middle
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
LayoutManager border = new BorderLayout(1,1); // border layout
frame.setLayout(border);
JButton button = new JButton("click"); // button text // Just a test
frame.add(button, BorderLayout.NORTH); // Jbutton is too big, need it be smaller
//for each button
frame.setVisible(true); //
}
}
Edited by ZekeDragon, 29 April 2011 - 10:24 AM.
Please use [CODE] tags (the # button) when posting code.


Sign In
Create Account

Back to top









