Why action not good here???
please in the toolbarPanel class why the
line button.addActionListener(new ButtonListener() );
not affect on the button .
please any one answer me .
the code here:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class Paint extends JFrame {
ToolbarPanel toolbarPanel;
private DrawingPanel DrawPanel;
private JMenuBar bar;
private JMenu fileMenu;
private JMenuItem openItem, saveItem;
private JPanel panel;
public Paint() {
DrawPanel = new DrawingPanel();
toolbarPanel = new ToolbarPanel(DrawPanel);
panel=new JPanel();
fileMenu = new JMenu("file");
fileMenu.addSeparator();
openItem = new JMenuItem("open");
fileMenu.add(openItem);
saveItem = new JMenu("save");
fileMenu.add(saveItem);
bar = new JMenuBar();
setJMenuBar(bar);
bar.add(fileMenu);
add(toolbarPanel, BorderLayout.NORTH);
DrawPanel.setBackground(Color.WHITE);
add(DrawPanel, BorderLayout.CENTER);
panel.setBackground(Color.GRAY);
panel.setPreferredSize(new Dimension(200,300));
add(panel,BorderLayout.EAST);
private static void creatAndShowGUI() {
JFrame frame = new Paint();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
creatAndShowGUI();
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.border.TitledBorder;
class ToolbarPanel extends JPanel {
private JToolBar toolbar;
private String[] labels = {"Line", "Oval", "Square", "Rectangle", "Polygan", "Triangle"};
private JButton button;
private DrawingPanel panel;
public ToolbarPanel(DrawingPanel panel) {
this.panel = panel;
toolbar = new JToolBar();
for (int i = 0; i < labels.length;++i) {
button = new JButton(labels);
toolbar.add(button);
toolbar.add(button);
button.addActionListener(new ButtonListener());
add(toolbar);
TitledBorder title;
title = new TitledBorder("Shapes");
title = BorderFactory.createTitledBorder(title);
setBorder(title);
code}
private class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == labels[0]) {
panel.draw(DrawingPanel.LINE);
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JPanel;
public class DrawingPanel extends JPanel {
private int x1, y1, x2, y2, width_I, width_F, Height_I, Height_F, Oval_w, Oval_h, Oval_x, Oval_y;
public final static int LINE = 1, OVAL = 2;
private int shape;
private Vector vLine, vOval;
public DrawingPanel() {
vLine = new Vector();
vOval = new Vector();
addMouseListener(
new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (shape == LINE) {
x1 = e.getX();
y1 = e.getY();
if (shape == OVAL) {
width_I = e.getX();
Height_I = e.getY();
Oval_x = e.getX();
Oval_y = e.getY();
@Override
public void mouseReleased(MouseEvent e) {
x2 = e.getX();
y2 = e.getY();
if (shape == LINE) {
vLine.add(new Coordinate(x1, y1, x2, y2));
repaint();
if (shape == OVAL) {
width_F = e.getX();
Height_F = e.getY();
/* if (width_F < width_I) {
Oval_x = e.getX();
if (Height_F < Height_I) {
Oval_y = e.getY();
/* vOval.add(new Coordinate(width_I,Height_I,width_F,Height_F));*/
repaint();
Dimension dimension = new Dimension(500, 300);
setMinimumSize(dimension);
setPreferredSize(dimension);
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (int i = 0; i < vLine.size(); ++i) {
Coordinate coordinate = (DrawingPanel.Coordinate) vLine.elementAt(i);
g.drawLine(coordinate.x1, coordinate.y1, coordinate.x2, coordinate.y2);
Oval_w = Math.abs(width_F - width_I);
Oval_h = Math.abs(Height_F - Height_I);
g.drawOval(Oval_x, Oval_y, Oval_w, Oval_h);
public void draw(int shapeTodraw) {
shape = shapeTodraw;
repaint();
private class Coordinate {
private int x1, y1, x2, y2;
public Coordinate(int inx1, int iny1, int inx2, int iny2) {
x1 = inx1;
y1 = iny1;
x2 = inx2;
y2 = iny2;
no my friend i don't take java in my class
i learend it wit myself.
plz answer to my question
i try to do this but filled
public void actionPerformed(ActionEvent e) {
for(int i=0;i<labels.length;++i){
if (e.getActionCommand()==labels){
panel.draw(DrawingPanel.LINE);
}i wait your answer
thanks
Similar Messages
-
Hello,i have a problem with my gift card here in switzerland,when i want to redeem the cod says that the code is not good for i tunes....and i buy the gift card from the shop...any idea? thx
I have one of these http://store.apple.com/us/personalize/itunes?product=M9949
but the credit on it is 30 chf....i try to reddem into itunes and after all the steps i recive a message that says"the serial code is not good...." i don t know why say this.... -
A very good friend of mine dropped her iphone into water and now it is not working.Her husband recently passed away and text messages from him and from well wishers after his decease are feared lost. Is there any way to retrieve them?
I suggested contacting Compub in Nassau St as the info is priceless and worth the trouble of trying to regain?
Any thoughts? The poor lady is very distressIf she has backed up her iPhone she can replace that iPhone and set up the new iPhone from her backup.
You can put the iPhone that went into water into a plastic baggie with either new silica gel packets (preferred) or raw rice and let it sit for 4 - 5 days. After that time remove the phone and connect it to power for at least a half hour. While it is still connected to power reset it by holding down the power and hold button, wait for the Apple logo then let go of the buttons. Might take several tries. If it revives immediately back it up. -
Why Action in af:inputDate is not working
I've af:inputDate in my page and I want to use action I've mapped it to a method in a bean and put System.out.println("Test");
but It didn't work
I've read in the following site :http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_inputDate.html
For this component, actionListener and returnListener attributes will only be fired on a PDA.but why action is not workingUser,
please allways tell us your jdev version as the solution might depend on it.
Can you post the code from your af:inputDate and the action?
Timo -
Question
Why cant i re-add gmail button on google toolbar? 4.01 is not good, I have never had a problem with your products..Whats going on??http://support.mozilla.com/en-US/kb/how-do-i-use-bookmarks
-
HT1338 why the map in iphone 5 its not working here United Arab Emirates
why the map in iphone 5 its not working here United Arab Emirates
Am having same problem with my iphone 5 ... i can't use facebook and weather app only ... other apps are working perfectly fine ... my phone is on fw 6.0.2 and i think its my firmware problem let me know how did u resolved your's?
-
I am trying to help my friend to enable dictation for ipad mini, when go to setting-general-keyboard-enable dictation is not in her ipad mini, why? It is on my ipad mini. The speaker is not there when she open the keyboard on her ipad mini. She wants to speak in Notes instead writing every word. Can any one help? Thanks
Try turning Siri "On".
Setting>General>Siri>On -
Why is the Good Wife latest episode still not available on Itunes Canada?
why is the Good Wife latest episode still not available on Itunes Canada?
FYI, the two episodes currently missing from iTunes Canada (Nov 17 "The Next Month" and Nov 24 "Whack-a-Mole") are available online for Global TV "subscribers":
http://www.globaltv.com/thegoodwife/
None of us are realy "Global TV subscribers", we are customers of one TV service provider or another, aka cable and satellite companies. Alas, I am in the situation where my service provider - Bell TV - has apparently not yet reached an agreement with Global, so I am hooped twice. I paid iTunes for a season pass that seems to have stopped delvering content. And I pay Bell TV for content which Global says I can only get in online form once Global and Bell reach some kind of agreement, although Shaw, Telus and Cogeco subscribers are already receiving it.
https://www.globaltv.com/signin/
Be nice if these companies could get their acts together, especially Apple iTunes.
I've paid them $49.99 for the Good Wife season pass. -
Why "full scans are not evil, indexes are not good"
in this article inside asktom page
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:9422487749968
tell about "full scans are not evil, indexes are not good"
someone tell me why for this select mentioned index are not good?...and if you read next post, nothing is black or white, it is all shades of grey .
This is not because your query will use index that it would be faster, and the example which Tom gave is really explicit :
With index usage 60127 consistent gets, and without index usage 92 consistent gets
Nicolas.
Message was edited by:
N. Gasparotto -
I have money in my acount why can not I buy here writes contact support
i have money in my acount why can not I buy here writes contact support
Click here and request assistance.
(72530) -
I have been trying to update my ipod to the 5.0.1 but after waiting for a hour for the download i get an error message that the server has timed out as my broadband speed is not good, could this be the problem and if so how can i get the update?
I have the same problem I disable msconfig mode all the programs escept windows and apple products but the same error appears at the last second of downloading the update
-
I have upgrade 2 of my Macbook air 11" models. Both have major slow functionality in allmost every programs. slow mail, safari, pages. Allmost nothing of the funksjonalitys can being uses in numbers. Slow functionality when jumping between programs. Allover i have BIG problems with mac for my first time. And why do not Apple send a fix for all fails there is after upgrading to Yosemite. When thousand of users have the same problem with major slow mac`s.
Here is a test for my mac.
EtreCheck version: 2.1 (101)
Report generated 4. desember 2014 kl. 22.48.33 CET
Hardware Information: ℹ️
MacBook Air (Verified)
MacBook Air - model: MacBookAir6,1
1 1.7 GHz Intel Core i7 CPU: 2-core
8 GB RAM Not upgradeable
BANK 0/DIMM0
4 GB DDR3 1600 MHz ok
BANK 1/DIMM0
4 GB DDR3 1600 MHz ok
Bluetooth: Good - Handoff/Airdrop2 supported
Wireless: en0: 802.11 a/b/g/n/ac
Video Information: ℹ️
Intel HD Graphics 5000 -
Color LCD 1366 x 768
System Software: ℹ️
OS X 10.10.1 (14B25) - Uptime: 0:12:8
Disk Information: ℹ️
APPLE SSD SM0512F disk0 : (500,28 GB)
S.M.A.R.T. Status: Verified
EFI (disk0s1) <not mounted> : 210 MB
Recovery HD (disk0s3) <not mounted> [Recovery]: 650 MB
Macintosh HD (disk1) / : 496.30 GB (371.41 GB free)
Core Storage: disk0s2 499.42 GB Online
USB Information: ℹ️
Apple Inc. BRCM20702 Hub
Apple Inc. Bluetooth USB Host Controller
Thunderbolt Information: ℹ️
Apple Inc. thunderbolt_bus
Gatekeeper: ℹ️
Mac App Store
Kernel Extensions: ℹ️
/Applications/Parallels Access.app
[not loaded] com.parallels.virtualsound (1.0 18 - SDK 10.6) [Support]
/Applications/Parallels Desktop.app
[not loaded] com.parallels.kext.hypervisor (10.1.1 28614 - SDK 10.7) [Support]
[not loaded] com.parallels.kext.netbridge (10.1.1 28614 - SDK 10.7) [Support]
[not loaded] com.parallels.kext.usbconnect (10.1.1 28614 - SDK 10.7) [Support]
[not loaded] com.parallels.kext.vnic (10.1.1 28614 - SDK 10.7) [Support]
/Library/Application Support/Kaspersky Lab/KAV/Bases
[not loaded] com.kaspersky.kext.kimul.38 (38) [Support]
/Library/Extensions
[loaded] com.silex.driver.sxuptp (1.10.9 - SDK 10.8) [Support]
/System/Library/Extensions
[not loaded] com.devguru.driver.SamsungComposite (1.2.61 - SDK 10.6) [Support]
[not loaded] com.freecom.driver.BoulderScsi (1.0.0d1) [Support]
[not loaded] com.kaspersky.kext.klif (2.2.1d19) [Support]
[not loaded] com.zg.driver.ZGUSBCDCACMData (1.5) [Support]
[not loaded] com.zg.driver.ZGUSBMassStorageFilter (1.5) [Support]
[not loaded] com.zg.driver.cdc_ecm_qmi (1.9) [Support]
[not loaded] com.zg.driver.cdc_usb_bus (1.9) [Support]
/System/Library/Extensions/ssuddrv.kext/Contents/PlugIns
[not loaded] com.devguru.driver.SamsungACMControl (1.2.61 - SDK 10.6) [Support]
[not loaded] com.devguru.driver.SamsungACMData (1.2.61 - SDK 10.6) [Support]
[not loaded] com.devguru.driver.SamsungMTP (1.2.61 - SDK 10.5) [Support]
[not loaded] com.devguru.driver.SamsungSerial (1.2.61 - SDK 10.6) [Support]
Launch Agents: ℹ️
[running] com.brother.LOGINserver.plist [Support]
[loaded] com.google.keystone.agent.plist [Support]
[loaded] com.oracle.java.Java-Updater.plist [Support]
[running] com.parallels.mobile.prl_deskctl_agent.launchagent.plist [Support]
Launch Daemons: ℹ️
[loaded] com.adobe.fpsaud.plist [Support]
[loaded] com.google.keystone.daemon.plist [Support]
[failed] com.kaspersky.kav.plist [Support] [Details]
[loaded] com.macpaw.CleanMyMac2.Agent.plist [Support]
[loaded] com.oracle.java.Helper-Tool.plist [Support]
[loaded] com.oracle.java.JavaUpdateHelper.plist [Support]
[running] com.parallels.mobile.dispatcher.launchdaemon.plist [Support]
[failed] com.parallels.mobile.kextloader.launchdaemon.plist [Support] [Details]
User Launch Agents: ℹ️
[running] ca.indev.MailTagsHelper.agent.plist [Support]
[loaded] com.facebook.videochat.[redacted].plist [Support]
[loaded] com.genieo.completer.download.plist Adware! [Remove]
[loaded] com.genieo.completer.ltvbit.plist [Support]
[running] com.genieo.completer.update.plist Adware! [Remove]
[not loaded] com.macpaw.CleanMyMac.helperTool.plist [Support]
[not loaded] com.macpaw.CleanMyMac.trashSizeWatcher.plist [Support]
[not loaded] com.macpaw.CleanMyMac.volumeWatcher.plist [Support]
[loaded] com.macpaw.CleanMyMac2Helper.diskSpaceWatcher.plist [Support]
[loaded] com.macpaw.CleanMyMac2Helper.scheduledScan.plist [Support]
[loaded] com.macpaw.CleanMyMac2Helper.trashWatcher.plist [Support]
[loaded] com.parallels.mobile.startgui.launchagent.plist [Support]
User Login Items: ℹ️
iTunesHelper ProgramHidden (/Applications/iTunes.app/Contents/MacOS/iTunesHelper.app)
fuspredownloader ProgramHidden (/Users/[redacted]/Library/Application Support/.FUS/fuspredownloader.app)
Internet Plug-ins: ℹ️
JavaAppletPlugin: Version: Java 7 Update 71 Check version
FlashPlayer-10.6: Version: 15.0.0.239 - SDK 10.6 [Support]
Default Browser: Version: 600 - SDK 10.10
NP_2020Player_IKEA: Version: 5.0.94.1 - SDK 10.6 [Support]
Flash Player: Version: 15.0.0.239 - SDK 10.6 [Support]
QuickTime Plugin: Version: 7.7.3
nplastpass: Version: 3.1.61 [Support]
JavaPlugin2_NPAPI: Version: Unknown
Silverlight: Version: 5.1.30514.0 - SDK 10.6 [Support]
iPhotoPhotocast: Version: 7.0
userinternetplugins ℹ️
Google Earth Web Plug-in: Version: 7.1 [Support]
Safari Extensions: ℹ️
Facebook Cleaner
Pin It Button
LastPass
ResizeMe
OpenIE
3rd Party Preference Panes: ℹ️
Cineform [Support]
Flash Player [Support]
Java [Support]
Time Machine: ℹ️
Mobile backups: ON
Auto backup: YES
Volumes being backed up:
Macintosh HD: Disk size: 496.30 GB Disk used: 124.90 GB
Destinations:
Data [Network]
Total size: 3.00 TB
Total number of backups: 65
Oldest backup: 2013-08-15 20:20:51 +0000
Last backup: 2014-12-04 17:20:31 +0000
Size of backup disk: Excellent
Backup size 3.00 TB > (Disk size 496.30 GB X 3)
Top Processes by CPU: ℹ️
4% WindowServer
1% fontd
1% cloudd
0% Safari
0% launchd
Top Processes by Memory: ℹ️
369 MB com.apple.WebKit.WebContent
155 MB Safari
103 MB Feedback Assistant
86 MB Finder
69 MB mds_stores
Virtual Memory Information: ℹ️
4.52 GB Free RAM
2.60 GB Active RAM
652 MB Inactive RAM
820 MB Wired RAM
1.04 GB Page-ins
0 B Page-outs
Diagnostics Information: ℹ️
Dec 4, 2014, 10:37:00 PM Self test - passed[loaded] com.genieo.completer.download.plist Adware! [Remove]
[loaded] com.genieo.completer.ltvbit.plist [Support]
[running] com.genieo.completer.update.plist Adware! [Remove]
[not loaded] com.macpaw.CleanMyMac.helperTool.plist [Support]
[not loaded] com.macpaw.CleanMyMac.trashSizeWatcher.plist [Support]
[not loaded] com.macpaw.CleanMyMac.volumeWatcher.plist [Support]
[loaded] com.macpaw.CleanMyMac2Helper.diskSpaceWatcher.plist [Support]
[loaded] com.macpaw.CleanMyMac2Helper.scheduledScan.plist [Support]
[loaded] com.macpaw.CleanMyMac2Helper.trashWatcher.plist [Support]
Your machine is slow because you loaded a bunch of third party junk on it. -
The other day my friend and I were trying to chat using FaceTime. She keep getting connection error. We were both on WiFi network. Both of us have our Apple IDs set up on the phone. In the past I successfully used FaceTime to chat with other friends, so the problem is likely at her side. She called Apple's customer service number in her area (China), described the problem. To her surprise, instead of being asked about the details, she was told "FaceTime is not good, don't try to use it." If this is really Apple's official attitude towards FaceTIme, why would it release this product? Or, is FaceTime suppose to be only among US users?
I doubt if that is Apples official position, and it is a shame it was said to your friend.
Your friend is in China, where are you? I ask because the longer the distance between network connections the more likely connection errors can occur. -
SwingWorker and Action - not playing well together
I have a long running task. I also like using AbstractAction. But since these are both classes, and Java won't let you extend more than a single class, I figured I'd build a new abstract "SwingAction" class. This extends SwingWorker and implements Action. I leave the SwingWorker classes out and leave the actionPerformed method from Action out. Here's what I'm left with:
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import javax.swing.Action;
import javax.swing.event.SwingPropertyChangeSupport;
import org.geotools.gui.swing.worker.SwingWorker;
public abstract class SwingAction extends SwingWorker implements Action {
private HashMap map = new HashMap();
private boolean enabled = true;
private SwingPropertyChangeSupport changer = new SwingPropertyChangeSupport(this);
public Object getValue(String key) {
return map.get(key);
public void putValue(String key, Object value) {
if (value!=null){
Object o = map.get(key);
if (o==null || !o.equals(value)){
map.put(key, value);
changer.firePropertyChange(key, o, value);
public void setEnabled(boolean enabled) {
if (enabled!=this.enabled){
this.enabled=enabled;
changer.firePropertyChange("enabled", new Boolean(!enabled), new Boolean(enabled));
public boolean isEnabled() {
return enabled;
public void addPropertyChangeListener(PropertyChangeListener listener) {
changer.addPropertyChangeListener(listener);
public void removePropertyChangeListener(PropertyChangeListener listener) {
changer.removePropertyChangeListener(listener);
}I've implemented this in a class and it works great - the first time! It seems like once I hit "start", I'm not able to call it again. I've tried calling interrupt in the finished method, but that has no affect.
I'm including the class that implements SwingAction - you'll need to change it to do something else and hook it up to a button to try it out, but if you have any idea why it's failing to run a second time, I'd love to hear it.
Thanks!
P.S. Here's the class that implements SwingAction:
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class EnlargeImageAction extends SwingAction {
private WMSViewer wmsViewer;
private JLabel mapImage;
private Cursor cursor;
public EnlargeImageAction(WMSViewer wmsViewer, JLabel mapImage){
this.wmsViewer=wmsViewer;
this.mapImage = mapImage;
public Object construct() {
System.out.println("Calling action");
return wmsViewer.getEnlargedImage();
public void finished() {
mapImage.setIcon((ImageIcon)get());
mapImage.setEnabled(true);
wmsViewer.setCursor(cursor);
this.setEnabled(true);
public void actionPerformed(ActionEvent e) {
mapImage.setEnabled(false);
cursor = wmsViewer.getCursor();
wmsViewer.setCursor(new Cursor(Cursor.WAIT_CURSOR));
this.setEnabled(false);
start();
}Thread can't be reused.
If you want to reuse it after its run() method returned, you should re-instantiate it. -
Requested action not taken: message refused (in reply to end of DATA comman
Hello!
When trying to send an email to one particular domain (that I know of) the email is being rejected from the recipient mail server and my mail logs are showing this error:
said: 550 5.7.1 Requested action not taken: message refused (in reply to end of DATA command))
Can anyone tell me where to start looking?
(I have full logs of the postifx transaction within my mail server).
regan.There's a myriad of reasons why the remote mail server may refuse your message. Since it's happening so quickly I'd bet on incorrect reverse DNS for your server, but it could also be an number of anti-spam filters that are running.
Do you have valid, working DNS for your server? in other words if you lookup your server's public IP address do you get the same hostname that the server thinks it is?
For example:
Good: nslookup mail.domain.com -> 12.34.56.78; nslookup 12.34.56.78 -> mail.domain.com
Bad: nslookup mail.domain.com -> 12.34.56.78; nslookup 12.34.56.78 -> some.hostname.your.isp.net
The latter is almost guaranteed to get your mail blocked at most of the big ISPs.
Maybe you are looking for
-
How to activate JMenu from other frame using accelerator key
Hi. I'm developing an application for my final year project. i set up my application to have multiple frame open at the same time (like sunone studio in SDI mode). only one JFrame contains the JMenuBar. i can activate this menu bar using the accelera
-
My monitor has suddenly started waking up on its own when the computer isn't on. it keeps having "OSD lockout" message constantly going off and on. The tab for adjusting things such as brightness and all other settings keeps flashing on and off. I do
-
hi, Can anybody give me the complete details about cell definition, where, why and how we are going to use. Regards
-
Limewire shared account in my iTunes?
I just downloaded a song from iTunes store and after download a shared limewire account appeared in my iTunes menu. I right click and it has a sub menu to disconnect. I do this but the account still remains in my iTunes menu. What is this? Or better,
-
How the ASR memory options shipped when bought as spares?
Does anyone knows how the ASR memory options shipped when bought as spares? Can i insert a 2GB memory on the ASR 1002-X as stated in the memory options in this link, http://www.cisco.com/c/en/us/products/collateral/routers/asr-1000-series-aggregation