Analog Clock - How To Use Menu To Change Alarm Time

May 10, 2014

the analog clock dese not move put it work when i run the program and the the buttoms dose not work i do not why how i can use the menu alarm to change the alarm time this my code run it.

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.Timer;

[code]....

View Replies


ADVERTISEMENT

Creating Analog Clock Based On Certain Values

May 3, 2014

I'm working on a Java/Android program that takes a number input (for example, hour = 7 and minutes = 30 for 7:30AM), and then expresses it on an Analog clock. (hour hand pointing to 7 and minute hand pointing to 30 minutes) ...

How can this be done? Would I need a lot of image files? How to start ...

View Replies View Related

Swing/AWT/SWT :: Analog Clock Working But Seconds Repeating In Java

Oct 6, 2014

I made an Analog Clock and its working but when a remove the filloval (Background) the seconds hand keep repeating itself..here is the code

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JPanel;

[code]....

View Replies View Related

Elevator Simulation In Event Time Not Clock

Apr 10, 2014

I am making a elevator simulator for my class. It needs to be "event time". I am having trouble understanding how I can make an "event time" simulator. Initially I was using a while loop to run a clock time simulation of x seconds for each event, until I ran into a concrete wall and had to call another method which took X seconds, while still needing to execute code.

An example of what I did is:

Spawn person -> person.goToElevator (Takes x seconds) - > person.waitForElevator (Until elevator arrives, x seconds). While this is happening, I needed to create another person and do the same thing, this will add another to the queue if the first person is still waiting. Etc etc, you get the point.

We have not learnt about multi threading, that is the next assignment.

Here is a quote from my lecturer:

"That's right, it requires multi-threading which we're not doing in this paper. Here's a solution that can work:

The person waiting for the lift and then doing lots of other things should do all that in a fraction of a second. So, you don't let the person really wait. Instead, you will set a timestamp in the future in the person object that "he's busy till that time". In all other steps in your simulation you will first check if a person is "busy" (i.e. has a timestamp in the future). If so, you can't use this object, otherwise, you can.

How does it create a bigger queue? Outputs I would have in my final simulation would be, averageQueueLength, numOfPeopleInBuilding etc.

View Replies View Related

Countdown Clock - User Can Input The Time?

Nov 5, 2014

how can you add a feature where the user can input the time for the clock to countdown to?

View Replies View Related

Creating A Clock That Displays Different TIME In Different Capitals

Oct 16, 2014

As much as a clock and a calender have to do with date and time, a question arose.

I am creating a clock that displays different TIME in different captials.

Date timestamp = new Date();
timestamp.setTime(timestamp.getTime());
DateFormat time = new SimpleDateFormat("HH:mm:ss");
time.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(time.format(timestamp));

This code, returns the current time in UTC 00:00, the center of the time measuring system. And my program either ADDS an hour to the timestamp or deletes an hour, to make it earlier. My question is: Does Java account for Daylight Savings Time?

On that day, hours shift, and does java shift with them? Is there a changed need to make my code in order to not get the wrong results after the daylight savings time has hit?

View Replies View Related

Report Employee Time Clock Cannot Find Corresponding Dates In And Out

Mar 8, 2014

I have this assignment to build an employee time clock. By using a menu you can enter an employee, enter punch in and out, and report.When I created the punch screen I wrote the in and out records to a file. Because there can be several employees punching in or out the file wrote each occurrence on different lines. Now I am attempting to write the report which you enter an employee Id and loop through the file to find the in and out date and then calculate the time (hours worked). I loaded the file into an Arraylist but now I cannot figure out how to loop through find the In and Out date - calculate the hours worked and then move on to the next day. here is the format of the file - employee id, place holder I or O, date, time, day. and sample

111221111i3/2/145:10 PMSunday
111221111o3/2/145:10 PMSunday
111331111i3/2/145:25 PMSunday
111331111o3/3/1412:47 PMMonday
111221111i3/3/1412:48 PMMonday
111221111o3/3/142:23 PMMonday
111441111i3/4/141:30 PMTuesday

[code]....

here is my code from the main screen.

