Trouble reading user input in Mac OSX

Advertisement
November 30

Hi, I am writing a program in Java (1.5) for Mac OSX that requires the user to setup files and settings, then a new frame opens with a blank screen and waits for user input (a key press) to begin. I have a setup screen that works fine (seperate frame) and triggers the blank screen and the rest of the program fine as well. The problem is when I try to have the program pause for user input. For some reason, this thread is no longer responding to user input at all. I have tried with a KeyListener Interface and with System.in.read() as well as BufferedReaders, etc and there are no keypresses registered at all.
Another object does create a seperate thread to deal with closing down Quicktime elements, but the keypresses are not registering even when that thread has not been called.
Can anyone tell me what might be the problem? Is there an issue with multiple frames interfering with the KeyListener? I can post the code, if you'd like, but it's pretty involved.
Any help greatly appreciated!
Heidi

Advertisement

Replay

Actually, this still isn't working. I'm posting the program class (there are several supporting classes that are not in this post - SetUp opens a SetUp frame and gathers information, then calls MTSNewSwing. Start movie places a Quicktime Component into a Panel, and QTSessionCheck starts a thread that check to make sure that QT sessions are closed when neccessary). KeyPresses are stll not being registered at all.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import quicktime.*;
import quicktime.std.*;
import quicktime.app.view.*;
import quicktime.std.movies.*;
public class MTSNewSwing extends JFrame{
     public Insets getInsets() {
          Insets rm = new Insets (20, 20, 20, 20);
          return rm;
char key = 'q';
int correct = 0;
boolean kp = false;
int numberOfMovies;
ArrayList<File> moviesList = new ArrayList();
ArrayList<File> altList = new ArrayList();
     public MTSNewSwing() {
          super("Matching to Sample");
          setSize(1024, 768);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setBackground(Color.black);
          getRootPane().registerKeyboardAction(new ActionListener(){
               public void actionPerformed(ActionEvent e) {
               System.out.println("keystroke"); }
          },KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0),JComponent.WHEN_IN_FOCUSED_WINDOW);
          moviesList = SetUp.movieList;
          numberOfMovies = moviesList.size();
          int randomSampleIndex;
          int randomAlternativeIndex;
          boolean corrAltAdded = false;
          //run new trial through numOfTrials
          for (int t = 0; t < SetUp.numOfTrials; t++) {
               //clear screen
               BlankScreen bs = new BlankScreen();
               getContentPane().add(bs);
               setVisible(true);
               //put random alternatives into array list
               randomSampleIndex = (int) (Math.random() * SetUp.numOfMovies);
               File sample = (File) moviesList.get(randomSampleIndex);
               altList.add(sample);
               int correctAlternativePosition = (int) (Math.random() * SetUp.numOfAlternatives);
               for (int altPosition = 1; altPosition <= SetUp.numOfAlternatives; altPosition++) {
                    if (altPosition == correctAlternativePosition) {
                         altList.add(sample);
                         corrAltAdded = true;
                         System.out.println("correct alternative added");
                    } else if (altPosition == SetUp.numOfAlternatives && corrAltAdded == false) altList.add(sample);
                    else {
                         do {
                              randomAlternativeIndex = (int) (Math.random() *
SetUp.numOfMovies);
                         } while (randomAlternativeIndex == randomSampleIndex);      
                         File nextAlt = (File) moviesList.get(randomAlternativeIndex);
                         altList.add(nextAlt);
                         System.out.println("alternative added");
               corrAltAdded = false;
               //wait for keypress to start trial
          //this is the part that still doesn't work
               //add movies to screen
               for (int i=0; i<= SetUp.numOfAlternatives; i++) {
                    File file = (File) altList.get(i);
                    StartMovie sm = new StartMovie();
                    try {
                         sm.go(file);
                    } catch (Exception e) {
                         e.printStackTrace();
                    if (SetUp.numOfAlternatives < 4) {
                         BorderLayout bdr = new BorderLayout();
                         this.setLayout(bdr);
                         JPanel samp = new JPanel();
                         JPanel alts = new JPanel();
                         BorderLayout altbdr = new BorderLayout();
                         alts.setLayout(altbdr);
                         if (i ==0) {
                              samp.add(sm);
                              this.getContentPane().add(samp, BorderLayout.NORTH);
                              setVisible(true);
                              System.out.println("sample added");
                         } else if (i == 1) {
                              alts.add(sm, BorderLayout.WEST);
                              System.out.println("alt1 added");
                         } else if (i == 2) {
                              alts.add(sm, BorderLayout.EAST);
                              System.out.println("alt2 added");
                         } else if (i == 3) {
                              alts.add(sm, BorderLayout.CENTER);
                              System.out.println("alt3 added");
                         this.getContentPane().add(alts, BorderLayout.SOUTH);
                         setVisible(true);
                         try {
                              Thread.sleep(10000);
                         } catch (InterruptedException ex) {
                              ex.printStackTrace();
                         continue;
     public static void main(String args[]) {
               SetUp setup = new SetUp();
}

View 15 Replies

SVHS input to Mac OSX (iMovie)

November 30

I would like to find a way to input a SVHS tape directly into my MAC (either iBook G4 or Power mac Tower . . from there I would import to iMovie. I can/have burned DVD's from SVHS but once DVD burned I cannot re-import to "improve" my original D

View All Replies

Having trouble installing Photoshop & Illustrator on Mac OSX 10.7.4

October 11

Hello Im having trouble installing Photoshop CS6 and Illustator CS6. I am geting the following errow while trying to install in Creative Cloud Download Manager: Exit Code: 34 -------------------------------------- Summary ----------------------------

View All Replies

I need help with reading user input

November 30

Hi there, I have the following sql query: select v.veh_vin, v.veh_make, v.veh_model, v.veh_regonumber, c.cond_desc from vehicle v, condition c where v.cond_code = c.cond_code and v.br_no = &branch_number order by v.veh_make, v.veh_model; The query co

View All Replies

SQL & operator to read user input

November 30

Select employee_id, employee_name from employee where start_date between '&Enter employee start date(format DD-MON-YY HH24:MI:SS)' and '&Enter employee end date(format DD-MON-YY HH24:MI:SS)' above query is not able to display full text for reading

View All Replies

I have master suite cs6. on mac osx. bridge has been quitting unexpectedly. Also, getting message at start up that states that "bridge encountered a problem and is unable to read the cache. Please try purging the central cache in Cache Preferences to corr

October 11

I have master suite cs6. on mac osx. bridge has been quitting unexpectedly. Also, getting message at start up that states that "bridge encountered a problem and is unable to read the cache. Please try purging the central cache in Cache Preferences to

View All Replies

Adobe Reader's Internet Plugins for Mac OSX

November 30

Every time I upgrade or reinstall Adobe Reader on Mac OSX I have to delete the plugins installed in my library to stop Reader being my default pdf viewer in Safari. Isn't it time your apps worked like everyone elses and gave the USER the option to se

View All Replies

User Uploaded Image won't display on Mac OSX

November 30

I am experiencing something very strange with user uploaded images on Mac OSX, latest Debug Flash Player 9, Safari and Firefox 2. Everything works fine on Windows (XP and Vista) on all major browsers. A user selects a local image to upload. The file

View All Replies

Adobe Reader will not print to Epson WF-2540 in Mac OSX 10.8.3

November 30

I have previously used Adobe Reader to print in both wired and wireless capacity to my Epson WF-2540 printer on my Mac OSX. My current version is Mac OSX 10.8.3. Recently (and it may have been following an update to my OS, I don't know for sure) the

View All Replies

Can I read Kindle ebooks downloaded on Amazon on a MacBook Pro with Mac OSX version 10.6.8 without the ibook reader app?

November 30

Can I read Kindle ebooks downloaded on Amazon on a MacBook Pro with Mac OSX version 10.6.8 without the ibook reader app?Amazon.com: Kindle for Mac - Read Kindle eBooks on your MacRead other 2 answers

View All Replies

I am a new mac user and I switch to mac due to the graphics that it brings. I do website in pc and I heard iweb is the best.NOW i heard that iweb will be discontinue. so what is the best application there for website using MAC OSX lion?

October 11

I am a new mac user and I switch to mac due to the graphics that it brings. I do website in pc and I heard iweb is the best.NOW i heard that iweb will be discontinue. so what is the best application there for website using MAC OSX lion?It is now conf

View All Replies

Adobe Reader 9 and Mac OSX 10.5 - FDF Issue

October 11

I have an issue that only happens when using Adobe Reader 9 and Mac OSX 10.5. When submitting a form from within a PDF, the FDF that gets sent is completely blank. Tested on Mac OSX 10.4 with Adobe Reader 9 - no issue Tested on Mac OSX 10.5 with Adob

View All Replies

Adobe Reader 10.1.3 "Internal Error" - Mac OSX 10.7.4?

October 11

Battling for hours trying to get the Reader to work with a new MBP running 10.7.4.  It downloads and installs OK and I get the licensing page but after clicking 'Agree' I just get 'An Internal Error Occurred'. For hours this drove me mad.  I tried de

View All Replies

I believe that i have malware on my mac, osx 10.9.4. accordingly, i've tried to run clamxav (on my mac HD) but just get a spinning wheel, then have to shut down. any advice on how to stop spinning wheel or get rid of malware? please help. :-).

November 30

i believe that i have malware (possible highjack of safari browser) on my mac, osx 10.9.4. accordingly, i've tried to run clamxav (on my mac HD) but just get a spinning wheel, then have to shut down. any advice on how to stop spinning wheel or get ri

View All Replies

"Your Mac OSX startup disk has no more space available for application memory" - uploading files problem

November 30

Hi everyone, I'm running a late-2012 27 inch iMac - 3.4GHz Intel Core i7, 32GB 1600 MHz DDR3 with the 3TB fusion drive, OS 10.8.4. At present there is 1.92TB of available storage. I have received this message "Your Mac OSX startup disk has no more sp

View All Replies

Need help loading mac osx snow leopard

October 11

i just bought mac osx snow leopard and im having trouble downloading it i have a mac osx 10.4.11 but when i put the disk in it says i need an itel based macSnow Leopard and above runs only on Intel processor Mac's, not PowerPC Mac's. Congradulations

View All Replies

Dealing w/ User Input and Multiple Objects

November 30

I am trying to write a simple interface where a user inputs his/her name and id and then a Patron object is created based on their given input. I am having trouble when there are multiple patrons. My problem is referencing the different Patron object

View All Replies

Once i open the iCloud or address book I lose my administrative privileges, Mac OSX Mountain Lion

November 30

Mac OSX Mountain Lion 10.8.2 The problem did not exist before this upgrade. If I open iCloud, or AddressBook, or if assistantd asks for Keychain Access password, I lose all my user's administrative privileges, I can't copy and paste files anymore and

View All Replies

Question Pertaining to User Input

November 30

I'm have trouble figuring out how to prompt for user input and then use that user input as part of my code. For instance, I want to declare two variables that will hold complex numbers. Then, I want the user to input two complex numbers. After this,

View All Replies

Firefox no longer working with Mac OSX 10.4.11

October 11

i'm using Mac OSX 10.4.11 and Firefox 3.6.12. As i understand it any of ur upgrades no longer work with this computer system. ( I tried to upgrade last week and ur site said upgrades no available gfor my platform version. Last week every time i condu

View All Replies

Tags:

  1. how empty bulk mail ipad1
  2. ifroget my icloud id n pasword
  3. badi or bte in sap afab transaction
  4. sccm 201 capture image Windows 8
  5. java deconfig for old jav r12
  6. me22n save enhancement
  7. cisco ise authentication failure
  8. LFJ9
  9. F990
  10. throughoutrpq
Copyrights 2019 Fcffair BigData Resource, All rights reserved