Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2007

Tip: Looking for answers? Try searching our database.

would someone care to hlp???

Thread view: 
beelzibub @ bawston school for idiots - 01 Jun 2007 17:54 GMT
... i know i should be using a lot more methods
but then they aren't declared? should i declare them in the main
so they are global???

k

/**
 *
 * @author kevin
 */
/**
 * @(#)BigFonts3
 *
 *
 * @Kevin
 * @version 1.30 2007/4/20
 */
import java.text.*;
import java.text.ParseException;

import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import java.awt.Font;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Calendar.*;
import java.util.Date.*;

import java.io.IOException;
import javax.swing.*;
import javax.swing.SpinnerDateModel;
import javax.swing.event.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import javax.swing.JSpinner.*;
import javax.swing.BorderFactory.*;
import javax.swing.border.EtchedBorder;
import javax.swing.border.Border;

abstract class BigFonts extends JComponent
        implements  MouseMotionListener, ActionListener,
        ChangeListener
{

 int newx = 125, newy = 95;

    public void paintComponent(Graphics g){
        String st = " Starting ...";
        g.drawString(st, newx, newy);
    }

//make draggable
    public void MouseDragged(MouseEvent e){

        newx=e.getX();
        newy=e.getY();
        repaint();
    }

    public static String doTime(String ts){

        String thetime;
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat tf = new SimpleDateFormat( "h:mm:ss a" ) ;
        thetime = tf.format(calendar.getTime());
        return thetime;
    }

    public static void addToBox(String thetime){

        // make text bigger for visually impaired friend
        Border raisedetched ;
        String alarmTime;
        Font big = new Font("Serif", Font.BOLD, 40);
        raisedetched = BorderFactory.createMatteBorder(5, 35, 10, 50,
Color.blue);
        JLabel msg = new JLabel("Time to go.");
        JButton thedisplay = new JButton(thetime);
        thedisplay.setFont(big);
        thedisplay.setSize(300, 200);
        thedisplay.setBackground(Color.blue);
        thedisplay.setBorder(raisedetched);

        // prepare alarm

        Calendar calendar = Calendar.getInstance();
        Date initDate = calendar.getTime();
        //calendar.add(Calendar.YEAR, -100);
        Date earliestDate = calendar.getTime();
        //calendar.add(Calendar.YEAR, 200);
        Date latestDate = calendar.getTime();
        SpinnerDateModel model = new SpinnerDateModel(initDate,
                             null,
                             null,
                             Calendar.SECOND);

       JSpinner alarm = new JSpinner(model);
       JSpinner setit = new JSpinner(model);
       setit.setSize(1,1);
       setit.setFont(big);
       alarm.setFont(big);
       alarm.setBorder(raisedetched);
       alarm.setFocusable(true);
       alarm.setEnabled(true);
       alarm.setEditor(new JSpinner.DateEditor(setit, "h:mm:ss  a"));

       alarm.setBackground(Color.blue);
       setit.setVisible(true);

        JFrame display = new JFrame("Set the Alarm.");
        display.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);;
        display.setLayout(new FlowLayout());
        display.add(thedisplay);
        display.pack();
        display.add(setit);
         display.pack();
        display.setSize(300, 200);
        display.setVisible(true);
    }

     // spinner action

     public void stateChanged(ChangeEvent evt){

   try {
       JSpinner alarm = (JSpinner) (evt.getSource());
       alarm.setEnabled(true);
       alarm.setFocusable(true);
       alarm.addChangeListener(this);
       alarm.setValue(alarm.getNextValue());
       alarm.commitEdit();
   }
   catch (ParseException pe) {
   }
       //alarm.setVisible(true);
}
    public static void setAlarm(){
    }

    public static void main(String[] args){

        JSpinner alarm = new JSpinner();

        boolean set;
        set = true;
        String st = " Starting ...";
        String theTime = " ";
        String theAlarm = " ";
        Thread t = new Thread();
        Calendar calendar = Calendar.getInstance();
        //setAlarm();
        t.start();
        try{
            for (;;) { // forever
                addToBox(doTime(st));
                t.sleep(1000);
            } // forever
        }catch (Exception e){}
            //{ who cares?)

    }

}
Signature

Sometimes I'm in a good mood.
Sometimes I'm in a bad mood.
When all my moods have cum to pass
i hope they bury me upside down
so the world can kiss me porcelain,
white, Irish bottom.

Hendrik Maryns - 01 Jun 2007 21:08 GMT
beelzibub @ bawston school for idiots schreef:
> ... i know i should be using a lot more methods
> but then they aren't declared? should i declare them in the main
> so they are global???

What is your problem?

Please read the link at the bottom and try asking your question again.

H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Oliver Wong - 04 Jun 2007 21:44 GMT
> ... i know i should be using a lot more methods
> but then they aren't declared? should i declare them in the main
[quoted text clipped - 50 lines]
>         g.drawString(st, newx, newy);
>     }
[snipped the rest of the code]

   I find it hard to believe that you are working with abstract classes,
Swing, inheritance, interfaces, etc. and yet do not know where you're
supposed to declare methods.

   If you really don't know where methods should be declared, you should
probably take a step back and read
http://java.sun.com/docs/books/tutorial/java/index.html

   - Oliver
Lew - 05 Jun 2007 03:08 GMT
"beelzibub @ bawston school for idiots"  wrote
>   Thread t = new Thread();
>   Calendar calendar = Calendar.getInstance();
[quoted text clipped - 7 lines]
>   }catch (Exception e){}
>         //{ who cares?)  // you should

This example looks familiar.

Your thread, t, does nothing.  It will open and stop immediately.  Basically,
thread t is dead by the time you get to the try{}.

t.sleep(1000) is a bad way to call sleep() because it has nothing to do with
Thread t.  It will cause the thread that created t, that is, the current
thread, to sleep.  Not t.  Besides, t will already be dead by the time you
call sleep().

Call sleep() the proper way:

Thread.sleep(1000);

<http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#sleep(long)>

Signature

Lew

a24900@googlemail.com - 05 Jun 2007 19:31 GMT
> This example looks familiar.

It is the "i'm not llloyd wood" guy who still tries to convince people
to do his homework. Since he is trying to contact you off-group I'd
like to suggest to be careful with personal information.
Jeremy - 06 Jun 2007 03:04 GMT
i'm lost. what 's going on?
>> This example looks familiar.
>
> It is the "i'm not llloyd wood" guy who still tries to convince people
> to do his homework. Since he is trying to contact you off-group I'd
> like to suggest to be careful with personal information.
Bluto Blutarsky - 20 Jun 2007 18:23 GMT
>> This example looks familiar.
>
> It is the "i'm not llloyd wood" guy who still tries to convince people
> to do his homework. Since he is trying to contact you off-group I'd
> like to suggest to be careful with personal information.

... i'm not in skool!

b

Signature

Sometimes I'm in a good mood.
Sometimes I'm in a bad mood.
When all my moods have cum to pass
i hope they bury me upside down
so the world can kiss me porcelain,
white, Irish bottom.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.