Keyboard Input Locale Error
Using Flex 3.0, targeting fp10, I'm building a rich text
editing component. Most of the keyboard input works just fine but
there is one bug.
I have a UK keyboard (and my Win Vista system language is
en-GB). When I enter text in my Flex component, however, " and @
are transposed, meaning the input works as if my keyboard were a
standard en-US. Is there a workaround for this? I don't want to
just swap the characters because our app may have users from a
number of different locales.
Thanks in advance for any assistance.
Jude Fisher / JcFx.Eu
I would certainly try another keyboard if at all possible -- could save you lots of time trying to find a potentially non-existent software issue.
Similar Messages
-
I am building a multilingual application with Designer and Forms 9i under Windows 2000 and wonder if it is possible to fix some text items to only have american input, and other text items to be multilingual.
Or let me rephrase the question - is it possible to somehow switch the Windows input keyboard and language per Forms item. Do I have to use some Windows code to do that??I am trying but i only get to check/uncheck "command+space" on both of them. My question is how to do it manually?
-
CS3 Language Keyboard Input Error
Greetings All,
I have been trouble-shooting this problem for a while, but still it is not resolved. Any help or ideas would be gladly received!
Background: We have a correctly functioning installation of Win XP, and PS CS3 Extended which appears to work normally in every other regard. No obvious errors; no crashes, no start-up complaints; nothing seemingly out of order. I use several installed languages in Windows (EngUK, Russian, Swedish, etc). All of these work normally. All of my installed fonts work correctly in every application on the system except for CS3.
There would appear to be something wrong with CS3's keyboard mapping in foreign languages. When typing with a non-English keyboard setting (any other language) and using TrueType fonts (not Open), only 'missing character' boxes appear in the artwork. The Layers menu displays the typed text correctly, but this will not appear in the artwork. If I use an old install of PS7, I can type using these same fonts correctly in any language. These layers can be imported into CS3, and these WILL display correctly on the artwork. However, the Layers menu in this case displays nonsensical characters. Ergo, I suspect that CS3's keyboard input data is errant.
Where does PS3 keep its information regarding language / keyboard layout? It is possible to edit this file(s)? Are there any other ideas regarding this problem and what might be wrong?
ThanksUnicode vs. non-Unicode. Turn off glyph substition in the character palette.
Mylenium -
hello all,
I'm having difficulty with my keyboard input.
d types out d=.
f types out 0
k types out k1
l types out l2=
; types out ;/3
delete works mostly, but sometimes types an f
caps lock also comes on by itself and also acts as return
I checked the language settings and they are all fine.
I checked SMART diagnostics, Repair Disk, Repair Disk Permissions and performed a cache cleaning.
I just updated to 10.4.9. Was running 10.4.7 and every time I tried to update the verification failed or an error was found. After running the diagnostics the update downloaded and installed successfully.
Is this something that might be able to be fixed? Or is getting a new keyboard the only option?
Any help would be appreciated.
Thanks
ARf
iMac6,1 Mac OS X (10.4.9) 2.33 Ghz Intel Core 2 Duo, 1 GB 667 MHz DDR2 SDRAMI would certainly try another keyboard if at all possible -- could save you lots of time trying to find a potentially non-existent software issue.
-
HttpServer error in reading buffer size via keyboard input - HELP
I've written a simple HttpServer program that reads keyboard input to construct a buffer to copy the requested file into the socket's output stream. I've done the string-to-integer conversion using BufferedReader and parse.Int. However, when I go to use the int later in the program, I keep getting the message "variable b may not have been initialized." Can anyone tell me what's missing from the code below? Thanks.
private static void sendBytes(FileInputStream fis, OutputStream os)throws Exception
//Construct a buffer via console input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
int b;
System.out.println("Enter desired buffer size or CTRL-C to break.");
//Convert entry to an integer
do
str = br.readLine();
try
b = Integer.parseInt(str);
catch(NumberFormatException e)
System.out.println("Invalid entry.");
while((str=br.readLine())!=null);
//Construct a buffer
byte[] buffer = new byte;
int bytes = 0;
//Begin timing HTML page delivery
long start, end;
System.out.println("Timing for Web page delivery");
start = System.currentTimeMillis();
//Copy requested file into the socket's output stream
while((bytes = fis.read(buffer)) != -1)
os.write(buffer, 0, bytes);As the message suggests, what is missing is code to initialize the variable b. The first mention ("int b;") does not initialize it. The second mention ("b = Integer.parseInt(str);") only initializes it if no exception is thrown. So it's possible for b to be uninitialized when you actually try to use it.
What do you need to change? First you need to decide what's to be done if the keyboard input isn't a valid integer. Do you have a default value in mind? If so, put that where you declare the variable ("int b = 42;"). If not, just initialize the variable to zero ("int b = 0;"). -
I have lost all reliable keyboard input to my G4 powerbook running on OSX 10.4. I have been able to run Tech Tool, Disk Repair and Repair Permissions. I don't have another users account and without the necessary input, I cannot sign-in as another user.
In all areas where text can be typed in, Text Edit, Apple Works, Authentication etc., if I get anything it is not close to the keystroke.
I show over 37gb available on a 80gb hard drive.Hi, Melvin. If your keyboard is typing a lot of numerals instead of letters, press the Num Lock key (F6) to turn off Num Lock.
If that's not the problem, connect a USB keyboard to the Powerbook and see whether it misbehaves in the same way. If it does, there's a software glitch behind the problem. To confirm that, boot to a CD or DVD. If the problem disappears, software on your hard drive is definitely at fault. In that case, while booted to the CD, run the Repair Disk and Repair Permissions functions of Disk Utility to square things away on the internal HD. Failing that, an Archive and Install of OS X should put things right.
If a USB keyboard behaves properly when connected, your built-in keyboard or its connection to the main logic board has gone bad. To determine which it is, release the keyboard, flip it over onto your Tibook's wrist rests, and gently disconnect its ribbon cable from the logic board, then reconnect it. Put the keyboard back and test again. If the problem persists, replace the keyboard. -
External Drive Disk Erase Failed with the Error Input/Output Error
I have 2 hard drives in an external FW800 enclosure that I am unable to format. When I go to initialize the drives in Disk Utility, I get the following error message: "Disk Erase failed with the error: Input/output error."
The drives show up in Disk Utility, but I can't repair them (that option is grayed out). Disk Utility correctly ID's the manufacturer of the drives (Maxtor), their size (200gb each), so it's obviously seeing that the drives are there. But it won't let me format them.
The drives are new, by the way; they don't have any data/files on them. I have Disk Warrior, but the drives don't show up there to be repaired -- probably because they aren't formatted yet.
After looking at other posts, I tried switching the jumper settings around on the drives -- from Master/Slave to cable select and back again, but it didn't help. I also tried doing a zero erase (even though the drives are new), zapping the PRAM -- again, no help.
One question I had is whether this could be a bad FW800 cable? The cable is new -- it came with the enclosure, which is an OWC Dual FW 800 enclosure. Other than that, does anyone have any other thoughts about what's causing this? Any help would be greatly appreciated.
MatthewSOLUTION!!!!
I had the exact same problem. I have the original 20 GB hard drive that came in my Powerbook G4 550MHz and a couple of years ago I traded up for a 60 GB drive and bought a FW/USB enclosure for my original drive to use it to backup my important files. I hadn't backed up in over a year (shame on me!) and I decided maybe I should erase the drive and start from scratch. It was connected via USB.
At that point DiskUtility gave me the exact same Input/Output error. I tried partitioning the drive into 1 or more partitions but came up with the same error. I couldn't figure out what was wrong so I decided to startup in OS 9.2.2, I did that and let it start up, then plugged in the hard drive and it gave me the standard "This disk is unrecognizable, do you want to eject or erase?" so I clicked Initalize. It worked!
Just make sure you choose the MacOS Extended option when initializing out of OS 9 (instead of the MacOS Standard option) so it can be read and viewed in OS X.
If your computer is too new to be able to boot from an OS 9 folder on your drive or an OS 9 CD, then see if a friend or a local library has older computers that are running OS 9 or can boot from it. If not let me know and you can send me your drive and I'll reformat it.
Kind of crazy...I haven't used the OS 9 partition on my HD in YEARS...was even thinking about erasing it since I don't use any Classic applications anymore...good thing I didn't!
Nick
Powerbook G4 550Mhz Mac OS X (10.4.6) -
SOLVED: Getting an Input/Output error when accessing certain files
My system started failing a few days ago because of sudden Input/Output errors when trying to access certain files. It was running fine until various applications started crashing like for example Pidgin (in retrospect probably because of DBus crashing). I decided to reboot and now can't login anymore because the DBus module fails to load which in turn means that HAL doesn't load either and so I can't use my keyboard to login.
The error message I get from DBus is that it can't access the file /etc/dbus-1/system.d/org.freedesktop.PolicyKit.conf because of an Input/Output error. I tried to fix/see what was wrong using the arch livecd. Because I thought my problem had to do with a pacman update that had failed before I'd rebooted, I updated my system and I noticed that when pacman tried to access other files it came back with the same error message. The files seemed pretty random, one of them was fakeroot.conf and then several library files like libfaad (sorry this is kind of vague but I'm away from home right now and can't go online very often so I'm writing this from memory).
I'm guessing its a hard drive problem because checking the filesystem for errors came back with nothing. I was just wondering whether anyone had any other ideas before I go and reinstall. I'm going back home tomorrow so I'll be able to follow any advice/reinstall then.
Last edited by siell (2010-04-08 17:01:37)UPDATE
It seems to be fixed! The second run of e2fsck fixed some more issues and the files that were causing the problems earlier seemed to have bad inodes. Boots fine now and I can get into my system. I checked and I still have a reasonable amount of free space so I don't think that was the reason ... I have no idea how the filesystem got so corrupted out of nowhere.
A few things are different, for example, it asked me to unlock the keyring and I couldn't mount my external encrypted drive anymore and had to do it manually with cryptsetup. e2fsck made quite a few changes so I imagine it's due to that. Shouldn't be to hard to fix though.
Thanks for your help! -
Default Keyboard input change in using roaming Profile on different Win 7
We found a strange problem on default Keyboard setting.
We are using roaming profiles for all users.
One of our users is using two Windows 7. One Windows 7 is VDI for working out of office and another Win 7 is her local PC.
She is only using Two keyboard input: Chinese Traditional English and Chinese Traditional Pinyin.
Whenever she had used the Windows 7 VDI, when she comes back to office and use her local PC, the default Keyboard input will automatically change to Chinese Traditional Pinyin.
The user said she had not changed any default keyboard input in the VDI of local PC.
Is there anything we can do for this issue?
IvanHi Ivan,
I am just writing to check the status of this thread. Was the information provided in previous reply
helpful to you?
Do you have any further questions or concerns? Please feel free to let us know.
If you have any feedback on our support, please click
here
Karen Hu
TechNet Community Support -
I have been building a Flex application using Flex 3 SDK Beta
2. I have run into a very anoying problem and I can't seem to find
a solution.
I have several TextInput controls scattered around my
application. I would love if these fields could accept special
characters as input. This does not seem to work though. I cant
enter danish special characters and I am having problems with most
of the other latin special characters too. Does anyone have
experience with this type of problem?
EDIT: The plot thickens. It seems that this problem only
applies to Flash Player 9 for Linux. I don't have this problem when
running Flash Player 9 for Windows.I am using revision 48 of Flash Player 9.0 for Linux. It's
seems a bit strange though, because I am using Ubuntu 6.06 at the
office and I am running 7.04 at home. Settings seem to be the same
(keyboard layout, locale and language) but I am running a newer
version of Firefox at home and in a chrooted 32-bit environment as
opposed to running a 32-bit version depending on some 32-bit
libraries.
I think I will have to search for a solution way outside the
scope of Flash Player and the Flex SDK in this case. -
[Solved] Programs hang on keyboard input (uim-xim)
Update: I've narrowed the issue down (via trial and error) to uim-xim. If it's running, it causes this problem (in XMonad) and if it isn't, gnucash has no issues. Oddly enough, when I start uim-xim by hand after gnucash, it works fine too. Starting uim-xim by hand before gnucash results in the same issue, and so I'm inclined to believe it's either an issue with XIM implementation, or simply uim-xim. Might also be a mixture of XMonad and uim-xim, as it works fine in Openbox.
I've noticed lately that certain GTK programs (I'd list them, but I haven't paid close attention until today, where I was using gnucash) work fine until I try to input anything via the keyboard. The moment I start typing (or, at the latest when I hit the shift key or backspace key) the program will hang (without any error message). I originally assumed that this was an issue with the program - not my window manager. However, I tried one of the problem programs (gnucash) in Openbox today, and it works just fine. That leads me to assume it's caused by my configuration in some way. I have absolutely no idea where to start debugging this issue.
A bit of information:
I use UIM (in both openbox and XMonad with identical configurations), run a script for a Japanese date format in XMonad (piped to dzen), and load the same xmodmap file in both window managers. Also, I start all my window managers using CDM (Console Display Manager), but in the case of XMonad I supply a bash script instead of the binary, in order to preload certain files. Also, I use a german keyboard layout.
<I removed the rest of this post because it was long and, ultimately, irrelevant>
Last edited by lswest (2012-05-01 09:53:46)spectater wrote:
Same situation, Confirmed here
I'm having the same problem with my laptop after upgrading to gnome 3 :
gnome-terminal , gedit can not accept keyboard input , lower case letters, enter , backspace and so on , but upper case letters are OK.
files can not be renamed with nautilus , also the find function affected in nautilus
while other programs such as xterm ,firefox , pidgin skype , thunar leafpad libreofficecan ...and so on work out of the box .
lower case & upper case letters all are not accepted well in my case. -
Reader Closes on any Keyboard input
Has anyone had this problem?
Reader closes on any keyboard input.
Mouse works fine. And I mean any keyboard action at anytime.
I have tried uninstalling all adobe reader apps/plugins and reinstalling the latest available version but still Reader closes with any keyboard input. Make opening password protected PDF's impossible. The "find" function unusable.
Any Ideas?Are you trying to run your application through TextPad, or some IDE? The System.in is best for command prompt input. Trying running your program through the command prompt, and it should work fine.
I replicated your error, running your application through TextPad. -
I need to get Keyboard input as well as mouse input on a JButton
I need to get Keyboard input as well as mouse input on a JButton
I have attempted to implement KeyListener. I get the keyCode but I need it to go in to the same String variable as my Actionlistener section.Here is the code I have trouble with getting keyboard input as wells as mouse input into the same variable.
public class Calctester extends JFrame
implements ActionListener, KeyListener
private double var1, var2;//var1 and var2 are used to perform calculation
String operand1 = "";//takes first input until an operator is pressed
String operand2 = "";//takes input after operator is invoked
double result;//is used to store the result
boolean flag = false;//to signal operator pressed
boolean decimalFlag = false;//to signal decimal pressed
String stringInput;//used as a temporary store for all entry to allow for conditions to be evaluated
char ch; //used to store the operator for comparison//Reason is pre does not compare using string
String pre = "";//used to store the operator
double mem; //will hold memory operation values
double vMod; //Temporary store for var2 to be used with percent operations
//Creates buttons
JButton btn0 = new JButton("0");
JButton btn1 = new JButton("1");
JButton btn2 = new JButton("2");
JButton btn3 = new JButton("3");
JButton btn4 = new JButton("4");
JButton btn5 = new JButton("5");
JButton btn6 = new JButton("6");
JButton btn7 = new JButton("7");
JButton btn8 = new JButton("8");
JButton btn9 = new JButton("9");
JButton btnC = new JButton("C");
JButton btnCE = new JButton("CE");
JButton btnBkpSpc = new JButton("Backspace");
JButton btnPlus = new JButton("+");
JButton btnMinus = new JButton("-");
JButton btnMultiply = new JButton("*");
JButton btnDivide = new JButton("/");
JButton btnEquals = new JButton("=");
JButton btnPeriod = new JButton(".");
JButton btnPlusMinus = new JButton("+/-");
JButton btnSqrt = new JButton("sqrt");
JButton btnMod = new JButton("%");
JButton btnOneOverX = new JButton("1/x");
JButton btnMC = new JButton("MC");
JButton btnMR = new JButton("MR");
JButton btnMS = new JButton("MS");
JButton btnMPlus = new JButton("M+");
//Displays Text area for Display
JTextField txtArea = new JTextField("0.");//The calculation display area set to 0.
JTextField mArea = new JTextField();//to display memory operations
//Default constructor
Calctester()
//Defines a content pane
Container c = getContentPane();
//Defines the layout of the frame and sets it to null to allow absolute positioning
c.setLayout(null);
//Defines event handling
btn0.addActionListener(this);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
btn5.addActionListener(this);
btn6.addActionListener(this);
btn7.addActionListener(this);
btn8.addActionListener(this);
btn9.addActionListener(this);
btnC.addActionListener(this);
btnCE.addActionListener(this);
btnBkpSpc.addActionListener(this);
btnPlus.addActionListener(this);
btnMinus.addActionListener(this);
btnDivide.addActionListener(this);
btnMultiply.addActionListener(this);
btnEquals.addActionListener(this);
btnPeriod.addActionListener(this);
btnPlusMinus.addActionListener(this);
btnSqrt.addActionListener(this);
btnMod.addActionListener(this);
btnOneOverX.addActionListener(this);
btnMR.addActionListener(this);
btnMS.addActionListener(this);
btnMPlus.addActionListener(this);
btnMC.addActionListener(this);
btn1.addKeyListener(this);
//Adds the buttons to the frame and sets the font of the label to be
//logical font Dialog,plain as opposed to Bold and the label size to 12
//Also sets the border type of aech button
c.add(btn0).setFont(new Font("Dialog", Font.PLAIN, 12));
btn0.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn1).setFont(new Font("Dialog", Font.PLAIN, 12));
btn1.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn2).setFont(new Font("Dialog", Font.PLAIN, 12));
btn2.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn3).setFont(new Font("Dialog", Font.PLAIN, 12));
btn3.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn4).setFont(new Font("Dialog", Font.PLAIN, 12));
btn4.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn5).setFont(new Font("Dialog", Font.PLAIN, 12));
btn5.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn6).setFont(new Font("Dialog", Font.PLAIN, 12));
btn6.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn7).setFont(new Font("Dialog", Font.PLAIN, 12));
btn7.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn8).setFont(new Font("Dialog", Font.PLAIN, 12));
btn8.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btn9).setFont(new Font("Dialog", Font.PLAIN, 12));
btn9.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnC).setFont(new Font("Dialog", Font.PLAIN, 12));
btnC.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnCE).setFont(new Font("Helvetica", Font.PLAIN, 12));
btnCE.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnBkpSpc).setFont(new Font("Dialog", Font.PLAIN, 12));
btnBkpSpc.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnPlus).setFont(new Font("Dialog", Font.PLAIN, 12));
btnPlus.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMinus).setFont(new Font("Dialog", Font.PLAIN, 12));
btnMinus.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMultiply).setFont(new Font("Dialog", Font.PLAIN, 12));
btnMultiply.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnDivide).setFont(new Font("Dialog", Font.PLAIN, 12));
btnDivide.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnEquals).setFont(new Font("Dialog", Font.PLAIN, 12));
btnEquals.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnPeriod).setFont(new Font("Dialog", Font.PLAIN, 12));
btnPeriod.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnPlusMinus).setFont(new Font("Dialog", Font.PLAIN, 12));
btnPlusMinus.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMod).setFont(new Font("Albertus Medium", Font.PLAIN, 12));
btnMod.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnSqrt).setFont(new Font("Microsoft San Serif", Font.PLAIN, 11));
btnSqrt.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnOneOverX).setFont(new Font("Dialog", Font.PLAIN, 12));
btnOneOverX.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMC).setFont(new Font("Dialog", Font.PLAIN, 12));
btnMC.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMS).setFont(new Font("Dialog", Font.PLAIN, 12));
btnMS.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMR).setFont(new Font("Dialog", Font.PLAIN, 12));
btnMR.setBorder(new BevelBorder(BevelBorder.RAISED));
c.add(btnMPlus).setFont(new Font("Dialog", Font.PLAIN, 12));
btnMPlus.setBorder(new BevelBorder(BevelBorder.RAISED));
//sets the color of the label of the buttons
btnC.setForeground(Color.red);
btnCE.setForeground(Color.red);
btnBkpSpc.setForeground(Color.red);
btnDivide.setForeground(Color.red);
btnMultiply.setForeground(Color.red);
btnMinus.setForeground(Color.red);
btnPlus.setForeground(Color.red);
btnMC.setForeground(Color.red);
btnMR.setForeground(Color.red);
btnMS.setForeground(Color.red);
btnMPlus.setForeground(Color.red);
btnEquals.setForeground(Color.red);
btn0.setForeground(Color.blue);
btn1.setForeground(Color.blue);
btn2.setForeground(Color.blue);
btn3.setForeground(Color.blue);
btn4.setForeground(Color.blue);
btn5.setForeground(Color.blue);
btn6.setForeground(Color.blue);
btn7.setForeground(Color.blue);
btn8.setForeground(Color.blue);
btn9.setForeground(Color.blue);
btnPlusMinus.setForeground(Color.blue);
btnSqrt.setForeground(Color.blue);
btnMod.setForeground(Color.blue);
btnOneOverX.setForeground(Color.blue);
btn0.setFocusPainted(false);
btnPlus.setFocusPainted(false);
btnEquals.setFocusPainted(false);
//The display text area and the memory operation text area
c.add(txtArea);
txtArea.setBorder(new BevelBorder(BevelBorder.LOWERED));
txtArea.setBounds(7,0,240,25);//To provide a Text box @ the top of the frame
txtArea.setEditable(false);
txtArea.setBackground(Color.white);
c.add(mArea);
mArea.setBounds(13, 35, 28, 25);
mArea.setEditable(false);
mArea.setBorder(new BevelBorder(BevelBorder.LOWERED));
setSize(260,251);//size of the frame
setTitle("Calculator"); //Title
setVisible(true); //this makes the frame visible on the screen
setResizable(false); //this disallow resizing of the frame
setDefaultCloseOperation(EXIT_ON_CLOSE);//to close app
//instead of the above method you can use the WindowsListener which extennds other classes and implements other interfaces.
setLocation(300,200);//positioning of the window on the screen
txtArea.setHorizontalAlignment(JTextField.RIGHT);//sets the text in the text field to the right
mArea.setHorizontalAlignment(JTextField.CENTER);//centers the label
JMenu editMenu = new JMenu("Edit");//creates menu
JMenuItem copy = new JMenuItem("Copy Ctrl+C");//creates menu item
copy.addActionListener(this);//event handling
JMenuItem paste = new JMenuItem("Paste Ctrl+V");//creates menu
paste.addActionListener(this);//event handling
JMenuBar myMenu = new JMenuBar();//declares a menu bar
setJMenuBar(myMenu);//adds the menu bar to the frame
editMenu.setBorderPainted(false);//removes the border shadow around the menu bar
myMenu.setBorderPainted(false);//removes the border shadow around menu bar
//adds menu items to the menu, sets the font and font size.
editMenu.add(paste).setFont(new Font("Dialog", Font.PLAIN, 12));//
editMenu.add(copy).setFont(new Font("Dialog", Font.PLAIN, 12));
myMenu.add(editMenu).setFont(new Font("Dialog", Font.PLAIN, 12));
JMenu viewMenu = new JMenu("View");//creates menu
JMenuItem sci = new JMenuItem("Scientific");//creates menu item
sci.addActionListener(this);//event handling
JMenuItem std = new JMenuItem("Standard");//creates menu item
//adds menu items to the menu, sets the font and font size.
viewMenu.add(sci).setFont(new Font("Dialog", Font.PLAIN, 12));
viewMenu.add(std).setFont(new Font("Dialog", Font.PLAIN, 12));
myMenu.add(viewMenu).setFont(new Font("Dialog", Font.PLAIN, 12));
JMenu helpMenu = new JMenu("Help");//creates menu
JMenuItem helpTopics = new JMenuItem("Help Topics");//creates menu item
JMenuItem aboutCalc = new JMenuItem("About Calculator");//creates menu item
helpTopics.addActionListener(this);//event handling
//helpTopics.setBorder(new BevelBorder(BevelBorder.RAISED));
helpTopics.setBorder(LineBorder.createGrayLineBorder());
//adds menu items to the menu, sets the font and font size.
helpMenu.add(helpTopics).setFont(new Font("Dialog", Font.PLAIN, 12));
helpMenu.add(aboutCalc).setFont(new Font("Dialog", Font.PLAIN, 12));
myMenu.add(helpMenu).setFont(new Font("Dialog", Font.PLAIN, 12));
//aboutCalc.setBorder(new BevelBorder(BevelBorder.RAISED));
aboutCalc.setBorder(LineBorder.createGrayLineBorder());
//aboutCalc.setActionCommand("Nothing here right now");
//Setting absolute positions for the buttons.
btn0.setBounds(50, 160, 35, 28);
btn1.setBounds(50, 130, 35, 28);
btn2.setBounds(90, 130, 35, 28);
btn3.setBounds(130, 130, 35, 28);
btn4.setBounds(50, 100, 35, 28);
btn5.setBounds(90, 100, 35, 28);
btn6.setBounds(130, 100, 35, 28);
btn7.setBounds(50, 70, 35, 28);
btn8.setBounds(90, 70, 35, 28);
btn9.setBounds(130, 70, 35, 28);
btnC.setBounds(180, 35, 63, 28);
btnCE.setBounds(115, 35, 63, 28);
btnBkpSpc.setBounds(50, 35, 63, 28);
btnPlus.setBounds(170, 160, 35, 28);
btnMinus.setBounds(170, 130, 35, 28);
btnMultiply.setBounds(170, 100, 35, 28);
btnDivide.setBounds(170, 70, 35, 28);
btnEquals.setBounds(210, 160, 35, 28);
btnPeriod.setBounds(130, 160, 35, 28);
btnPlusMinus.setBounds(90, 160, 35, 28);
btnMC.setBounds(8, 70, 35, 28);
btnMR.setBounds(8, 100, 35, 28);
btnMS.setBounds(8, 130, 35, 28);
btnMPlus.setBounds(8, 160, 35, 28);
btnSqrt.setBounds(210, 70, 35, 28);
btnMod.setBounds(210, 100, 35, 28);
btnOneOverX.setBounds(210, 130, 35, 28);
// btn7.addKeyListener(this);
try
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
catch (Exception e)
System.out.println("Could not load Metal Look and Feel");
public void keyReleased(KeyEvent e)
//btn1 = txtArea.getRegisteredKeyStrokes();
// System.out.println(1);
// keyTyped();
public void keyPressed(KeyEvent e)
//if (e.getActionCommand().equals("1"));
//(e.getKeyText().compareTo("1"));
//(e.getKeyCode().equals("1"));
//else
System.out.println("Error");
//keyTyped();
public void keyTyped(KeyEvent e)
//displayInfo(e, "KEY TYPED: ");
System.err.println("KeyTyped >>> " + e.KEY_TYPED);
//keyEvent.keyTyped();
// e.KEY_TYPED;
/* protected void displayInfo (KeyEvent e, string s)
{KeyCodeString;
int keyCode = e.getKeyCode();
keyCodeString = "key code " + keyCode
+ "("
+ KeyEvent.getKeyText(keyCode);
public void actionPerformed(ActionEvent e)
stringInput = e.getActionCommand();
System.out.println("First stringInput action performed>>" +stringInput);
System.out.println("First pre action performed>>" +pre);
if (stringInput == "C")
operand1 = "";
operand2 = "";
var1 = 0;
var2 = 0;
var1 = result;
txtArea.setText("0.");
flag = false;//to force the operations to jump to operand 1 and go through the loop as normal
pre = "";
if (stringInput == "CE")
operand2 = "";
var2 = 0;
txtArea.setText("0.");
flag = true;//to force the operations to jump to operand 1 and go through the loop as normal
if (stringInput == "MR")
if (var1 != 0)
txtArea.setText(Double.toString(var1));
mArea.setText("M");
System.err.println("mem@operand1 >> "+ mem );
else if (var2 != 0)
txtArea.setText(Double.toString(var2));
mArea.setText("M");
System.err.println("mem @ mR else>> "+ mem );
if (stringInput == "MS")
mArea.setText("M");
if (operand1 != "")
mem = var1;
else if (operand2 != "")
mem = var2;
else
mem = 0;
if (stringInput == "MC")
mArea.setText("");//to clear the text area display
mem = 0;//to reset the variable
if (stringInput == "M+")
mArea.setText("M");
flag = true;//to force the operations to jump to operand 2 and go through the loop as normal
if (stringInput == "=")
//result = evaluate();
txtArea.setText(Double.toString(result));
System.out.println("Equals>>" +stringInput);
System.out.println("Equals>>" +pre);
System.err.println("The flag at equals is " + flag);
if (stringInput == "+"||stringInput == "-"||stringInput == "/"||
stringInput == "*"||stringInput == "=")
pre = pre.concat(stringInput);
System.out.println("Second action perfo/check for operator>>" +stringInput);
System.out.println("Second pre action perfo/check for operator>>" +pre);
operand2 = "";
System.err.println("The flag at +,- etc is " + flag);
if(!flag &&(stringInput == "*"|| stringInput == "/"))
var2 = 1;
stringInput = "";
flag = true;
if(!flag)
stringInput = pre;
System.out.println("if flag true/stringInput" +stringInput);
System.out.println("flag true/pre" +pre);
else
//These statements extract the operator
stringInput = pre.valueOf(pre.charAt(pre.length()-2));
ch = pre.charAt(pre.length()-2);
System.out.println("@ position -2 stringInput" + pre.valueOf(pre.charAt(pre.length()-2)));
System.out.println("@ position -2 pre" + pre.charAt(pre.length()-2));
result = evaluate();
var2 = 0;
operand2 = "";
txtArea.setText(Double.toString(result));
System.out.println("Total is " + result);
flag = true;
if(!flag &&(stringInput == "*"|| stringInput == "/"))
var2 = 1;
stringInput = "";
flag = true;
if (stringInput == "%")
//evaluate();
txtArea.setText(Double.toString(result));
System.err.println("mem @ mR else>> "+ result + " %" );
if (stringInput == "1/x")
if (operand1 != "")
txtArea.setText(Double.toString(1/var1));
//System.err.println("mem@operand1 >> "+ mem );
else if (operand2 != "")
operand2 = "";
txtArea.setText(Double.toString(1/var2));
//System.err.println(">> "+ mem );
if (Character.isDigit(stringInput.charAt(0))||stringInput == ".")
System.out.println(operand1);
if (stringInput == "." && operand1 == "")
operand1 = "0";
System.out.print("fail op1");
if (stringInput == "." && operand2 == "")
System.out.print("fail op2");
operand2 = "0";
if (flag==false)
operand1 = operand1.concat(stringInput);
result = Double.parseDouble(operand1);
System.out.println("op1 =>" + operand1);
txtArea.setText(operand1);
//result = var1;
System.out.println("result after var1 = result " + result);
else
operand2 = operand2.concat(stringInput);
var2 = Double.parseDouble(operand2);
//var2 = vMod;
System.out.println("op2 =>" + operand2);
txtArea.setText(" ");//to clear the text area
txtArea.setText(operand2);//to display the second number if (operators == "+")
System.out.println("result after var2 " + result);
public double evaluate()
if (ch == '+' )
result = result + var2;
if (ch == '-' )
result = result - var2;
if (ch == '/' )
result = result / var2;
if (ch == '*' )
result = result * var2;
if (ch == '%')
var2 = Double.parseDouble(operand2);
result = result/vMod*100;
System.out.println("% "+ result);
return result;
public static void main(String [] args)
Calctester x = new Calctester();
} -
Keyboard Input Output Problems on Mac OS X
Hey guys,
I'm at college studying Java, however my teacher and the rest of the class all use the Kawa IDE, I've been using Project Builder, provided with Mac OS X. Our tutor gave us a class made up of various methods which the college designed to handle keyboard Input and Output, however when I import it I get unpredictable results. I've put it online at: http://www.lostroom.co.uk/inout/
All I'm trying to do is run a simple program;
import InOut;
class CostReckoner
public static void main(String[] args)
// Declare the variables
int quantity;
double unitCost, basicCost, vatCost, totalCost;
double vatRate = 0.175;
// Input the number of items and the cost per item
System.out.print("What is the unit cost of the items?");
unitCost = InOut.readDouble();
System.out.print("How many items in the order?");
quantity = InOut.readInt();
// Calculate the cost of the order
basicCost = unitCost * quantity;
vatCost = basicCost * vatRate;
totalCost = basicCost + vatCost;
//Output the total cost of the order
System.out.println("Cost �"+InOut.format(basicCost,2));
System.out.println("Vat �"+InOut.format(vatCost,2));
System.out.println("Total �"+InOut.format(totalCost,2));
I seem to need to press space bar after I input anything, as it doesn't recognise "Return" without it. Any ideas ??
Strange thing is it seems to work fine on the PC Kawa IDE within college. Any advice you guys could offer would be really appreciated. Send me an email at: <[email protected]> if you can help.
Regards, GarethHi thanks for your help, I tried compiling the code you gave me to read the streams, however I seem to be have problems with it.
ERROR
keys.java:18: unreported exception java.io.IOException; must be caught or declared to be thrown
n=stream.read();
HERE IS THE CODE I'M TRYING TO COMPILE
import java.io.*;
public class keys {
public static void main(String[]arguments)
BufferedInputStream stream = new BufferedInputStream(System.in);
int n=0;
while(true){
n=stream.read();
System.out.println(Integer.toHexString(n));
if (n==0x30) break;// this termination condition is optional
Any ideas ?? -
Suspend almost working, input/output error after resume
Hi,
I have gotten suspend to ram almost working on my sony vaio sz 28 laptop. It resumes properly and I can use the terminal to list files for a while, but I cannot launch any programs, I get "input output error" It's like the machine cannot do anything new that wasn't started before the suspend. After a while some programs quits (nm-manager), because of I/O error, and then shutdown won't even finish. At first I tought the hard drive didn't work, but since I can list files in the terminal, that shouldn't be the problem.
Any ideas ?
My /etc/powersave/sleep contains
UNLOAD_MODULES_BEFORE_SUSPEND2RAM="prism54 ipw3945 i810 sky2 ath_pci "
and
SUSPEND2RAM_RESTART_SERVICES="ipw3945d networkcpufreq"
thanks,
SteinarI am running powersaved on a vaio c2z laptop with this config. Maybe it helps.
UNLOAD_MODULES_BEFORE_SUSPEND2RAM=""
SUSPEND2RAM_RESTART_SERVICES=""
SUSPEND2RAM_SWITCH_VT="yes"
Also you dont need to run the cpufreq service powersaved and the acpid can do this too. I disabled all of them and let the kernel
handel my cpufreq. The only thing iam doing is to tell the system on startup which govenour it should use by default, for me thats "conservative".
#!/bin/bash
# /etc/rc.local: Local multi-user startup script.
cpufreq-set -c 0 -g conservative
cpufreq-set -c 1 -g conservative
If i need another one i can adjust that via the terminal (cpufreq-set or via direct echo in /sys) or gnomes cpufreq applet.
For using the kernel handler correctly you have modify these entries
1. in /etc/powersave/cpufreq to prevent powersaved from setting cpufreq.
CPUFREQ_ENABLED="no"
2. in /etc/acpi/handlers.sh to prevent acpid from setting corespeed back to kernels default govenour (mostly performance) after returning from suspend.
ac_adapter)
case "$2" in
AC)
case "$4" in
00000000)
echo -n $minspeed >$setspeed <--- add a # before this command
#/etc/laptop-mode/laptop-mode start
00000001)
echo -n $maxspeed >$setspeed <--- add a # before this command
#/etc/laptop-mode/laptop-mode stop
esac
*) logger "ACPI action undefined: $2" ;;
esac
Have fun
Maybe you are looking for
-
How can I share calendars between two different people?
I am trying to share my ICAL with my wife and she wants to do the same with me. For some reason I cannot find the path to allow us to see each otjer's calendars. Any ideas? Thanks Don
-
DAQmxRegisterEveryNSamplesEvent is never called in MFC environment
Hello? I'm uing DAQmx8.9 version with Visual C++ 6. DAQmxRegisterEveryNSamplesEvent is never called in MFC environment. Do I have to upgrade to .Net base compiler? I have Visual Studio 2008 and will install this tomorrow to see if this may work in .
-
0 risks found in while approving role in workflow of CUP
Hi All, I am using one stage work flow. I created one change request to add one role , it is created and while manager is approving the role, he ran the risk analysis, but it is showing zero risks. where as in RAR/CC for the same role we have 2 risk
-
Converting HTML Forms to PDF - Field Names
When I use Adobe 8 to convert and HTML form to PDF all the field names in the resulting PDF have the crazy long names that are jumble of letters and numbers. So I always have to go back through and manually rename every field because I'm using anothe
-
The Critical message is: MID 25342101 antivirus server error Version: 6.1.0-301