Having problems with JPassword fields combined with terminalIO

i copy pasted the code from the java tutorials of the JPasswordField program PasswordDemo. the code is found here... http://java.sun.com/docs/books/tutorial/uiswing/components/examples/PasswordDemo.java
then i went to the part that defines what the program does if the password is correct and copy pasted one of my programs in. i did this twice. one with a terminalIO program and one with a JOptionPane program. for some reason the JOptionPane works but the TerminalIO freezes the program and does not allow me to type anything into it. Does anybody have any sugestions on how to fix this other than translating the code to a JOptionPane program?
any help is greatly appreciated.

and this is the whole program so that you can put it into an editor:
import TerminalIO.KeyboardReader;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/* PasswordDemo.java requires no other files. */
public class PasswordDemo extends JPanel
implements ActionListener {
private static String OK = "ok";
private static String HELP = "help";
private JFrame controllingFrame; //needed for dialogs
private JPasswordField passwordField;
public PasswordDemo(JFrame f) {
//Use the default FlowLayout.
controllingFrame = f;
//Create everything.
passwordField = new JPasswordField(10);
passwordField.setActionCommand(OK);
passwordField.addActionListener(this);
JLabel label = new JLabel("Enter the password: ");
label.setLabelFor(passwordField);
JComponent buttonPane = createButtonPanel();
//Lay out everything.
JPanel textPane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
textPane.add(label);
textPane.add(passwordField);
add(textPane);
add(buttonPane);
protected JComponent createButtonPanel() {
JPanel p = new JPanel(new GridLayout(0,1));
JButton okButton = new JButton("OK");
JButton helpButton = new JButton("Help");
okButton.setActionCommand(OK);
helpButton.setActionCommand(HELP);
okButton.addActionListener(this);
helpButton.addActionListener(this);
p.add(okButton);
p.add(helpButton);
return p;
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (OK.equals(cmd)) { //Process the password.
char[] input = passwordField.getPassword();
if (isPasswordCorrect(input))
KeyboardReader reader = new KeyboardReader();
System.out.println("Enter a number: ");
int theInteger = reader.readInt();
System.out.println(theInteger);
else {
JOptionPane.showMessageDialog(controllingFrame,
"Invalid password. Try again.",
"Error Message",
JOptionPane.ERROR_MESSAGE);
//Zero out the possible password, for security.
for (int i = 0; i < input.length; i++) {
input[i] = 0;
passwordField.selectAll();
resetFocus();
} else { //The user has asked for help.
JOptionPane.showMessageDialog(controllingFrame,
"You can get the password by searching this example's\n"
+ "source code for the string \"correctPassword\".\n"
+ "Or look at the section How to Use Password Fields in\n"
+ "the components section of The Java Tutorial.");
* Checks the passed-in array against the correct password.
* After this method returns, you should invoke eraseArray
* on the passed-in array.
private static boolean isPasswordCorrect(char[] input) {
boolean isCorrect = true;
char[] correctPassword = { 'b', 'u', 'g', 'a', 'b', 'o', 'o' };
if (input.length != correctPassword.length) {
isCorrect = false;
} else {
for (int i = 0; i < input.length; i++) {
if (input[i] != correctPassword) {
isCorrect = false;
//Zero out the password.
for (int i = 0; i < correctPassword.length; i++) {
correctPassword[i] = 0;
return isCorrect;
//Must be called from the event-dispatching thread.
protected void resetFocus() {
passwordField.requestFocusInWindow();
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("PasswordDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
final PasswordDemo newContentPane = new PasswordDemo(frame);
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Make sure the focus goes to the right component
//whenever the frame is initially given the focus.
frame.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
newContentPane.resetFocus();
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();

Similar Messages

  • Create Query with New Field combined with Existing InfoCube Data (BW 3.5)

    Hi Everyone!
    How would you recommend I handle the following situation?
    I have a custom InfoCube (which I will call ZCUBE) that has been deployed to production. The business would like a new query that combines Current Standard Price along with data currently stored in ZCUBE.
    Now, Current Standard Price is uniquely identified by the Material and Plant to which it is associated. These InfoObjects (Material and Plant) are characteristics of ZCUBE.
    I am strugglig since the business will not allow any changes in the design of the InfoCube (i.e. add any new characteristics/key figures).
    Is there a way to combine the two data sets? I attempted to use a Multi-Provider using ZCube and a custom ODS, but had no luck since the characteristics were so different. (ZCUBE has almost 50 characteristics defined)
    I also have tried adding the attribute Standard Price to InfoObject Plant Material (0MAT_PLANT) but that was not helpful since 0MAT_PLANT is not included in ZCUBE.
    From what I can tell I should create an InfoSet using ZCUBE and potentially a new ODS, but that isn't going to work since you can create InfoSets using InfoCubes in BW 3.5.
    So... I am at a loss now. Any assistance would be appreciated!
    Thanks-
    Nathalie

    Thank you very much for your responses!
    I went ahead and created a custom ODS (Z_ODS) that contained the keys Material and Plant and had the data field Standard Price. I then created a Multi-Provider to sit on top of the custom cube and the custom ODS. Unfortunately, I am not getting the correct response since the Multi-Provider returns a union of the two infoproviders.
    Z_ODS
    0Material (key)
    0Plant (key)
    Standard Price
    Z_Cube
    0Material (char)
    0Plant (char)
    Char1 (char)
    Char2 (char)
    Char3 (char)
    0FiscalYear
    Key1....
    MultiCube
    0Material = 0Material
    0Plant = 0Plant
    Char1
    0FiscalYear
    Standard Price
    Key 1
    If I run a query just using Material and Plant in the return, the Standard Price and Key1 are returned correctly. If I include Fiscal Year in the query, the standard price is returned in a row associated to a blank Fiscal Year. See example below.
    Query 1
    Plant1   Material1   StandardPrice1   Key1
    Plant2   Material2   StandardPrice2   Key2
    Query 2
    FiscalYear2009   Plant1   Material1   #(blank StandardPrice)   Key1
    FiscalYear2009   Plant2   Material2   #(blank StandardPrice)   Key2
    FiscalYear# (blank) Plant1   Material1   StandardPrice1 #(Blank Key1)
    FiscalYear# (blank) Plant2   Material2   StandardPrice2 #(Blank Key2)
    I know I should be using an InfoSet, but we are on BW 3.5... so I can't include a cube in an InfoSet.
    I believe that the solution will be to add all relevant characteristics to the custom ODS... but that is going to be a much bigger challenge then originally expected. Please let me know if I am missing something... a silver bullet would be much appreciated
    Thanks everyone!
    Nathalie

  • I am having problem while using ms word with anjal( OS X Lion 10.7.5 (11G63))

    i am having problem while using ms word with anjal  is not working properly but its working in facebook and other areas.i need and  its very important to using tamil fonts for my job.can anyone help me out from this problem.
    thanking you
    by
    moses

    Those who are knowledgable in this area (myself not among them) say that Word's support for Asian languages is faulty. The best word processor for that use is "Mellel."

  • Having problems opening a pdf file with reader 10/11 get error msg cannot open close reader and try again any ideas

    having problems opening a pdf file with reader 10/11 get error msg cannot open close reader and try again any ideas

    Hi George ,
    Is it happening with all the PDF' or any specific one?
    Could you please share the error message so that we can replicate at our end ?
    Try repairing reader  once and see if that fixes the issue.
    Launch Reader>Navigate to Help>Repair Adobe Reader Installation
    Regards
    Sukrit Dhingra

  • Having problems using ion tape express with itunes cannot find the song on hard drive

    Having problems using ION tape express with itunes.  The song is on hard drive as temp1 not the name of the song.  And I have problems playing it in itunes
    because it says it cannot locate the song'

    Then correct the name of the song or point iTunes to the new file.
    Issues with restoring should be directed to the manufacturer of the backup software/device... this is not an Apple or iTunes issue.

  • I am having problems syncing my iPad 2 with iTunes. Whenever I click "sync" or "apply," the sync begins. As soon as it gets to step 3 (in this particular case "determining apps to sync") it immediately stops syncing. What's the deal here?

    I am having problems syncing my iPad 2 with iTunes. Whenever I click "sync" or "apply," the sync begins. As soon as it gets to step 3 (in this particular case "determining apps to sync") it immediately stops syncing. What's the deal here?

    You haven't purchased apps with multiple Apple ID's have you? If you have, you can only sync with one Apple ID in the iTunes library at a time. Whichever ID you are signed into on the computer and the iPad would determine which apps would sync.
    Have all of your apps been transferred into iTunes for your iPad?
    iTunes Store: Transferring purchases from your ... - Support - Apple

  • TS4001 Anybody having problems accessing Adwords Exspress login with Safari ?

    Anybody having problems accessing Adwords Exspress login with Safari ?

    Hi jhankins,
    There was a problem yesterday for a brief half an hour to 1 hour, please let us know if you are still facing that issue.
    -Ankit

  • Having problems downloading dreamweaver, comes up with error 50

    I'm a student and is having, problems downloading dreamweaver, it comes up with error 50, when ever finish downloading, could someone come back to me, I need to download urgently,  Kind Regards Miss Shaw.

    I'm a student and is having, problems downloading dreamweaver, it comes up with error 50, when ever finish downloading, could someone come back to me, I need to download urgently,  Kind Regards Miss Shaw
    ............................Please reply urgent.

  • I am having problems pairing my Galaxy s2 with my Ipad 4.. Can some help please..

    I am having problems pairing my cell Galaxy S2 to my IPAD4? .. any one please help Thank you

    The iPad Bluetooth is mainly for earplugs, earphone, speakers and keyboard.
    It will not paired with your Samsung.

  • Having problem accessing MacMini over network with PC's Windows 7

    Hi all,
    I have a Mac Mini with 10.6.x
    Onec in a while, especially when restart Airport Extreme for upgrade or something else (both are connected with ethernet cable cat5e) ALL PC's on the network having problem accessing Mac Mini Server while All MACs are fine and can access all folders no problem. Usually takes about 3-4 min for PC to connect to server. Then  once it is connected (it loads all folder and files in that current window on the PC) i can go from folder to folder with no delays. However if i close the window with all folders then again i have to wait for around 3 min. to load everything all over again. AFP and SMB are ON. Today i made an experiment and turned SMB off and the problem still excist with the difference that after 3-4 min delay no folders were shown.
    It seems that the PCs have hard time establishing connection with the server which is weird that Macs don't have that problem. It must be something with the setting of Mac MIni. Other wise i have no problem accessing Internet so the routher is working fine. DHCP is ON on the AP Extreme.
    I came across as i was searching for this issue and it seems that authentication - Golden triangle or whatever is called - might be the issue in the whole mess. Do you guys think that this might be the case ?
    The only way i have found out to help is to restart the Router and Server and that usually fix the problem  .
    Could you please help me figure what is going on there?
    Here is the original thread: https://discussions.apple.com/thread/3867559?tstart=0 ( i think i posted in the wrong forum )

    The specified changeip -checkhostname command does not make changes to your configuration. 
    To research the command (and that's entirely your perogative), please use Google or Bing to search for previous discussions and details, or review the provided man page documentation for the command.  (Launch Terminal.app (folder Applications > Utilities) and issue the command man changeip.  You'll see something like this:
    $ man changeip
    changeip(8)               BSD System Manager's Manual              changeip(8)
    NAME
         changeip -- Change service configuration files with hard-coded IP addresses
    SYNOPSIS
         changeip [-v] [-d path] old-ip new-ip [old-hostname new-hostname]
         changeip -checkhostname
         changeip -h
    DESCRIPTION
         changeip is used to manually update configuration records when a server's IP address or hostname changed in a way that affected services were unable to properly process, for example when the server is behind a NAT device and the WAN identity changed.  ...
    Given your response and your concern, consider creating a backup of your disk.  Shut down, boot the installation DVD, and use Disk Utility (from the Utilities menu) in the second screen of the installation process to copy your disk contents to an external storage device.  (Time Machine isn't as good at getting a backup of a server as is a clean backup created while shut down.)  There are descriptions around that detail how to create this backup using Disk Utility.
    There is no DNS server implemented in the Airport Extreme.  The Airport Extreme forwards DNS requests to a DNS server elsewhere.  Few gateway devices contain DNS servers; that these devices request a DNS address tends to be confusing, too.  That address is solicited from the user for use in the DHCP server that many of the available gateway devices provide.
    There is no need for a DNS forwarder, particularly if your server is configured for your LAN.  (Adding a forwarder adds another hop into the whole translation process.  That configuration and that extra hop can be useful when the intermediate DNS server is providing specific, enhanced DNS-related functions, such as security monitoring and logging, or providing a "nanny filter" mechanism.)
    If you are running DNS services on your LAN, then your Airport Extreme DHCP server should be configured to pass out the IP address of your DNS server.
    It would appear that your local box has the default self-hosted DNS, and is not configured to serve LAN DNS (other than for itself).  That's good.  Accordingly, it'll likely be getting good DNS from itself, but will not be getting translations for other hosts on your network.  That's not so good.  When DNS responses are not available, you'll get DNS-level timeouts, and those are usually around 30 seconds each.
    Check your server logs for messages related to the failed connections, and check the Windows file service logs for any errors being generated by the file service.  The log information is most easily available from Console.app, which is a utility in Applications > Utilities folder, or from the Server Admin tool (Applications > Server folder) for DNS, and for the file server component.
    The above is probably going to read like a wall of unfamiliar jargon, so please ignore this and my previous response here, and I'll leave it to somebody else to assist you here.

  • Problems with 'ProtectDoubleSubmit' in combination with 'TableView'

    Hello all,
    maybe there is someone around who can help me with the following problem:
    I am using a tableview (based on a table) with an additional column with an image ('dustbin'). When the user clicks on it the user deletes the chosen row.
    It works perfectly well unless I include 'ProtectDoubleSubmit'. The 'ProtectDoubleSubmit' leads to a different behaviour of the event that is triggered when the user clicks on the u2018dustbinu2019-image:
    lr_event = cl_htmlb_manager=>get_event_ex( request ).
    Without 'ProtectDoubleSubmit' i get an event with the expected event_class CL_HTMLB_EVENT_TABLEVIEW (with column and row index which I need for my delete activity).
    With 'ProtectDoubleSubmit' I get an event with the event_class CL_HTMLB_EVENT with event_name = u2018imageu2019!. I dont get the information which cell i clicked on.
    Has anybody an idea how this comes and how I can avoid this behaviour?
    Do I have the chance to redefine/change the class CL_XHTMLB_PROTECTDOUBLESUBMIT in a way that I can avoid the problem? I had a look in that class, but unfortunatly I do not understand the logic how 'ProtectDoubleSubmit' works.
    Thanks in advance for your efforts!
    Frank

    Hello Chandra,
    thanks for your answer.
    Unfortunatly the link didnt help in my case. I implemented javascript function in onClientClick for the image as described but without effect. The class of the event stayed the same...still the general event from class CL_HTMLB_EVENT. Do you have any other idea or would you need some other information?
    Thanks!
    Frank

  • In iTunes I'm having problems changing the "Media Kind" with a number of playlists in the OPTIONS menu from "music" to "audiobook". After going through the steps, the next time I check the items have reverted back to "music". What step am I missing?

    In iTunes I'm having problems changing the "Media Kind" in the OPTIONS menu from "Music" to "Audiobook". After going through the steps, the next time I check, the items have reverted back to "Music". What must I do to save it as an "Audiobook"?

    After more digging in the Support section here and some Google work, I turned off iTunes Match and lo and behold!  I can change the media kind to Audiobook!  So, it looks like iTunes Match locked the files up somehow and for some reason.
    I went into iTunes Store > iTunes Match > "No, Thanks" to disable it on the local PC.

  • I am having problems uploading photos to websites with version 6 - it just won't work.

    Am having a problem with doing this but if I use Windows Explorer (which I'd rather not use) there is not a problem.

    I have same problem, when i try to upload any image using Firefox 4.0, and browse the image to upload, it shown a transparent mask to flash application with hand cursor mouse pointer . now again i need to click anywhere is screen to activate flash controls and then i need to click again to upload. I have this issue in FireFox 4.0 Only.
    Please advise. Thanks

  • I'm having problems syncing my outlook calender with iphone 3gs calendar

    Just recently, with the last week, the updates and additional appointments that are made in my outlook calendar are not syncronizing to my Iphone.  I am having the same problem if I add an appointment in my iphone calendar it is not syncing with my outlook calendar.  I ran the sync test in itunes and tests were sucessful. 
    iphone software version 4.3.2  Itunes version is 10.2.2.12
    Computer os - Windows xp, ms outlook 2007
    I even removed itunes applications and reinstalled on my computer. Reset iphone also. 
    I even reset sync history.
    Sync option to outlook calender is selected.
    Any other suggestions?

    The sync between the midi and the audio when I use the motion and logic the message says that the sync is failing

  • Really having problems conditioni​ng while loop with a front pannel occurance

    Hi
    I was hoping somebody may be able to help me with a problem I am having running my vi so it acts on front panel occurrences.
    The vi in question "test platform v" is in the vi library I attach with this message.
    Basically I would like the vi to run continuously and each time I change the front panel values (which set the hardware) the updating loop stops the hardware is reset and the updating loop then continues.
    I guess I need to use occurrences so that the updating loop recognizes when the front panel values have changed so the new data can be written to the hardware.
    I am having trouble working out how to do this.  I guess so event based code would be best - I ama having trouble implementing this.
    I have simplified the code a lot to make the process of what I am trying to do easier to understand.
    Hope somebody can help.
    Many Thanks
    Attachments:
    big A 2 and tourist test platform.llb ‏1616 KB

    You need a few more tricks.  The answers you seek are in a very simple solution in the attached VI.
    You need to understand events and using property nodes with Signal (Very Important)
    Matt
    www.CompleteAutomatedSolutions.com
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
    Attachments:
    genEvent.vi ‏31 KB

Maybe you are looking for