• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Code to generate a Grid Test GUI

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am completely at a loss for this and need an answer asap.
I need to know the code to generate a GUI with the number from 1 to 12 with each number in a seperate section.
And if anyone knows how to cod the numbers 1 to 4 in a pannel i would be greatly apricative.
I need this info very badly and very quickly i do not know where to look and i need the code to generate this. Any help on either of these topics and you would be a life saver
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

Have you worked with Swing GUI programs at all? Here's a Sun tutorial to get you going: http://java.sun.com/docs/books/tutorial/uiswing/ You might be looking for a GridBagLayout once you're comforatable with making GUI programs.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

First, let me point out our policy on display names which requires that you use a real-sounding first and last name. Single names and "handles" aren't acceptable. You can change your display name here. THanks for your immediate attention.

Second: we've got a forum for Swing and AWT questions like yours; I'm going to move this post as well as your "advanced" one to that forum where they will be on-topic.
 
Mike Jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Name changed and thank you.
I know that it is a big ask but if anyone could supply me with code as i am short of time i would be greatfull.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
start by creating a JFrame
create a JPanel
set the JPanel's layout manager to a GridLayout(ROWS,COLUMNS)
in a for loop (where x = 0; x < ROWS*COLUMNS)
{
create a JLabel
set the JLabel's text to x (or x+1, if 1-based)
add the JLabel to the JPanel
}
add the JPanel to the JFrame
JFrame.pack()
JFrame.setVisible(true)

should just about do it.
if you run into problems, Stan's link earlier will have all the answers
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!