Simulate Press Of Space Button Every 15 Minutes
Jul 1, 2014I'm on windows 8 and I want to use notepad or notepad++ to simulate the press of the space bar every 15 minutes so my computer doesn't auto lock.
View RepliesI'm on windows 8 and I want to use notepad or notepad++ to simulate the press of the space bar every 15 minutes so my computer doesn't auto lock.
View RepliesI have been reading some java guides here [URL] .... and was trying to put a bit of what I have learnt into practice but am having some difficulty. Basically, using netbeans IDE I have created a new jFrameform so that I can place swing components in design mode. What I want to create isnt overly complicated but I just cant seem to get it. In design I have simply added a panel and a button. When I press the button I want to display an image I have located at:
/resources/images/numbers/1.png.
This is my code so far (most of it has been automatically generated from me adding things via design mode:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
[Code] ....
I assume I need something like below somewhere , do i need to create a draw method? if so how do I call it as it is expecting graphics2d as a parameter, what would I pass into it?
BufferedImage img = null;
try {
img = ImageIO.read(new File("/resources/images/numbers/1.png"));
} catch (IOException e) {
}
I am trying to do a program about a contact agenda, now, I have one JPanel that contains three sub panels (GridLayout(1,3)) where I have in the left the picture of the Contact, the middle one is not important, but the right one contains 4 JTextFields with information of the contact and one JCheckBox that indicates if the contact is a favorite or not. The thing is that I am only able to show the first contact, but I want to be able to scroll between the contacts with a Button that I have in another panel. I think I am actually scrolling among the contacts, but the panel with the information from the contact is not updating the information...
public class PanelInfoContacto extends JPanel{
// -----------------------------------------------------------------
// Constructores
// -----------------------------------------------------------------
/**
* Construye el panel. <br/>
* @param contacto - es una referencia al contacto que muestra. contacto != null.
*/
public PanelInfoContacto(Contacto contacto){
setLayout(new GridLayout(1,3));
[Code] .....
I am newbie in java and little bit known to apex. I write an java code and compile it to class file. Now i want to call that class file from an push of button on apex. When button is pushed i need some arguments to be password to java class files . For arguments i need to take the item value from the apex page.
But i stuck on how to call that java class file from apex. On command prompt when i ran java class file, its working.
I need to write a simple program that reads an amount of minutes and displays the approximate number of years and days for the minutes. For simplicity, assume a year has 365 days and the resulting amount of days is a whole number.
View Replies View RelatedI'm fairly new to JSTL. Can I convert the minutes JSTL expression into hours and minutes using a java method. I'm not sure how to go about.
<% CalendarUtilities.getHoursAndMinutes(%> ${minutes} <% ) %>
I have a filechooser that works how it should and if anyone enters anything with a dot that isnt .xml it shows an invalid file name message. However when I dont choose a file and press cancel it still says that because when my boolean hits false it's the first thing it hits in that section of code.
if(!writeSuccess)
{
//display output messages in JOptionPane
JOptionPane.showMessageDialog(null,"Error, file name invalid", "Error", JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null,"Export successful", "Success", JOptionPane.INFORMATION_MESSAGE);
//close the form
me.dispose();
}
If I want it to just close down without it saying anything is there sort of if statement I could do that would prevent this? But if it is an invalid file name it will still show that message?
I have four buttons with different names and depending on which button is pressed I want to change the label to be displayed. Center is the name of the label the other directions are buttons. The label should change if a different button is pressed. The error I get is that it cannot be converted to String.
public void actionPerformed(ActionEvent event){
Object source = event.getSource();
if (source == east){
center.setText(east);
}
if (source == west){
center.setText(west);
[code]...
Java Code:
package --.-----.game;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.List;
public class InputHandler implements KeyListener{
public InputHandler(Game game) {
game.addKeyListener(this);
[Code] ....
I'm trying to figure out why this doesn't print "This works" if I press or release anything. It just ignores the keys that I press.
Does this class look right?
I show a JDialog window and this window has 3 buttons when I press one of them it should close the window, how do I do that?
View Replies View Relatedi want to make a piece of software that enables me to Press a key on my keyboard and then it will play a Sound. But i Want to be able to do it when i'm playing.Can code The Sound an Keys
View Replies View RelatedWrite a method called statistic that simulates the rolling of two dice 1000 times. (1000 times is a parameter of the method statistic).The program should have no input, and should use pseudo random numbers to simulate the rolls (one random number per die). Store the sum resulting from each roll of two dice, determine the number of times each 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, and 12 was rolled. The out produced by the program is:
Sum 2 3 4 5 6 7 8 9 10 11 12
Total 33 49 93 103 127 159 150 124 85 49 28
This is my code:
public static void main(String[] args) {
statistic(1000);
}
public static void statistic(int number) {
Random randomNumbers = new Random();
[code]...
i have been trying for hours to make it look like the output above but no luck. I was wondering if there's any other way writing the code without using arrays.
Suppose that a certain airport has one runway, that each airplane takes LandingTime minutes to land and TakeOffTime minutes to take off, and that on the average, TakeOffTime planes take off and LandingTime planes land each hour.
Assume that the planes arrive at random instants of time. (Delays make the assumption to randomness quite reasonable.) There are 2 types of queues: a queue of airplanes waiting to land and a queue of airplanes waiting go take off. Because it is more expensive to keep a plane airborne than to have one waiting on the ground, we assume that the airplanes in the landing queue have priority over those in the take off queue.
Write a program to simulate this airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate two random numbers: If the first in less than LandingTime /60, a "landing arrival" has occurred and is added to the landing queue, and if the second is less than TakeOffTime /60, a "takeoff arrival" has occurred and is added to the takeoff queue. Next, check whether the runway is free. If it is, first check whether the landing queue is nonempty, and if so, allow the first plane to land; otherwise, consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue. You might also investigate the effect of varying arrival and departure rates to simulate the prime and slack times of day, or what happens if the amount of time to land or takeoff is increased or decreased.
My Queue Interface: [URL] ....
My Queue Implementation: [URL] ....
My Demo (Main Method) Program: [URL] ....
Right now, I'm struggling with the demo program. I wrote some pseudocode in which I tried to match what the instructions were asking:
for(each minute) {
rand1 = generator.nextInt();
rand2 = generator.nextInt();
if(rand1 < LANDING_RATE / 60)
Add to the landing queue
if(rand2 < TAKE_OFF_RATE/60)
[Code] .....
Firstly, exactly how many minutes am I supposed to be doing this for? The assignment gave me a variable called final int ITERATIONS = 1440 , could that have something to do with how long I loop? Secondly, what exactly do I add to the queue if the conditions are true. For example, if rand1 < LANDING_RATE/60, what would I enqueue to the landingQueue? Thirdly, how am I supposed to check if the runway is free? Does that mean check to see whether the takeOffQueue is empty or not? Fourth, would allowing the first plane to land mean removing an item from the landingQueue? Also, what does it mean by "otherwise, consider the takeoff queue". Does that mean if the landingQueue is empty, I should start removing items from the takeOff queue?
The biggest problem is the fact that I have to calculate the average queue length and average time that an airplane spends in a queue.
I wanted to try out using a KeyListener to read what key I press so it can paint a circle in my frame, but I can't get it to work?
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Random;
[Code] ....
*Write a program to simulate this airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate two random numbers: If the first in less than LandingTime /60, a "landing arrival" has occurred and is added to the landing queue, and if the second is less than TakeOffTime /60, a "takeoff arrival" has occurred and is added to the takeoff queue*.
*Next, check whether the runway is free. If it is, first check whether the landing queue is nonempty, and if so, allow the first plane to land; otherwise, consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue.*
I have most of the code done as you can see below:
* Queue Interface: Queue.java
* Queue Implementation: ArrayQueue.java
* Demo Program: Airport.java
Right now, I am stuck on the first calculation which is trying to figure out the average size of the landing queue. For some reason, as you can see at the bottom of my demo program, the average always comes out to be 0.0 and I'm not sure what's wrong.
Secondly, how to calculate the average time a plane stays inside a queue for. Write a program to simulate this airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate two random numbers: If the first in less than LandingTime /60, a "landing arrival" has occurred and is added to the landing queue, and if the second is less than TakeOffTime /60, a "takeoff arrival" has occurred and is added to the takeoff queue.
Next, check whether the runway is free. If it is, first check whether the landing queue is nonempty, and if so, allow the first plane to land; otherwise, consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue.
I have most of the code done as you can see below:
* Queue Interface: Queue.java
* Queue Implementation: ArrayQueue.java
* Demo Program: Airport.java
Right now, I am stuck on the first calculation which is trying to figure out the average size of the landing queue. For some reason, as you can see at the bottom of my demo program, the average always comes out to be 0.0 and I'm not sure what's wrong.
Secondly, how to calculate the average time a plane stays inside a queue for.
I have designed an applet to simulate a stack (last-in, first-out) of strings. The applet consists of:
Two JButtons
Two JTextFields
Two JLabels
A TextArea
The user enters text in the first text field then clicks the push button and it goes in the textArea. After entering several strings the user can click the pop button and the top string goes into the second text field. I am a total newbie and am stuck. I can get a string of text to push to the textArea and then pop it out; however I can't stack them LIFO. Most examples I've seen use integers and I'm not sure how to translate the concept to strings. I'm just not sure how the stack concept works even though I read the API webpage.
My code
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JApplet;
import javax.swing.JButton;
[Code] ....
my assignment is to code a program to simulate the rolling of 2 dice. I have most of it set but when I run it and have it print out how many times each number (2-12) was rolled, it displays the numbers 1 off. for instance it will display the number of 4s rolled next to the 5s.
here it is
import java.util.Scanner; //allows info to be inputted//
import java.util.Random; //opens random number generator//
public class RollTheDiceWithArray13
{
public static void main(String[] args)
[code]....
Write a program to simulate the rolling of two dice. The program should use Math.random (google how to use Math.random if needed) to roll the first die and should use Math.random again to roll the second die. The sum of the two values should then be calculated your program should roll 50,000 times. Use a single dimensional array to tally the numbers of times each possible sum appear(the possible values are 2 through 12, think about why?). Print the results in a tabular format.
Here's the code I'm working on so far:
public class RollingDice{
public static void main(String[] args){
int die1;
int die2;
int roll;
die1 = (int)(Math.random()*6) + 1;
die2 = (int)(Math.random()*6) + 1;
roll = die1 + die2;
System.out.println("The roll of the first dice is: " + die1);
System.out.println("The roll of the second dice is: " + die2);
System.out.println("Your total roll is: " + roll);
}
}
What am I missing at this point, and what parts did I do wrong to change it?
I need to create and simulate an ATM interface for my computer programming class using scanner class, if else & switch statements. I've been working on this assignment all day and I'm still no closer to figuring out how to do it. I'm currently working in NetBeans to try and solve it. I have attached the pdf , what I need to do. This is what I have so far:
package bankatmifelse;
//Gator Bank ATM Program
import java.util.Scanner;
public class BankATMIfElse {
[code]...
import java.util.Random;
/**
* A very basic Dice that can be rolled and represent int values
*/
public class Dice{
private Random rand;
public Dice(){
rand=new Random();
}
/**simulates rolling the dice*/
[Code] ....
Why the Random rand is initiated at the Constructor and not at roll? Like the code works for both but I remember our teacher telling us something about one uses more memory than the other.
Write a program to simulate the operation of a simple robot. The robot moves in four directions: Forward, backwawrd, left, and right. The job of the robot is to move items and place it in the right slots in each station. There are 8 stations plus the pickup station. Pick up station is the initial start where the robot picks the items. 8 items can be placed on each station. The nearest station must be filled before placing items on the next station. The items are marked with identification or serial numbers. The items with odd serial number go to the right and items with even number go to the eft. The last slot, number 7 is reserved for light items which are less than 80kg. The serial number is a five digit number, the MSB digit 5 indicates that the product must be placed in the fifth station which is keeping the product at 20 degree F.
View Replies View RelatedI have a timer where it counts down from 300 to 0 then does something. But I want the display for the clock to show the time in minutes. I tried:
double showTimeLeft = timeLeft / 60;
o.setDisplay(String.format("%.2f", showTimeLeft) + " Minutes");
But Every so many seconds it skips like:
Time = 3.38
Time = 3.37
Time = 3.35
Time = 3.34
It skipped 3.56
How to do this right?
I have a servlet with a method:
/**
* @return <code>double</code> Hours
*/
public double getDriveHours() {
return getAsDouble("DriveTime", 0.0D);
}
I would like to change the time to minutes. I will create a new entry in the db for the minutes, but wondered if the time minutes is also double.
I have a web application where the server has to write the excel document to the output stream.It takes more than 5 minutes for the server to write it.After 5 minutes i get a '504 gateway timeout' error code. I have tried setting the timeout values in the web container in Admin Console.Still the same problem.I followed this link.
[URL] ....
I even tried setting the ConnectionKeepAliveTimeout and ConnectionIOTimeOut values. But still didn't work. How do i increase the timeout value?
I have this code for a Countdown Timer...
Java Code:
package javaproject;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Countdown.Timer;
import java.util.Timer;
import javaproject.Countdown;
public class Minutes {
[Code] ....
Do I need to put more code in the Countdown class or in the Minutes Class...
How can i write a java program that simulate a simple calculator that performs the basic arithmetic operations of JAVA. (JOption Pane and Repeat control structure)
Example : Addition, Subtraction, Multiplication, Division.
The program will prompt to input two floating point numbers and a character that represents the operations presented above. In the event that the operator input is valid, prompt the user to input the operator again.
Sample Output :
First number 7
Second number 4
Menu
<+> Addition
<-> Subtraction
<*> Multiplication
</> Division
Enter Choice: * <enter>
The answer is 28.