How can I associate an ActionListener with a specific button
I modified the code a lot. Everything works except that it does not associate the actionListener with the button. It will do the action when the window is minimized or maximized, but not when the button is clicked.
//July 2, 2011
//Multiplication Tables
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MultTables extends JApplet implements ActionListener
//Create Variables for Multiplication Problems
int factorX = 1;
int factorY = 1;
int productZ = 1;
int productReply;
//Create the TextField
JTextField answer = new JTextField(10);
//Create Labels and buttons
JLabel productZLabel = new JLabel(factorX + " * " + factorY + " = ");
JButton checkAnswer = new JButton("Check Answer");
//Create a container
Container con = getContentPane();
FlowLayout flow = new FlowLayout();
public void init()
//What goes init? What needs to be added to the interface?
con.setLayout(flow);
//Add Components and create interface
con.add(productZLabel);
con.add(answer);
con.add(checkAnswer);
//Add ActionListener to button
checkAnswer.addActionListener(this);
public void actionPerformed(ActionEvent e)
productZ = factorX * factorY;
String productReplyString = (answer.getText());
productReply = (Integer.valueOf(productReplyString));
for(int sub = 1; sub <= 9; ++sub);
if (productReply == productZ)
JLabel correct = new JLabel("That is correct!");
con.remove(productZLabel);
con.remove(answer);
con.remove(checkAnswer);
con.add(correct);
++factorX;
else
JLabel incorrect = new JLabel("The correct answer is " + productZ);
con.remove(productZLabel);
con.remove(answer);
con.remove(checkAnswer);
con.add(incorrect);
++factorX;
}
EJP wrote:
Are you sure you're running that code? It should work. ActionListeners don't respond to min/max events.Yup. But the repaint triggered by resizing updates the display.
db
Similar Messages
-
How can I associate 2 appleids with one account or use a different Appleid for imessage as described in another post?
I have rejoined the iPhone community, not with one iPhone but with two. My wife agreed to move from the unenlightened!
I have set up both under my apple account and want to keep it that way. But I do not want iMessages going to both phones. I would like separate message queues but share all apps and other purches from the store.
I have created a separate AppleID for her but under Settings>Message>Receive At (it currently says 2 addresses) > ... will not allow me to change the current eMail address and when I add hers (her appleid) it errors out. The only thing I can do in the Apple ID field is to manage my account and not change it to hers.
How can I have 2 iPhones (and my iPad) on the same account but have separate identies?
Thanks,
LpGrumpy1. Yes. Restart with the Option key held down as needed.
2. No, it won't be a problem.
(83373) -
How can I associat ".swf" files with flashlite 2.1
How can I associate ".swf" files with flashlite 2.1? When I
install flash lite 2.0,it can do ---- click .swf files system can
autoly use flashlite to play.But now I install flashlite 2.1,it
lost this ability return as "unknow files formate".
Now,how can I reassociate ".swf" with flashlite 2.1?
first: I must use flashlite 2.1.
second:I must click .swf file directly.
I know another way to open :open the player and then find the
.swf,and open it. But ,unfortunately,I can not use this way to
open.Now I will be looking for another way.unfortunately, the 2.1 developer edition you have installed
has not overwritten the original version integrated into the
symbian OS by the manufacturer. This means that the only way to
open the 2.1 files is to open the 2.1 player from your apps menuu,
and click on the swf file. You will only get direct access if the
updated player is in a firmware update for you handset.
Matt
http://www.outside-media.co.uk/blog -
How can i associate a template with my message,
hi,
how can i associate a template with my message only.
where is the location of templage file?
thanks in advance.
zam_orahi,
i found out system Mailer item type and messages.
so i hople , i could take a copy of the template message and modify and associate with my notification , right?
but how i know , which template my notification is currently using.?
we are using Outlook as email client.
thanks.
zam_ora -
How can I associate file types with Dreamweaver so they open automatically?
I've just installed Dreamweaver CS4 under Windows XP
Professional but I've an issue with which files types are
associated with Dreamweaver.
When I first ran DW CS4 the application invited me to select
which type of files to associate with Dreamweaver: .css, .js,
.xslt, php, etc. I deselected a few as I was using another editor
for those at the time. However, I would now like to associate PHP
files with Dreamweaver CS4, so that when I double-click a PHP file
in Windows Explorer it opens in Dreamweaver CS4.
How can I do this?
Is there a way to run the initial dialog box again that
invited me to select which files to associate with Dreamweaver?
Thanks in advance
GarethHowever, I would
> now like to associate PHP files with Dreamweaver CS4, so
that when I
> double-click a PHP file in Windows Explorer it opens in
Dreamweaver CS4.
Browse to any PHP file with Windows Explorer, right click
then select Open
With..., Choose Program and select DW CS4 (and tick the
"Always..." box to
make this the default file association)
Regards
John Waller -
How can i associate the iPad with my account?
Hi,
i got a new ipad 2, first thing ive synchronized it with my iTunes, but i cant download new tv episodes from on the ipad 2. when i downloaded a new app on it ive receive an email saying that the app was downloaded on a computer or device that had not previously been associated with this apple id?
plus how can i authorise a computer to this account?
thanks in advance for the support,
Yasser.Thank you for your reply. But I am still facing the same problem. When I get an email notifying me that a news episode is out for the season pass t bought I press on the link to dounload it takes me to ituens and I immediately get a msg saying can't connect to iTunes. After dismissing the msg iTunes opens but in the download section it dose not start to download.
I have to open my MacBook use the iTunes to download then synchrenize.
In my first iPad I used to download straight into my iPad.
Hope I get help for this.
Thanks. -
How can I delete songs associated with a specific iTunes account?
They are songs that I accidentally pulled onto my machine from a friends and I don't want them. Anytime I run across one it asks for their password. I'd like to delete all of the songs associate with her ID en masse. Any thoughts?
You can swipe and delete the individual songs from within the music app
Or delete all of the music at once from settings/usage/music
You will have to either synch with your own library again via iTunes or re download via the iTunes Store and going to purchased
I don't know of away to delete just the music specific to one account -
How can my IDoc create shipment with a given number
Hi,
I m using IDoc type SHPMNT03, message type SHPMNT and precess code SHPM to create shipment document via EDI.
How can I generate a shippment with a specific number and not with the number genetrated automatically??
thx in advance.I think it s possible, because I ve already done the same with reservations, I created reservations with my own numbers...
-
how can I cancel an order made as apple guest? or how can i associate it with an account?
You should still have an order number
call 1-800-MY-APPLE -
How do I associate a device with my Apple ID?
I have an iPad and an iPhone. I sync them with my iMac desktop computer, and never with any other. I always use the same Apple ID. As far as I know, it's the only one I have.
Recently, I purchased an app using my iPad. The next time I synced the iPad with the computer, I got an alert saying "The purchased item 'App' on the iPad
'Etchemendy's iPad' could not be transferred to your iTunes library because you are not authorized for it on this computer." The alert goes on, in fine print, to say, "To authorize this computer for items purchased from the iTunes Store, choose Store > Authorize This Computer."
So I choose Store > Authorize This Computer, and I get a second alert saying, "This computer is already authorized." A nifty little continuous loop that neatly precludes me from using the app on any device except the one I used to purchase it.
But it gets better. In stumbling around trying to figure out what's going on here, I accessed "My Account" using iTunes on my desktop computer (logging in with the same Apple ID I used to purchse the troublesome app). When I click "Manage Devices," I arrive at a box that says, "These computers and devices are associated with your Apple ID for Automatic Downloads or to download previously purchased music, apps, and books..." It then gives me a "list" showing just one device -- my iPhone. The iPad is not shown here. Neither is the desktop computer iTunes just told me is already authorized. There's a button that says "Remove" next to the iPhone. And two bigger buttons. One says "Cancel" and the other says "Done." There is no "add a device" option.
So how to I associate a device with my Apple ID? And, as a matter of fact, why aren't all the devices I registered using my Apple ID already associated with it? I never had any of these problems till the big iOS system upgrade a few months ago. Since which, my interactions with Apple have nearly all been nightmarish. Apple obviously put the WAY wrong guy in charge of iOS development.
Oh. And BTW, when I look at the drop-down menu for choosing the "product" I'm having a problem with, only about half the devices registered with my Apple ID appear there. And I have no clue what kind of iPad I currently have. I have the warranty right in front of me, and all it says is "iPad WiFi 64GB Black." No doubt if I try to solve this using Apple phone support, I'll have to pay $20 to straighten out Apple's problem for them. Which is why I'm here.My guess is you're using a long Apple ID and just omitted or mistyped a letter sometime, or something similar.
Anyway, the way to recover is this:
You cannot change ownership of the mistyped Apple ID to the correct one. After all, the mistyped one purchased it. However, you can authorize purchases from the mistyped Apple ID on your devices by doing Store > Authorize This Computer on iTunes on your computer, and enter the mistyped Apple ID and password. Then sync again and you'll be all set.
When you change computer (e.g., sell your current one and buy a replacement), you'll have to repeat this process. -
How can i plot a histogram with using the results of Line Length
PLS HELP.How can i prepare a histogram with using the results of line length code(It is somewhere in the middle).
This is a final exam take-home question. I would appreciate if you can help?
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.text.*;
import java.io.File;
public class WordAnalyser extends JFrame implements ActionListener
private JMenuItem jmiAc, jmiSil, jmiCikis, jmiAnaliz, jmiHakkinda, jmiKullanim;
private JTextArea jta1, jta2;
private JFileChooser jFileChooser = new JFileChooser();
File hafizada;
File aktarilan = new File("Sonuc.txt");
// Main method
public static void main(String[] args)
WordAnalyser frame = new WordAnalyser(); /* Ana ekran olusturulur */
frame.setSize(400, 300); /* Degerleri belirlenir */
frame.setVisible(true); /* Gorunebilirligi ayarlanir */
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public WordAnalyser()
setTitle("Serkan Ozgen Dosya Inceleme Programina Hos Geldiniz");
JMenuBar mb = new JMenuBar();
setJMenuBar(mb);
JMenu fileMenu = new JMenu("Dosya");
fileMenu.setMnemonic('F');
mb.add(fileMenu);
JMenu helpMenu = new JMenu("Degerlendirme");
helpMenu.setMnemonic('H');
mb.add(helpMenu);
JMenu kullanimMenu = new JMenu("Kullanim Kilavuzu");
mb.add(kullanimMenu);
fileMenu.add(jmiAc = new JMenuItem("Ac", 'A'));
fileMenu.add(jmiSil = new JMenuItem("Sil", 'S'));
fileMenu.add(jmiCikis = new JMenuItem("Cikis", 'C'));
helpMenu.add(jmiAnaliz = new JMenuItem("Analiz", 'D'));
helpMenu.add(jmiHakkinda = new JMenuItem("Hakkinda", 'H'));
kullanimMenu.add(jmiKullanim = new JMenuItem("Kullanim"));
getContentPane().add(new JScrollPane(jta1 = new JTextArea()), BorderLayout.CENTER);
getContentPane().add(jta2 = new JTextArea(), BorderLayout.SOUTH);
jmiAc.addActionListener(this);
jmiSil.addActionListener(this);
jmiCikis.addActionListener(this);
jmiAnaliz.addActionListener(this);
jmiHakkinda.addActionListener(this);
jmiKullanim.addActionListener(this);
public void actionPerformed(ActionEvent e)
String actionCommand = e.getActionCommand();
if (e.getSource() instanceof JMenuItem)
if ("Ac".equals(actionCommand))
Ac();
else if ("Sil".equals(actionCommand))
Sil();
else if ("Cikis".equals(actionCommand))
System.exit(0);
else if ("Analiz".equals(actionCommand))
sayim();
else if ("Hakkinda".equals(actionCommand))
JOptionPane.showMessageDialog(this,
"!!!! Bu program text analizi gerceklestirir. Her hakki saklidir SERKAN OZGEN!!!!",
"Bu program hakkinda",
JOptionPane.INFORMATION_MESSAGE);
else if ("Kullanim".equals(actionCommand))
JOptionPane.showMessageDialog(this,
" Ilk once dosya menusunden Ac i tiklayarak analiz etmek istediginiz Dosyayi seciniz (Lutfen uzantisi *.txt \nveya *.log olsun). Daha sonra Degerlendirme menusunden analizi tiklarsaniz dosyanizda kac adet rakam, harf, \ncumle ve kelime oldugunu gorebilirsiniz. Simdiden kolay gelsin",
"Programin kullanim detaylari",
JOptionPane.INFORMATION_MESSAGE);
private void Ac()
if (jFileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
hafizada = jFileChooser.getSelectedFile();
Ac(hafizada);
// Acilan Dosyayi ana ekranda gostermeye yariyan bir method
private void Ac(File file)
try
// Acilan dosyayi okuma ve ana ekranda gosterme
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
byte[] b = new byte[in.available()];
in.read(b, 0, b.length);
jta1.append(new String(b, 0, b.length));
in.close();
catch (IOException ex)
// Temizle tusunun hangi ekranlara etki edecegini secme
private void Sil()
jta1.setText("");
jta2.setText("");
private void sayim()
int buff;
int sayac = 0;
int Cumleler = 0;
int Kelimeler = 0;
int Karakterler = 0;
int Satirlar = 0;
int Rakamlar = 0;
boolean start = true;
int linenum = 0;
try
FileInputStream instream = new FileInputStream(hafizada);
FileOutputStream outstream = new FileOutputStream(aktarilan);
BufferedReader infile = new BufferedReader(new InputStreamReader(new FileInputStream(hafizada)));
PrintStream out = new PrintStream(outstream);
out.println("---Kelime Avcisinin Sonuclari---");
String line = infile.readLine();
while (line != null){
int len = line.length();
linenum++;
line = infile.readLine();
out.println("Line Length :" + linenum + "\t" +len);
while ((buff=instream.read()) != -1)
switch((char)buff)
case '?': case '.': case '!': /* Eger "?", "." veya "!" gorurse program cumleleri ve kelimeleri arttirir*/
if (start == false)
Cumleler++;
Kelimeler++;
start = true;
break;
case ' ': case '\t': case ',': case ';': case ':': case'\"': case'\'': /* Eger /t,;:\ ve \" bu isarteleri goruruse program kelimeleri arttirir */
if (start == false)
Kelimeler++;
start = true;
break;
case 'n': case '\n': /* Eger \n gorurse satirlari arttirir */
if (start == false)
Satirlar++;
Kelimeler++;
start = true;
break;
default:
if (((char)buff >= 'a' && (char)buff<='z')|| /*a-z, A-Z veya - degerlerini gorurse karakterler arttirilir */
((char)buff >= 'A' && (char)buff<='Z')||
((char)buff == '-'))
Karakterler++;
if ((Kelimeler % 50) == 49)
if (start == true)
out.println();
out.print((Kelimeler+1) + " ");
out.print((char)buff);
start = false;
if ((char)buff >='0' && (char)buff <='9') { /* 0-9 gorurse rakamlari arttiri */
Rakamlar++; }
}// switch
}//while
instream.close();
out.println();
out.println();
out.println("Karakter sayisi: " + Karakterler);
out.println("Kelime sayisi: " + Kelimeler);
out.println("Cumle sayisi: " + Cumleler);
out.println("Satir sayisi: "+ Satirlar);
out.println("Rakam sayisi: "+ Rakamlar);
outstream.close();
try
BufferedInputStream in = new BufferedInputStream(new FileInputStream(aktarilan));
byte[] b = new byte[in.available()];
in.read(b, 0, b.length);
jta2.append(new String(b, 0, b.length));
in.close();
catch (IOException ex)
catch (Exception e)
System.out.println(e);
}Why is it that you're not interested in IOExceptions?
catch (IOException ex)
} Empty catch blocks is a hallmark of foolish Java code. At least print out the stack trace.
% -
How can I use an iPad with two itunes accounts?
How can I use an iPad with two itunes accounts?
Hi there
My partner has a works iPad, which has her works Apps on (ones that are specifically made by her company and are NOT available in the App store).
What I want to be able to do is to ALSO have my itunes account on there so that I can put all the apps I have purchased previously from my iPhone on it.
This is so I can put on VLC player (thats already in my itunes account) so I can add videos to the iPad.
How do I do this please?
I tried it before by connecting it to my mac, but it wiped everything off the iPad completely and also deleted the data settings for using 3G.
So I want to avoid this happening again the future as it had to be sent back to her head office to be sorted again.
Any advise please?
ThanksYou can't. The iPad is desgined to be a 'one user' device and only really works with one apple ID at a time.
The only way would be if she, at work and with her work apple id, downloaded your apps (repurchasing them of course).
It's not meant to be a multiple user/multiple ID device. -
I purchased an ablum thru itunes on my phone and it says i purchased the songs on itunes but when i go on my music it says i have to repurchase all the songs how can i get the songs with out havin to pay again
Whether you can redownload music depends upon what country that you in. If you are using your computer's iTunes then does music show in the Purchased link under Quicklinks on the right-hand side of the iTunes store home page (on your phone you might be able to redownload media via the Purchased tab in the iTunes store app) ? If music shows there, but not that album, then check to see if it's hidden : http://support.apple.com/kb/HT4919
If you aren't in a country when you can redownload music and it's still on your phone then you should be able to copy it over from the phone via File > Devices > Transfer Purchases. -
How can i create excel sheet with multiple tabs using utl file?
how can i create excel sheet with multiple tabs using utl file?
any one help me?Jaggy,
I gave you the most suitable answer on your own thread yesterday
Re: How to Generating Excel workbook with multiple worksheets -
My neighbour's Mac Book Pro shows up as discoverable in my Bluetooth list on my iPad Air. How can I block her Bluetooth device? How can I prevent her pairing with my device? I need Bluetooth to stream music on my Bose system. Thanks!
If your device is discoverable, the other BT device would try (I am not sure if that would be successful). If it was, it would appear in your system preferences>Bluetooth.
Take a look at this re: security:
http://support.apple.com/kb/PH10786
This is from another Apple article:
Use Bluetooth
You can wirelessly transfer files between computers—even Mac to PC—using the Bluetooth File Exchange utility. You can even browse selected devices and retrieve files remotely. For extra security, you can stipulate that only trusted devices be allowed to connect to your Mac, and 128-bit over-the-air encryption is also available
Barry
P.S. Since I have not had the issue, I have not researched this before. Thank you for making me look into BT security
Message was edited by: Barry Hemphill
Maybe you are looking for
-
HT4236 How do I get 4 g on my ipad
Verizon 4g doesn't load on my iPad. I get 3G but it looses Internet all the time. Ant pointers
-
Hi, I have a table with a background image inside one of the cells, I would like to change this background image when the page refreshes. i cant figure out how to do it! It is here: www.morgansilva.com THanks!
-
Application Server Version 4.0.7 and NT Service Pack 5
Hi there, has someone experience with the environment Application Server Version 4.0.7 on Windows NT 4.0 with Service Pack 5 ? Are there serious problems? Which problems? I am strongly interested for any commend. Thanx Lars null
-
Diff between Oracle 9i Standard Editionand Oracle 9i Enterprise Edition
what is the diff between Oracle 9i Standard Edition and Oracle 9i Enterprise Edition
-
ThinkVantage Productivity Centre/Password Manager for Windows 7 Beta?
Hi, i've noticed that there's no beta build of ThinkVantage Productivity Centre for Windows 7 Beta. Is Lenovo intending to release one? But most important of all(my main question actually), is that can Password Manager be made available? I found it q