Could some body write me a small program?

Im after a program that will simulate a simple fruit machine It must have a minimum of Three lables which will display the fruit machine symbols - orange-banana-pear-cherry-bar-seven-java (all jpegs)
Two buttons one with the text "SPIN" and the other with the text "QUIT" These buttons will both have actions associated with them.
One lable to show the current credit (i.e. score)
One lable to show the outcome of a spin (e.g "you win 100")
The GUI may include internal Jpanels, use of a grid layout, BorderLayout ect.
The Game. The user should start with 100 credits and the three image lables show the java image (java.jpeg) The current credit lable should show the value of 100. The outcome lable has blank text( "") at the start of the game.
When the user presses the spin button the image lables show 3 random images from orange banana pear cherry bar or seven. Each time the SPIN button is pressed the credit is reduced by 5, the credit label should change accordingly.
Credits can be increased if there is a winning combination of images.
Some challenge eh guys

You guys are being too hard on him, and I'm probably being too easy. Anyway, here's your program. Have fun!
SlotLabel.java
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
public class SlotLabel
  private static final Dimension SIZE = new Dimension(200, 38);
  private static final float FONT_SIZE = 22;
  private static final int TIMER_DELAY = 40;
  private static final int MAX_TIMER_LOOPS = 60;
  public static final int STR_LENGTH = 9;
  private JLabel mainLabel = new JLabel("", SwingConstants.CENTER);
  private byte[] byteArray;
  Timer timer = new Timer(TIMER_DELAY, new TimerListener());
  public SlotLabel(byte[] byteArray)
    this.byteArray = byteArray;
    mainLabel.setPreferredSize(SIZE);
    mainLabel.setOpaque(true);
    mainLabel.setBackground(Color.white);
    mainLabel.setBorder(BorderFactory.createLineBorder(Color.black));
    mainLabel.setFont(mainLabel.getFont().deriveFont(Font.BOLD, FONT_SIZE));
  public void clear()
    mainLabel.setText("");
  public void spin()
    timer.start();
  public JComponent getComponent()
    return mainLabel;
  private class TimerListener implements ActionListener
    private int timerCounter = 0;
    private Random random = new Random();
    private int base = 'A';
    private int gap = 'Z' - 'A';
    public void actionPerformed(ActionEvent arg0)
      if (timerCounter < MAX_TIMER_LOOPS)
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < STR_LENGTH; i++)
          sb.append((char)(random.nextInt(gap) + base));
          mainLabel.setText(sb.toString());
        timerCounter++;
      else
        mainLabel.setText(new String(byteArray));
        timer.stop();
        timerCounter = 0;
}SlotMachineHomework.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SlotMachineHomework
  private static final byte[][] BYTE_ARRAYS =
    {0x50, 0x4c, 0x45, 0x41, 0x53, 0x45, 0x20, 0x44, 0x4f},
    {0x59, 0x4f, 0x55, 0x52, 0x20, 0x4f, 0x57, 0x4e},
    {0x48, 0x4f, 0x4d, 0x45, 0x57, 0x4f, 0x52, 0x4b, 0x21}
  private static final int TIMER_DELAY = 600;
  private JPanel mainPanel = new JPanel();
  private SlotLabel[] slotLabels = new SlotLabel[BYTE_ARRAYS.length];
  private Timer timer = new Timer(TIMER_DELAY, new TimerListener());
  private JButton spinButton = new JButton("Spin");
  private JButton quitButton = new JButton("Quit");
  public SlotMachineHomework()
    JPanel slotPanel = new JPanel(new GridLayout(1, 3, 10, 0));
    for (int i = 0; i < slotLabels.length; i++)
      slotLabels[i] = new SlotLabel(BYTE_ARRAYS);