public static void displayPunches()
throws FileNotFoundException, IOException, ParseException {
boolean isValid = false;
String choice = "y";
String emp = Validator.getLine(sc, "Enter I -Individual or A -All ");
if (emp.equalsIgnoreCase("A"))

[code]....

View Replies View Related

How To Change Menu GUI With Buttons

Apr 23, 2014

I have a GUI with a menu to do various options. However I want to change that menu to use buttons instead. I'm working with JSwing components and I'm a little familiar with the JButton function, but I don't know how to convert the menu to a button. I think I'll have to remove the menu completely..anyway I tried to start with the file menu but the compiler says no suitable method found for setForeground(javax.swing.JMenu). Why is it giving me an error related to JMenu when I'm using Jbutton objects? Can I not use JButton objects inside a menubar scope? I'll bold the area it highlighted:

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

[Code]...

View Replies View Related

Construct And Populate Time Menu

Apr 23, 2014

//construct and populate the Time menu
Menu mnuTime = new Menu("Time", true);
mnuBar.add(mnuTime);
MenuItem mnuCurrentTime = new MenuItem("CurrentTime");
mnuTime.add(mnuCurrentTime);

[Code] ....

E:Calculator.java:64: error: cannot find symbol
if (arg == "Time")
^
symbol: variable arg
location: class Calculator
1 error

Tool completed with exit code 1

View Replies View Related

JSP :: Dynamic Menu Duplicates Every Time A Link Is Clicked

Jan 2, 2015

I have following code to populate a dynamic menu from categories retrieved from database

<jsp:useBean id="category" class="category.CatBean" scope="application"></jsp:useBean>

<c:if test="${applicationScope.cartList == null}">
<c:set var="catList" value="${category.categoryList}" scope="application"/>
</c:if>
<div id="categoryBrowse"><label>Browse by Category</label></div>
<div id="cssmenu">

[Code] ....

It works fine. But every time I click on a link on the menu, it duplicates the whole menu.

View Replies View Related

Allow User To Change And View State Of Credit Card With Menu Driven Program

Apr 20, 2015

I am new to OOP, i am not sure if this is the correct approach or not. Write a class named CreditCard that has (at least) the following member variables:

- name. A String that holds the card holder's name.
- cardNumber. A field that holds the credit card number.
- balance. A double that stores the current credit card balance.
- spendingLimit. A double that stores the spending limit of the card holder.
- Bonus: additional fields that you can think of.

In addition, the class should have the following member functions:

- Constructor. The constructor should accept the card holder's name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the spending limit to $2,000 and the balance to $0.
- Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's member variables.
- purchase. This function should add the amount specified as a parameter to the balance member variable each time it is called.
- increaseSpendingLimit. This function should add 500 to the spendingLimit member variable each time it is called.
- payBill. This function should reset the balance to 0.
- Input validation: Whenever a credit card number is modified, verify that it is of reasonable length.

Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.

View Card Information.

- Purchase an Item: ask the user the purchase amount and increase the card balance accordingly.
- Pay Bill: call payBill method to set the balance to 0.
- Increase Spending Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit function the appropriate number of times.

[CODE]

import java.io.*;
import java.util.Scanner;
public class CreditCard
{
Scanner input = new Scanner(System.in);
//data members
private String holderName;
private int cardNumber;
private int accountBalance;
private double spendingLimit;

[Code] ....

View Replies View Related

Cardlayout Format - Change Main Menu Screen Into Game Screen On Button Click

Mar 16, 2015

I'm making a game of checkers for my A2 Computing coursework which is due in within a week. I have completely finished the game, and only thing I have left to do is connect the two JPanels together via a CardLayout that I have made. However I am unsure how to do so

Here is the code from my CardLayout:

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JButton;

[Code] ....

I have kept the code I am displaying to a minimal, hence I have removed all the action listeners for my buttons, anyway the problem I have is that, I would like it so that when the user clicks on the 'Multiplayer' button which is the array button ourButtons[1], it will then transition into my main game screen so that the user can then play a game of checkers.

Here is the main important GUI from my CheckerBoard class:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
  public class CheckerBoard extends JPanel implements ActionListener, MouseListener {
// Main routine that opens an Applet that shows a CheckerBoard
public static void main(String[] args) {
new CLayout();
 
[Code] ....

Once again kept to a minimal.

View Replies View Related

Reading Json Of Nested Menu Without Giving Menu Names In Java

Aug 14, 2014

I want to read json file as follow;
 
{
  "M": {
  "row": [
  {
  "col1": "c00"
  },
  {
  "col1": "c10",
  "col2": "c11"
  },
  {
  "col1": "c20",
  "col2": "c21",
  "col3": "c22"
  }
  ]
  }
}
 
Next to reading I need to assign to two dimensional array, but without giving "col1","col2","col3" a lot. 

The array is for example, Array[3][] = {{"c00"},{"c10","c11"},{"c20","c21","c22"}};

View Replies View Related

Thread And Clock Management

Dec 19, 2014

I have objects (baddies in a game) that have individual clocks/counters assigned to them (when I make an object, I fill an integer based array list with a new digit entry at a value of one) that all happens in threads. then in another thread, I am checking the whole list of clocks, to see if any are equal to a wanted value , then I am taking an action and reseting the clock at that point on the array list.

now, the problem is:even though my code says " yes, I've taken that action because the value of array position x was >= specified value and I will now reset the clock" it doesn't reset the clock. Here is what it looks like

*these are excerpts taken from a really big program, however they should stand on their own as they are individual classes

Java Code:

public class levelclock extends Thread {
public void run() {
while (Run2 == true) {
if (Run == false) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();

[code]....

(Attached, just open up the zip and read the .txt)

View Replies View Related

How To Implement Clock / Timer In Java

Jun 10, 2015

How do I impliment a clock/timer in Java? The program saves files in memory for future use. I've included part of the program below I'd like to add a timer to check if the file was changed every 10 minutes. I have included part of the program below.
 
static FastDateFormat fastDateFormat = FastDateFormat.getInstance("MM/dd/yy HH:mm:ss"); 
  private static final class FileContentsObject {
  private long cachedTime; // currentTime
  private long lastModifiedTimestamp;
  private List<String> contents;

[Code] .....

View Replies View Related

Military Time - Adding Minutes Displaying Correct Time

Feb 9, 2015

I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)

I need the output time to be the time the class started, plus the length of the class, and displayed in military time.

for example,

Start Time = 0930
Length = 50 minutes
Endtime = 1020

I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say

Start time: 0700
Length = 90 minutes

I get:

Endtime = 90

90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.

Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.

public class calc
{
public static void main(String[] args) {
double hours, minutes, length;
double temp;
int time = 2400;
hours = time / 100;
System.out.println("Hours are: " + hours);

[Code] ....

View Replies View Related

Converting Military Time To Standard Time?

Jan 29, 2014

I have two classes. time_runner is used for testing my code.

This is what I'm using to test my code:
 
class time_runner
{
 public static void main(String str[]) throws IOException {
 Time time1 = new Time(14, 56);
System.out.println("time1: " + time1);
System.out.println("convert time1 to standard time: " + time1.convert());
System.out.println("time1: " + time1);
System.out.print("increment time1 five times: ");
time1.increment();

[code]....

The two constructors are "Time()", which is the default constructor that sets the time to 1200, and "Time(int h, int m)" Which says If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0. Those are my two constructors that I pretty much have down. The three methods however I'm having trouble with. The "String toString()" Returns the time as a String of length 4. The "String convert()" Returns the time as a String converted from military time to standard time. The "void increment()" Advances the time by one minute.

public class Time {
private int hour;
private int minute;
  public Time(int h, int m) {
if(h > 1 && h < 23)
hour = h;

[code]....

View Replies View Related

How To Create A Menu

May 12, 2014

I'm trying to create a GUI java application.

I want a menu with buttons that looks like this:

Button 1: Start
Button 2: Help
Button 3: About Me

If you press one of the buttons you will get to another frame with new buttons, new labels and so on.

Next step for instance if you press button 1, I'd like my program to get this frame:

Different alternatives, and a text field with a button. One commando leads to one new JFrame with new buttons, text fields and so on.

View Replies View Related

JSP :: DropDown Menu Does Not Work

Nov 17, 2014

I want to create a dropdown menu with contents from a database. You can see my Code in the attachment. It does not work, but why? I have a dropdown-symbol, but no contents.

View Replies View Related

Cannot Display Menu Using Derby

Apr 15, 2014

ok so I am trying to create a movie rental database. I want to show a list of movies, customers, and rentals. my problem is that I cant run everything but I keep getting the following error :

ERROR: Table/View 'MOVIES' does not exist.

Here is my code

import java.sql.*;
import java.util.Scanner;
public class MovieRentalDB
{
public static void main(String[] args)

[code]....

the program runs but I keep getting that error. I know my code is also not complete but I will do the rest once I figure out why my tables are not creating

View Replies View Related

Using A Menu For Stack Operations

Dec 3, 2014

I am working on implementing a stack using a linked list. Programming the stack operations (push, pop, isEmpty, etc.) was easy but my directions were to provide the user with a menu to choose the operation that he/she wishes to perform. I am new to JFrames/Menus so how to make the stack operations available in a menu.

View Replies View Related

JSP :: Selected Drop Down Menu?

Nov 8, 2014

I am making an edit page and I want to populate my drop down menu with things that were already selected. For example, if i want i click to edit my favorite food it will be populated with the one the user previously selected. How do i go about doing this? [URL] ....

View Replies View Related

Creating A Menu For Grades

Sep 29, 2014

I have an assignment that I need to create a menu like this using only arrays.

Main Menu:

1. Input how many students.
2. Input names and grades
3. Print name and grades.
4. Exit

I dont know how to do them in array.

View Replies View Related

Swing/AWT/SWT :: Popup Menu Add In Jlsit?

Apr 8, 2015

package newdb;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

[code]....

i want to popup menu add in jlist and select file than open and save through context menu. but popup menu show on frame not in list .

View Replies View Related

Changing Items On The Main Mac Menu

Apr 17, 2014

How would I change items in the main menu (top of screen) that has the app's name on it (e.g. Firefox)? I've used :

System.setProperty("apple.laf.useScreenMenuBar", "true");

And it works, but how would I change things like "About [thisapp]" and make it execute a certain method?

View Replies View Related

Using Java Arraylist With Menu Method

Apr 12, 2015

2 problems with this code:

How do I code this so that after the user has added to the arraylist 'theFruit' if they then press 'V' to view all fruit it includes the default fruit as well as the fruit they've added?

Also in the method 'AddFruit' it only allows me to add 2 fruit before printing. Why is this?

import java.util.ArrayList;
import java.util.Scanner;
public class StkOv {
public static void main(String[] args) {
TheMenu();

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved