Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 9th, 2004, 06:33 AM
Registered User
Join Date: Jun 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default layout

Hi, this is probably fairly simple but im only just beginning to program graphics in java. What I need is for the setPanel, which holds the setClockButton, to be underneath what the paint method produces. Anyone now how I can achieve this.

import java.awt.*;
import java.awt.event.*;
public class DisplayClockTime extends Panel implements ActionListener
    private static int r = 65;
    private int x = 150;
    private int y = 150;
    private int minX, minY, hourX, hourY;
    private boolean timeSet;
    private Label hourLabel = new Label("Hour");
    private TextField hourField = new TextField(2);
    private Label minsLabel = new Label("Mins");
    private TextField minsField = new TextField(2);
    private Button setClockButton = new Button("Set clock");
    public Panel holdAll = new Panel();
    private Panel timePanel = new Panel();
    private Panel setPanel = new Panel();

    public DisplayClockTime(){
        holdAll.setLayout(new BorderLayout());




        timeSet = false;


    public void paint(Graphics g){
        if(timeSet == true){

    public void actionPerformed(ActionEvent e){
        String hourEntered = hourField.getText();
        String minsEntered = minsField.getText();
        int minsIn, hourIn;
        double theta;

        if(e.getSource() == setClockButton){
            minsIn = (int)Double.parseDouble(minsEntered);
            hourIn = (int)Double.parseDouble(hourEntered);

            theta = 2 * Math.PI * minsIn/60;
            minX = x + (int)(r * 0.9 * Math.sin(theta));
            minY = y - (int)(r * 0.9 * Math.cos(theta));

            theta = 2 * Math.PI * (hourIn + minsIn/60.0)/12.0;
            hourX = x + (int)(r * 0.65 * Math.sin(theta));
            hourY = y - (int)(r * 0.65 * Math.cos(theta));

            timeSet = true;

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
3 column layout acevision7 BOOK: Professional CSS: Cascading Style Sheets for Web Design 0 February 24th, 2008 11:13 PM
CSS Layout DeadMeatGF CSS Cascading Style Sheets 2 November 5th, 2005 03:23 PM
3 Row Layout simrud CSS Cascading Style Sheets 3 August 1st, 2005 06:47 PM
Datalist layout silverfox_1188 ASP.NET 1.0 and 1.1 Professional 2 May 13th, 2005 05:43 AM
datalist layout silverfox_1188 Classic ASP Components 0 May 11th, 2005 04:16 PM

All times are GMT -4. The time now is 01:07 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.