slotPanel.add(slotLabels[i].getComponent());
spinButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent arg0)
for (int i = 0; i < slotLabels.length; i++)
slotLabels[i].clear();
spinButton.setEnabled(false);
timer.start();
JPanel btnPanel = new JPanel();
btnPanel.add(spinButton);
btnPanel.add(quitButton);
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
mainPanel.setLayout(new BorderLayout(20, 20));
mainPanel.add(slotPanel, BorderLayout.CENTER);
mainPanel.add(btnPanel, BorderLayout.SOUTH);
public JComponent getPanel()
return mainPanel;
private class TimerListener implements ActionListener
private int timerCounter = 0;
public void actionPerformed(ActionEvent arg0)
if (timerCounter < slotLabels.length)
slotLabels[timerCounter].spin();
timerCounter++;
else
timer.stop();
timerCounter = 0;
spinButton.setEnabled(true);
private static void createAndShowGUI()
JFrame frame = new JFrame("SlotMachineHomework Application");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new SlotMachineHomework().getPanel());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args)
javax.swing.SwingUtilities.invokeLater(new Runnable()
public void run()
createAndShowGUI();

Similar Messages

  • HT4623 Hi . My iPhone 4S Facebook page won't rotate either it's lock or unlock what should I do for it could some body tell me about this problem plz

    Hello dear I want to ask that when I am using the Facebook app in my iPhone 4S I want rotate the screen but its not turn over in side ways other all pager or apps like text massages , safari browser , all rotate but only having problem with my Facebook that I can not rotate so please can some body tell me what should I do for this problem .
    Waiting for positive answer.
    I look forward to hear from you people soon thanks
    Regards ,
    Syed Basharat Ali

    They may not have the updated Facebook app. I have a 4S and my Facebook will not rotate. You can use Google and find more information about this. I'm just reporting what is going on and why it is happening.
    Google:
    http://www.google.com/search?q=ios+facebook+app+rotation&sourceid=ie7&rls=com.mi crosoft:en-us:IE-Address&ie=&oe=
    One of the links from Macrumors:
    http://forums.macrumors.com/showthread.php?t=1427794
    Message was edited by: ChrisJ4203

  • Could someone please write a download manager program that allows me to set what time of day downloads can be scheduled.?

    I have a iMac, iPhone &amp; iPad. I am using "Hughes Satilite Internet". We have a very limited download of 425MB. But between 1:am till 5:am I can download freely any amount. Some updates have been well over 1 gig &amp; combination of different updates have been more. Also iCloud syncs with all devises. I would like a program on Apple products that allow me to specify a time to download updates &amp; iCloud syncing, to allow me to schedule updates &amp; music downloads at specific times. This is a needed program for all Apple products. It needs to be built in to the iOS.
    Thank you,
    Glenn

    This is an enhancement of the OS, we are just users and have no influence on that, send your feedback here:
    http://www.apple.com/feedback/

  • Could some one help me in knowing abt this function

    NVL(MONTHS_BETWEEN(TO_DATE('01/01/2005' , 'dd/mm/yyyy')+1,pims.get_last_appt(p.patnt_refno)),0) op
    Could some body explain me how this works in a pl/sql block .
    many thanks
    Prk

    It works the same in sql as pl/sql, but anyway...here goes.
    If the number of months between 02-JAN-2005 and the patient's last appointment is null, then put a zero. Or in layman's terms, find out how many months were between 02-JAN-2005 and the last time the person had an appointment. If they've never had an appointment, it is 0.

  • Could not write to file: C:\Program Files (x86)\Adobe\Acrobat 7.0\ActiveX\AcroPDF.NOR. ?

    Hi, I get this message (loosely translated from Swedish):
    "Could not write to file: C:\Program Files (x86)\Adobe\Acrobat 7.0\ActiveX\AcroPDF.NOR.
    Confirm that you have access to this file"
    when I try to install Acrobat standard 7.0, and after several "retry" I cannot finish the installation.
    Does anyone know why?
    Thank you,
    MIa

    Appears that you are on a Win7, 64-bit machine. AA 7 has an issue with activation since the server no longer exists for AA 7. There is a separate install at Adobe to address this issue that might solve the problem temporarily (Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3). Even if you get AA 7 installed on Win7, you will have to do workarounds to make it work. Both the print driver (Adobe PDF) and AcroTray.exe fail on Win7 and they require workarounds to be able to even use AA 7. It is strongly recommended that you get AA XI at this point.

  • I wish to uninstal a program ? could some one please help me thank you  marie

    I wish to uninstal a program / could some one please help me  thank you   marie

    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, Easy Find, instead.  Download Easy Find at VersionTracker or MacUpdate.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
    AppZapper
    Automaton
    Hazel
    CleanApp
    Yank
    SuperPop
    Uninstaller
    Spring Cleaning
    Look for them at VersionTracker or MacUpdate.
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • Can some body tell me where my code is going wrong

    I have been trying to print a jTextArea and have been having trouble. Can some body look at my code and tell me where I am going wrong please, Thank You.
    I have pasted the code below. P.S. I have only attempted to print the jTextArea I have not done anything else. The program was written in the hope that I could learn how to print a jTextArea and no other function in an aim to transfer the successful code to other applications that I enter information into the jTextArea.
    * print.java
    * Created on 05 August 2007, 23:34
    package my.print;
    * @author morgan
    import java.awt.print.*;
    public class print extends javax.swing.JFrame {
    /** Creates new form print */
    public print() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jButton1 = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);
    jButton1.setText("jButton1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(88, 88, 88)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jButton1)
    .addContainerGap(67, Short.MAX_VALUE))
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(95, 95, 95)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jButton1)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(109, Short.MAX_VALUE))
    pack();
    }// </editor-fold>
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    try {
    jTextArea1.print();
    } catch (java.awt.print.PrinterException exc) { // ... }
    * @param args the command line arguments
    public static void main(String args[]){
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new print().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration
    }

    sorry i hope that this preserves the code.
    * print.java
    * Created on 05 August 2007, 23:34
    package my.print;
    * @author  morgan
    import java.awt.print.*;
    public class print extends javax.swing.JFrame {
        /** Creates new form print */
        public print() {
                initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jButton1 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(88, 88, 88)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton1)
                    .addContainerGap(67, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(95, 95, 95)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton1)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(109, Short.MAX_VALUE))
            pack();
        }// </editor-fold>
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    try {
        jTextArea1.print();
    } catch (java.awt.print.PrinterException exc) { // ... }
         * @param args the command line arguments
        public static void main(String args[]){
            java.awt.EventQueue.invokeLater(new Runnable() {
                 public void run() {
                    new print().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        // End of variables declaration
        }The preview looked correct. Thank you for the URL. I have been writting my program in netbeans 5.5.1. unfortunately it simplifies the code that you have to put in but at the same time it makes it difficult to follow code examples that are intended to develope the whole of the code from scratch. I have tried looking at the netbeans guidance documentation but find that it doesn't always work even when I follow the direct code for the demonstrations. Anyway thanks for the guidance and for getting back to me so soon.

  • Small issue in small program(code) that need to be fixed ...

    Hi Guys ,
    i need ur help in some kind of issue( technique thing ;) ). i have done small program that ask for numbers then print them and told u how many Odd numbers.
    the issue that i have it, is that the program when print the result (the numbers) it print them correctly but print with them word "null".
    i need ur help to avoid that word.
    How???
    sorry for my bad english, since i don't know english well.
    and thank u soo much for ur help ;)
    this is the code:-
    import javax.swing.JOptionPane;
         // takes number from the user and show u the odd number and print them
    public class Odd {
         public static void main(String[] args) {
              String n,m;
              int a=0;
              int x=1;
              String result = null;
              n=JOptionPane.showInputDialog(null,"How many number do you want to check for the odd ? ");
              int n1 = Integer.parseInt(n);
              int array[]=new int[n1];
              for(int i=0;i<array.length;i++){
                   m=JOptionPane.showInputDialog(null,"Enter number "+x);
                   array[i] = Integer.parseInt(m);
                   result=result+array[i]+"\n";
                   x++;
                   if( array%2 !=0 )
                        a++;
                   JOptionPane.showMessageDialog(null,"The Numbers Are :\n"+ result);
                   JOptionPane.showMessageDialog(null,"The Odd Numbers are:\n " a" Numbers");

    First of all you don't need to feel yourself sorry. Here is a Java forum not an english literature forum and at least I can understand you. At least you don't try to write in your language which we probably may not understand.
    Secondly if you initialize your String value like that you have the null value. You can initialize it like
    String result = new String(); and try it again.

  • Need suggestions to write a PL/SQL program

    Hi,
    We have some readme documents in different places. we need to keep the docs in specified folders. for example if we have around 100 docs we need to figure out the required docs by giving the just any one word from that doc name.
    now the requirement is need to keep all the docs in one specified folder (check the product name, if the product is there then it will pick all the docs related to that particular product and keeps in separate folder). whenever we need to find out any one of the document from that product we need to give the short word from that doc name then it will show you the required doc.
    So could you please let me know is it possible to write any PL/SQL program for the above requirement else suggest me which one will support to resolve the above requirement.
    Kindly suggest me for the above request.
    thanks in advance.

    You may want to consider loading the documents into blobs or using BFILES.
    BFILE defnition
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements001.htm#SQLRF50996
    BLOB definition
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements001.htm#SQLRF50997
    Regardless of whether you use BLOB's or BFILE's, you'll have to build a metadata table for each document.
    For example, if you decided upon BLOB's, you would need some kind of metadata table as follows;
    create table doc_table (id number, doc_name varchar2(20), b blob);
    insert into doc_table values (1, 'DOC_A', to_blob('A'));
    insert into doc_table values (2, 'DOC_B', to_blob('B'));
    commit;
    create table doc_metadata (id number, keyword varchar2(20));
    insert into doc_metadata values (1, 'A');
    insert into doc_metadata values (2, 'B');
    commit;You would then search for a document based on a keyword, for example,
    to find document A;
    select dt.doc_Name      
    from   doc_table    dt
          ,doc_metadata dm
    where  dt.id = dm.id
    and    dm.keyword like 'A';You could add more columns (as you like), for example location, size etc.

  • Windows App Certification Kit - Test Fails for Validate Desktop App at "Write appropriate Add/Remove Program values"

    Hi,
    I am trying to validate a .Net Framework 4 WinForms application for use in the Microsoft Partner Network portal.
    I am using Windows App Certification Kit 3.4 for Windows 8.1 , and the Validate Desktop App option.
    To build the package I am using InstallShield 2012 SPR Limited Edition (for Visual Studio), and the validation fails
    only with the following error (please also see the attached image):
    Clean reversible install test: Failed to Write appropriate Add/Remove Program values
    Error Found: The registry population test detected the following error: app didn't create the required registry entries.
    A non-optional value 'DisplayName' is missing or invalid (same for 'Publisher', 'ProductVersion')
    Please note that I have filled in all the publisher/product details in the InstallShield project, on the General Information page.
    Also I have tried to use the Microsoft Visual Studio Installer Project for VS2013, and the validation failed with the exact same error.
    (https://visualstudiogallery.msdn.microsoft.com/9abe329c-9bba-44a1-be59-0fbf6151054d)
    Any help would be very appreciated.
    Thank you.

    You may need to add the necessary info to the app’s Windows Installer package so it can configure Add/Remove Programs in Control Panel correctly. Setting these properties automatically writes the corresponding values into the registry. From the picture,
    you are missing some necessary information about your desktop app.
    Also You need the correct admin permissions to write to the registry.
    Please refer to this thread:
    http://stackoverflow.com/questions/21182856/windows-app-certification-kit-test-result-app-didnt-create-the-require-regist
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I HAVE A MAC BOOK AND I CAN GET TO WORK THE CD 1 IT DOESN'T READ AND ONLY APPEAR A ICON LIKE A FOLDER WIR ONE QUESTION MARK, CAN SOME BODY HELP?

    I HAVE A MAC LAP TOP MAC BOOK AND  WANT JUST TO REINSTALL THE SOFTWARE I DONT CARE ABOUT MY FILES I HAVE BACK UP BUT WHEN I INSERT THE DISK VERSION 10.5 WHICH COMES WITH MY COMPUTER DOESN'T WANT TO READ I HEARD THA IS TRYING BUT NOTHING,
    CAN SOME BODY HELP ME...

    There is a possibility that the disk drive could be broken, if it just spits it back out that usually means its toast. If your MacBook has a Core 2 Duo processor, you can install Lion (via a thumb drive not disks). Here is a link to the Lion thumb drive.You can also still order them for $19.99 by calling 1-800-MY-APPLE. Also you can borrow an external disk drive and try the Leopard disks that way as well.
    Good Luck!

  • Time stamp to excel .....some thing is wrong in my program

    Hi 
    i am trying to write date and time to excel sheet i got this example from https://decibel.ni.com/content/docs/DOC-2108. but when i tried to write it on excel it is just showing the numbers but not exact date and time what i want.
    some body have idea whats wrong in my VI(see attached file)?
    thanks
    Attachments:
    LVtime2Exceltime.vi ‏8 KB

    You might want to swap up to this Version.  There are a few things that LVtime2Exceltime.vi   does not handle correctly (like Zone, DST and the Leapyear Bug in excel)  you may want to vote for this Idea
    Jeff
    Attachments:
    Time to XL.vi ‏15 KB

  • Could not initialize Photoshop because of a program error" with PS CC 2014

    I get "Could not initialize Photoshop because of a program error" with PS CC 2014 on a 2099 Macbook Pro running Mavericks. Then the program closes. Can anyone help?

    Could be corrupt preferences, a problem with the OS font cache, or some other problem with the OS.
    First, try resetting the preferences.

  • How would I set this small program to activate every 120 seconds?

    I have this small program that writes the value 0 to a file, but I want it to only activate every 120 seconds, so it doesn't take up a bunch of system resources by constantly running. Can I make it pause for 120 seconds, or set a timer for it, in such a way that it won't make my PC run slow? Here's my code. Thanks if you can help.
    import java.util.*;
    import java.io.*;
    import java.io.File;
    public class Purge extends Random implements Serializable {
         public Purge () {
              writePrimDoubles();
         public static void main (String [] args) {
              Purge test = new Purge();
         public void writePrimDoubles() {
              DataOutputStream outStream;
              long timerStart;
              long timerEnd;
              long size;
              int a = 1;
              try     {          
                   while (a==1) {
                        outStream = new DataOutputStream
                             (new FileOutputStream("packetlog.txt"));
                        timerStart = System.currentTimeMillis();
                        outStream.writeBytes("0");
                        timerEnd = System.currentTimeMillis();
                        outStream.close();
              catch(IOException e) {
                   System.out.println("Error writing to file");
    }

    java.util.Timer, I think may do the trick.

  • Photoshop CC: Could not open Photoshop because of a Program Error. How do I fix this?

    Photoshop CC: Could not open Photoshop because of a Program Error.
    How do I Make sure your OS X user account has Read & Write access for the following path:
    /Users//Library/Preferences/Adobe

    Nobody can tell you anything without proper system info or other technical details like the actual crash logs. From your description it simply sounds like your graphics hardware is acting up, so update the graphics driver. Likewise, you may simply run out of disk space for the PS scratch file, so check that, too.
    Working with your Operating System’s Tools | Mylenium's Error Code Database
    Mylenium

Maybe you are looking for