LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2010, 03:42 AM   #1
wch705
LQ Newbie
 
Registered: Jul 2010
Location: Australia
Distribution: Debian
Posts: 23

Rep: Reputation: 0
Basic Java GUI problem


hi guys, i am new to java and trying hard to leanring JAVA GUI.
I got an exercise to construct a picture as attached.
The basic thinking is i draw all graphics, button, label in a JPanel, and display it in a JFrame. And the result is all graphics are perfect, except the button and label, it got duplicated(when doing maxmising and minimising) and how can i put them at the bottom.
can anyone give a help?
Thank you.
Attached Thumbnails
Click image for larger version

Name:	drawgraphics.GIF
Views:	13
Size:	11.6 KB
ID:	4386  
Attached Files
File Type: txt DrawGraphicsTest.txt (1.3 KB, 15 views)
 
Old 08-23-2010, 09:27 AM   #2
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
You can position buttons by using a LayoutManager and adding a second Jpanel to hold the buttons. Consult the docs for details: java.awt.BorderLayout.
 
Old 08-23-2010, 10:25 AM   #3
suprstar
Member
 
Registered: Aug 2010
Location: Atlanta
Distribution: ubuntu, debian
Posts: 142
Blog Entries: 2

Rep: Reputation: 23
Or setLayout(null); and handle it yourself. Make your panel implement ComponentAdapter and put this in your class:

componentResized(ComponentEvent e) {
//draw all your stuff

//place button at bottom of screen centered horizontally:
myButton.setBounds(getWidth()/2-myButton.getWidth()/2,getHeigth()-myButton.getHeight());
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java: How to define paint into a certain panel java GUI mitchell7man Programming 2 04-22-2010 01:18 AM
Java GUI and repaint() problem Cyhaxor Programming 4 03-05-2009 06:51 PM
Basic Linux (hopefully with GUI) PastorWirl Linux - Newbie 11 11-07-2006 12:29 PM
a basic problem in java and linux qyzlp Programming 15 04-17-2005 03:53 AM
edonkey java gui not finding java Sephiroth Linux - Software 0 03-13-2004 08:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration