Strange problem with Java KeyListener
Hi everyone,
I basically have a JFrame which implements KeyListener .
Initially it recognizes when a key is pressed and typed, etc. But after I click a button on the frame, it stops recognizing any further keyEvents.
Any thoughts?
Thanks!
Taking your advice, I used key bindings with the following code:
InputMap im = new InputMap();
im.put(KeyStroke.getKeyStroke("control F"), "pressed");
im.setParent(this.getInputMap(JComponent.WHEN_FOCUSED));
this.setInputMap(JComponent.WHEN_FOCUSED, im);
this.getActionMap().put("pressed",
new AbstractAction("pressed") {
public void actionPerformed(ActionEvent evt) {
System.out.println("pressed");
);For now, it still only triggers when the JPanel is in focus. I'm not sure how to go about implementing it so that the keys trigger regardless of whether the JPanel is focused.
Similar Messages
-
Strange problem with WD component build
Hi all,
I have strange problem with building one wd component, which is part of SC. I'm getting few errors which stops me from building component (and transporting to other systems via CMS of course). I'm providing sample of the errors (3 types) and ant error:
[code] [wdgen] [Error] com.gbs.gmob.RequisitionFoCust --> ContextValueAttribute startDate [type]: Type missing (Hint: The type property must be set to a simple type, a built in type or any java native type)
[wdgen] [Error] com.gbs.gmob.RequisitionFoCust --> ContextValueAttribute stopDate [type]: Type missing (Hint: The type property must be set to a simple type, a built in type or any java native type)
[wdgen] [Error] com.gbs.gmob.SuppMatGroupView --> TextView MATERIAL_GROUP_NAME_editor [text]: Context element and property are not compatible
[wdgen] [Error] com.gbs.gmob.SuppMatGroupView --> TextView MATERIAL_GROUP_ID_editor [text]: Context element and property are not compatible
[wdgen] [Error] com.gbs.gmob.SupplierCust --> ContextModelNode SuppMatGroup [modelClass]: The context model node has not been bound to a model class (Hint: A Context model node has to be bound to a model class or mapped to a model node of another controller.)
[wdgen] [Error] com.gbs.gmob.SupplierCust --> ContextValueAttribute material_group_list [type]: Type missing (Hint: The type property must be set to a simple type, a built in type or any java native type)
[wdgen] [Warning] com.gbs.gmob.ApprovalRejectView --> TextEdit TextEdit: UIElement does not have a label
[wdgen] [Info] Catching throwable null
[wdgen] [Info] com.sap.webdynpro.generation.ant.GenerationAntTaskError
[wdgen] at com.sap.webdynpro.generation.ant.GenerationAnt.showCheckResult(GenerationAnt.java:153)
[wdgen] at com.sap.ide.webdynpro.generation.Generation.check(Generation.java:2050)
[wdgen] at com.sap.ide.webdynpro.generation.Generation.generatePersistentComponent(Generation.java:1299)
[wdgen] at com.sap.ide.webdynpro.generation.console.GenerationConsole.generate(GenerationConsole.java:175)
[wdgen] at com.sap.webdynpro.generation.ant.GenerationAnt.main(GenerationAnt.java:50)
[wdgen] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[wdgen] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[wdgen] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[wdgen] at java.lang.reflect.Method.invoke(Method.java:324)
[wdgen] at com.sap.webdynpro.generation.ant.WDGenAntTask.execute(WDGenAntTask.java:219)
[wdgen] at org.apache.tools.ant.Task.perform(Task.java:341)
[wdgen] at org.apache.tools.ant.Target.execute(Target.java:309)
[wdgen] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[wdgen] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[wdgen] at com.sap.tc.buildplugin.techdev.ant.util.AntRunner.run(AntRunner.java:115)
[wdgen] at com.sap.tc.buildplugin.AbstractAntBuildAction.execute(AbstractAntBuildAction.java:65)
[wdgen] at com.sap.tc.buildplugin.AbstractPlugin.handleBuildStepSequence(AbstractPlugin.java:225)
[wdgen] at com.sap.tc.buildplugin.AbstractPlugin.performBuild(AbstractPlugin.java:201)
[wdgen] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[wdgen] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[wdgen] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[wdgen] at java.lang.reflect.Method.invoke(Method.java:324)
[wdgen] at com.sap.tc.buildtool.PluginCommunicator.maybeInvoke(PluginCommunicator.java:114)
[wdgen] at com.sap.tc.buildtool.PluginCommunicatorV2.communicate(PluginCommunicatorV2.java:42)
[wdgen] at com.sap.tc.buildtool.PluginHandlerImpl.handlePluginCommunication(PluginHandlerImpl.java:354)
[wdgen] at com.sap.tc.buildtool.PluginHandlerImpl.execute(PluginHandlerImpl.java:176)
[wdgen] at com.sap.tc.devconf.impl.DCProxy.make(DCProxy.java:1726)
[wdgen] at com.sap.tc.devconf.impl.DCProxy.make(DCProxy.java:5559)
[wdgen] at com.sap.ide.eclipse.component.provider.actions.dcproject.BuildAction.buildDCsForDevConfig(BuildAction.java:307)
[wdgen] at com.sap.ide.eclipse.component.provider.actions.dcproject.BuildAction.access$200(BuildAction.java:58)
[wdgen] at com.sap.ide.eclipse.component.provider.actions.dcproject.BuildAction$1.run(BuildAction.java:212)
[wdgen] at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
[wdgen] ERROR: Unknown exception during generation null (com.sap.webdynpro.generation.ant.GenerationAntTaskError)
[wdgen] ERROR: Generation failed due to errors (6 seconds)
Ant runtime 9.234 seconds
Ant build finished with ERRORS
[Error] Generation failed!
Error: Build stopped due to an error: [Error] Generation failed!
[/code]
Strange is that if I try to rebuild and deploy locally, no errors occurs and I can normally deploy and run application manually!
Does anyone have experience with this problem?
Thanks in advance!
Regards,
IvanHi Ivan
I have faced this problem earlier BUT ultimately I have to create the DC from scratch.
But you can check these things:
1.Have you copy/pasted Dictionary type from other location (check the path of the dictionary types ) --> If yes then deleted that and create again(do not use copy/paste)
2.This also happens if your "Used DC" has some problems in the JDI --> Remove the used DC and add it again.
3.Make sure the NWDI infastructure is perfect- this may be a cause.
4. Check Context mappings --> delete all mappings > save metadata > Create again.
5. Delete the model and recreate it again.
6.If you have done reimporting model make sure to restart J2EE instance.
Hope this solves the problem - if not please post
Regards
Ananda -
Strange Problem with a Vector wraped inside a Hashtable
Hi all ,
I'm having a strange problem with a Vector wraped within a Hashtable inherited Class.
My goal is to keep the order of the elements of the Hashtable so what I did was to extend Hashtable and wrap a Vector Inside of it.
Here is what it looks like :
package somepackage.util;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class OrderedHashTable extends Hashtable {
private Vector index;
/** Creates a new instance of OrderedHashTable */
public OrderedHashTable() {
this.index = new Vector();
//adds a key pair value to the HashTable and adds the key at the end of the index Vector
public synchronized Object put(Object key,Object value){
index.addElement(key);
Object obj = super.put(key,value);
System.out.println("inside OrderedHashTable Put method index size = " + index.size());
return obj;
public synchronized Object remove(Object key){
int indx = index.indexOf(key);
index.removeElementAt(indx);
Object obj = super.remove(key);
return obj;
public synchronized Enumeration getOrderedEnumeration(){
return index.elements();
public synchronized Object getByIndex(int indexValue){
Object obj1 = index.elementAt(indexValue);
Object obj2 = super.get(obj1);
return obj2;
public synchronized int indexOf(Object key){
return index.indexOf(key);
public synchronized int getIndexSize() {
return index.size();
}Everything seemed to work fine util I tried to add objects using a "for" loop such as this one :
private synchronized void testOrderedHashTable(){
OrderedHashTable test = new OrderedHashTable();
for (int i = 1 ; i<15; i++){
System.out.println("adding Object No " + i);
String s = new String("string number = "+i);
test.put(new Integer(i),s);
System.out.println("-----------------------------------");
//try to list the objects
Enumeration e = test.getOrderedEnumeration();
while (e.hasMoreElements()){
Integer intObj = (Integer) e.nextElement();
System.out.println("nextObject Number = "+ intObj);
}Here is the console output :
Generic/JSR179: adding Object No 1
Generic/JSR179: inside OrderedHashTable Put method index size = 1
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 2
Generic/JSR179: inside OrderedHashTable Put method index size = 2
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 3
Generic/JSR179: inside OrderedHashTable Put method index size = 3
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 4
Generic/JSR179: inside OrderedHashTable Put method index size = 4
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 5
Generic/JSR179: inside OrderedHashTable Put method index size = 5
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 6
Generic/JSR179: inside OrderedHashTable Put method index size = 6
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 7
Generic/JSR179: inside OrderedHashTable Put method index size = 7
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 8
Generic/JSR179: inside OrderedHashTable Put method index size = 8
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 9
Generic/JSR179: inside OrderedHashTable Put method index size = 10
Generic/JSR179: inside OrderedHashTable Put method index size = 10
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 10
Generic/JSR179: inside OrderedHashTable Put method index size = 11
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 11
Generic/JSR179: inside OrderedHashTable Put method index size = 12
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 12
Generic/JSR179: inside OrderedHashTable Put method index size = 13
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 13
Generic/JSR179: inside OrderedHashTable Put method index size = 14
Generic/JSR179: -----------------------------------
Generic/JSR179: adding Object No 14
Generic/JSR179: inside OrderedHashTable Put method index size = 15
Generic/JSR179: -----------------------------------
Generic/JSR179: nextObject Number = 1
Generic/JSR179: nextObject Number = 2
Generic/JSR179: nextObject Number = 3
Generic/JSR179: nextObject Number = 4
Generic/JSR179: nextObject Number = 5
Generic/JSR179: nextObject Number = 6
Generic/JSR179: nextObject Number = 7
Generic/JSR179: nextObject Number = 8
Generic/JSR179: nextObject Number = 9
Generic/JSR179: nextObject Number = 9
Generic/JSR179: nextObject Number = 10
Generic/JSR179: nextObject Number = 11
Generic/JSR179: nextObject Number = 12
Generic/JSR179: nextObject Number = 13
Generic/JSR179: nextObject Number = 14
You can notice that the output seems correct until the insertion of object 9.
At this point the vector size should be 9 and the output says it is 10 elements long ...
In the final check you can notice the 9 was inserted twice ...
I think the problem has something to do with the automatic resizing of the vector but I'm not really sure. Mybe the resizing is done in a separate thread and the new insertion occurs before the vector is resized ... this is my best guess ...
I also tested this in a pure J2SE evironment and I don't have the same strange behavior
Can anybody tell me what I am doing wrong or how I could avoid this problem ?
Thanks a lot !
Cheers AlexAm i doing anything wrong?Uhm, yes. Read the API doc for addElement() and for addAll()
-
Strange problem with JOptionPane.showInputDialog
I have a strange problem with JOptionPane.showInputDialog in that when I run a program anything that is typed in is displayed backwards, for example: I type this character > and this < is what is displayed.
I've uninstalled the sdk and reinstalled it twice but that hasn't solved my problem and the java plug-in in the control panel is displaying the same symptoms.
I did a search before posting this but all I got really was posts from people who wanted to reverse their text.
Thanks for your help on this.Is it just the < and > characters?
-
Strange problem with SSL Sockets using more than 10 Clients
Hi
I�m using Jsse ( JDK 1.4.2_06 ). I have coded a Client/Server Applikation acting over SSLSockets or over unsecured Sockets. If I use unsecured Sockets everthing works fine, but if I use SSLSockets for the Connection and about 20 Clients, the Clients often can�t connect to the Server and the following Exception was thrown:
java.net.ConnectException: Connection refused: connect
Could it be that there is some strange problem with SSLServerSockets relating to this phenomenon?
If I use only a few Clients the Exception occurs never or only sometimes.
Has anyboby an idea what is happaning there?
Regards ChrisliHi
From the description of your scenario, you have coded your own server side of the application. I would advise that you consider moving your application to run under Tomcat framework and test if you still get the same exception. -
Strange problem with jpcap library.
Hello everone;)
I have a very strange problem with jpcap. I have ubuntu 8.10, libpcap installed by apt (manually upgraded to 0,9,8) and jpcap 0.7 (installed from deb package).
My code is:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package agh;
import java.util.logging.Level;
import java.util.logging.Logger;
import jpcap.*;
import jpcap.packet.Packet;
* @author iceman
public class Main
* @param args the command line arguments
public static void main(String[] args)
try
Tcpdump interfejsy = new Tcpdump();
catch (Exception ex)
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
// agh_MainFrame ramka = new agh_MainFrame();
// ramka.setVisible(true);
// TODO code application logic here
class Tcpdump implements PacketReceiver
public void receivePacket(Packet packet)
System.out.println(packet);
public Tcpdump() throws Exception
System.out.println("wszedlem do wykazu interfejsow");
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
if (devices.length ==0)
System.out.println("no devices");
for (int i = 0; i < devices.length; i++)
System.out.println(i + " :" + devices.name + "(" + devices[i].description + ")");
System.out.println(" data link:" + devices[i].datalink_name + "(" + devices[i].datalink_description + ")");
System.out.print(" MAC address:");
for (byte b : devices[i].mac_address)
System.out.print(Integer.toHexString(b & 0xff) + ":");
System.out.println();
for (NetworkInterfaceAddress a : devices[i].addresses)
System.out.println(" address:" + a.address + " " + a.subnet + " " + a.broadcast);
When i start this simple code it isn't working correctly. On the output i have only "no devices". JpcapCaptor doesn't see any mine network interfaces. On windows this code works correctly.
Anyone has any idea what is wrong?
Thanks,
iicebergHi, guys,
I also have a similar problem but in Windows. I've been using a W2008 Server for a short time. For what I've seen and have been told, it works like a Vista. I've wrote a program which uses jpcap and winpcap and, first of all, gets the device list.
Well, if I boot my computer and log on with my usual account, which in theory is an administrator, gets 0 devices when I run the program.
Then, if I log on with the actual Administrator account i works perfectly.
And, if after logging and running the program with the Administrator account (NOT just logging on) I log on with my usual account, it works too.
It's like the Adm account has some kind of "top" permission that doesn't go away at logoff. I tried that because I had some other problems accessing the DVD-ROM for writing from my usual account.
I think that I doesn't happen in WXP, but I haven't tested that last problem, yet.
Any ideas??
Thank you. -
Strange problem with Istant DB
Hello,
i have a strange problem with idb and classloader... if i try to connect to my db using a servlet, i get a ClassNotFoundException, but if i try to connect to it normally, it's all ok...
C:\jwsdp\webapps\ROOT\prova\DB>java DataBase
Enhydra InstantDB - Version 3.26
The Initial Developer of the Original Code is Lutris Technologies Inc.
Portions created by Lutris are Copyright (C) 1997-2001 Lutris Technologies, Inc.
All Rights Reserved.
Database movies is shutting down...
Database movies shutdown complete.
What's the problem??? why
Class.forName("org.enhydra.instantdb.jdbc.idbDriver");
in a servlet application catch a ClassNotFoundException???
this is my classpath:
%JAXP_HOME%\lib\jaxp-api.jar;
%JAXB_LIBS%\jaxb-api.jar;
%JAXB_LIBS%\jaxb-ri.jar;
%JAXB_LIBS%\jaxb-xjc.jar;
%JAXB_LIBS%\jaxb-libs.jar;
%JWSDP_HOME%\common\lib\catalina-ant.jar;
%JWSDP_HOME\common\lib\servlet.jar;
C:\idb\Classes;
C:\idb\Classes\idb.jar;
C:\idb\Classes\idbexmpl.jar;
C:\idb\Classes\jta-spec1_0_1.jar;
C:\j2sdk\lib;
C:\jwsdp\jaxb-1.0\lib;
C:\jwsdp\jaxb-1.0;
C:\jwsdp\jaxb-1.0\lib\jaxb-api.jar;
C:\jwsdp\jaxb-1.0\lib\jaxb-libs.jar;
C:\jwsdp\jaxb-1.0\lib\jaxb-ri.jar;
C:\jwsdp\jaxb-1.0\lib\jaxb-xjc.jar;
Thanks, MarcoThere should be a xml configuration file for tomcat, and it should be possible to state additional classpaths there. But I'd suggest to use the pre-configured classpaths. In which directory does your servlet class reside, or where is your document root for the web application of this servlet?
Regards -
Strange Problem with InKeyset filter
I encountered a strange problem with inkeyset filter.I am trying to do some operations on the the selected set of keys within a cache. I have posted the psuedo code below
InKeySetFilter inKeySet=new InKeySetFilter(AlwaysFilter.INSTANCE,orgDestFlightSubset);
// Set of Keys for NamedCacheInstance
inKeySet.ensureConverted
(NamedCacheInstance.getCacheService().getBackingMapManager().getContext().getKeyToInternalConverter());
Extra code to be Added
System.out.println(NamedCacheInstance.entrySet(inKeySet).size());
Always prints 0 eventhoug the keys are present in cache. If i add the following code
NamedCacheInstance.get(orgDestFlightSubset.toArray()[0]) above printing it gives 1 as a result.
I am sure that object is in cache becoz cache.get() does not call the DB again
Can anyone tell me what could be the possible problem?Hi,
user10866091 wrote:
I encountered a strange problem with inkeyset filter.I am trying to do some operations on the the selected set of keys within a cache. I have posted the psuedo code below
InKeySetFilter inKeySet=new InKeySetFilter(AlwaysFilter.INSTANCE,orgDestFlightSubset);The orgDestFlightSubset must contain keys in Java format which are existing cache keys.
user10866091 wrote:
// Set of Keys for NamedCacheInstance
inKeySet.ensureConverted
(NamedCacheInstance.getCacheService().getBackingMapManager().getContext().getKeyToInternalConverter());I assume NamedCacheInstance is a NamedCache instance obtained from CacheFactory.
In this case you should not call the ensureConverted method. This is called by Coherence on the storage nodes upon deserializing of the filter.
Try these changes.
Best regards,
Robert -
Strange Problems with XDK v10 Beta Version
Hello together,
I encounter two strange problems with the new 10.1.0.0.0 Beta release of XDK. I already posted them in the Beta Release Testing Forum, but got no replies, so I decided to start another try here. Maybe anyone can help me...
I upgraded a fine-working XSQL web application from XDK 9.2.0.4 to the new 10.1.0.0.0 Beta release of XDK. Since then, two bugs came up, which are reproducible by will:
1.)
When processing XSQL insert-requests, the error given below is thrown. I already found an entry in the bug database that says that exactly this error should have been fixed since 9.2.0.3 (see http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=230695.1), but no it seems to be there again.
This is the stack trace:
XSQL-017: Unexpected Error Occurred
java.lang.NoClassDefFoundError: oracle/sql/OPAQUE
at oracle.xml.xsql.actions.XSQLInsertRequestHandler.handleAction(XSQLInsertRequestHandler.java:118)
at oracle.xml.xsql.XSQLDocHandler.getDocument(XSQLDocHandler.java:158)
at oracle.xml.xsql.XSQLPageProcessor.process(XSQLPageProcessor.java:171)
at oracle.xml.xsql.XSQLServlet.doGet(XSQLServlet.java:61)
at oracle.xml.xsql.XSQLServlet.doPost(XSQLServlet.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
2.)
When I deploy and start the application now, I always get the following error only once(!) after deployment when I call the application for the first time:
XSQL-017: Unexpected Error Occurred
java.lang.NullPointerException
at weblogic.jdbc.oci.Statement.executeQuery(Statement.java:865)
at oracle.xml.xsql.actions.XSQLQueryHandler.handleAction(XSQLQueryHandler.java:161)
at oracle.xml.xsql.XSQLDocHandler.getDocument(XSQLDocHandler.java:158)
at oracle.xml.xsql.XSQLPageProcessor.process(XSQLPageProcessor.java:171)
at oracle.xml.xsql.XSQLServlet.doGet(XSQLServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
When I reload the same page, it works. However, this is not really a good state for productive use.
Any ideas? After days of research, I'd be very glad for any help.
Thanks alot,
EckhardOnce again me:
I guess I should partially revoke for the second topic: The error described above under 2.) seems to be rather a Weblogic versioning problem than a XDK bug, as it only occurs when deploying the application to WebLogic 7.0 (instead of 6.1, which was used before). Maybe I should search the BEA docs for an answer.
However, the first bug is still a problem to me... -
Hello,
I'm having a weird problem with some java apps that I'm trying to use (netbeans and frostwire). Looks like they aren't recognizing where the mouse pointer is. If I click Frostwire's window close button, it minimizes instead. The same thing is happening with netbeans, where I can't even access the menus with my mouse. I have the latest jdk and xfce4 packages installed.
Any hints on how I can fix this?
Thanks,
GustavoDo you use beryl ? it causes (or atleast used to cause) some strange behaviour with Java applications
-
Strange problem with In-line If-Else block
Hi!
I've discovered a very strange problem with the following code:
enum Enum {
A, B, C
public static void main(String[] args) {
Enum e = Enum.C;
Object o = e == Enum.A ? 1 : e == Enum.B ? 2 : null; // Throws NullPointerException because of the null. Why???
}I'm using Java 6
Thanks in advance!Instead of guessing what the problem is, how about we go to [the source|http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25] and see what's actually happening.
Our line is
expr ? <int> : (expr ? <int> : <null>)Let's look at the inner conditional first. By JLS 5.1.8, we have two different types, neither of which is a reference type. The null is convertible to int, so we have two types convertible to numerics and we apply unboxing to the null, which is where your error is coming from.
Your fix works because Object is not convertible to int, so we fall through to the last case and use boxing on the ints instead of unboxing on the null.
Another way to fix this is to use Integers instead of ints. Since Integer is a reference type, we hit the third case and never try to unbox.
Object o = (e == A ? Integer.valueOf(1) : (e == B ? Integer.valueOf(2) : null)) -
Problem with Java and Windows (Mainly Vista and UAC)
Hi all,
I am having a problem with a program that I've devoloped. The program itself is packaged as a jar and I plan to deploy it across multiple platforms eventually however right now i am only concerned about windows based systems. I have made an installer for a windows baised systems using NSIS to install the software files. I made the installer as I need several java packages to be installed so the program would work (JAI, J3D, JAI ImageIO) and I also require the program to have fileassociations on windows.
I know that this is not what java is about, however the majority of the users will be on windows baised systems so I've decided that OS specific installers is the best option.
During the process I have noticed that there are several key problem with java for this type of application!
The first issue that I have come across is getting file associations to work on java. As a .jar is not an excutable it is not possible to directly associate a filetype with it in java so to overcome this I currently run the program from a .bat files and also the program requires large memory so this also allows me to run the program with -xmx. The batch file that I use is :
<code>
cd PATH TO PROGRAM
start javaw -Dsun.java2d.noddraw=true -Xmn100M -Xms500M -Xmx1000M -jar "PATH TO PROGRAM\program.jar" %1 -vram 134217728
pause;
</code>
Ok so all this appears to work fine and allows windows to have file associations and start the program and thats all works perfectly but this is a non-ideal solution. Has anyone got any advice on improving this?
The next problem that I have appears to be a problem with Vista and UAC (user access control). When a user installs the program and installs the program into the program files directory I found that the program did not work and kept saying that I did not have access to the files in the current directory. This is a problem as I read and write settings files during program execution.
On a Vista system UAC prevents file write operations into the Program Files directory unless the program has requested elevated status even if the user is a full administrator. The probem is that there appears to be no real way to achieve this under java that I'm aware of...
Has anyone else had this probem and has a suitable solution?
Any advice on these issues would realy be appricated.
Regards
JoeyOk so i've kinda found a solution, its not ideal but its very good. I found this program called Elevate
A link to the site I got it was
http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx
This program allows you start java with a UAC dialog for high access using
Elevate java -jar myjar.jar
This then allows you to have full access using java... I guess it could be dangerous but it does the job. -
Problem with java and pogo games
i use mozilla and now with the problems with java and hackers cannot play my pogo games,what can i do? i disabled my java i tried java 6 doesnt work or is not safe,what is a safe way to play games on pogo that use java?
Oracle has released a Java 7 Update 11 to address security vulnerabilities and you should update to that version.
*https://support.mozilla.org/kb/how-to-use-java-if-its-been-blocked
See also:
*http://kb.mozillazine.org/Java#Windows_installation_issues
You can find the latest Java version on the Oracle website.
See Java Platform > Java SE 7U11 and Java 6U38 (Download JRE)
*http://www.oracle.com/technetwork/java/javase/downloads/index.html -
Problem with java swing button and loop
Problem with java swing button and loop
I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
When I click on start button it must do next:
Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
And when I click on stop button it must do next:
Start button must set enabled and selected and Stop button must set disenabled.
Field status is set to 0.
This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
There is java code, so you can get better picture:
/** start button */
public void gStart_ActionEvents() {
try {
ivjGStart.setEnabled(false);
ivjGStop.setEnabled(true);
ivjGStop.setSelected(true);
getJTextPane1().setText("Program is running ...");
Status = 1;
} catch (Exception e) {}
/** stop button */
public void gStop_ActionEvents() {
try {
ivjGStart.setEnabled(true);
ivjGStart.setSelected(true);
ivjGStop.setEnabled(false);
getJTextPane1().setText("Program is NOT running ...");
Status = 0;
} catch (Exception e) {
/** procedure IzvajajNeprekinjeno() */
public void IzvajajNeprekinjeno() { //RunLoop
try {
int zamik = 2000; //delay
do {
Thread.sleep(zamik);
PreberiDat(); //procedure
} while (Status == 1);
} catch (Exception e) {
So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
Any help will be appreciated.
Best regards,
TomiThis is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
Since java is task-based this will happen if you do like this:
1. Button "Start" is pressed. Thread running: GUI_Thread
2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
5. Call PreberiDat(). Thread running: GUI_Thread
6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
http://java.sun.com/docs/books/tutorial/uiswing/index.html
This tutorial explains how to build a multi threaded gui.
/Lime -
I have a problem with Java and an e-procurement system integrating
I use an e-procurement system at work and yesterday I could not get my parts list from the suppliers web site to display in our in-house eprocurment finance package.
There is not a problem with the finance package. There is not a problem with the suppliers web site. I have verified both of these by other colleagues being able to complete what I am trying to do.
The difference between my version of Firefox and my colleagues' is that I am on version 6.0.1 and they are on 6.0.
I have had problems with Java not displaying certain animations on the suppliers web site but, my colleague does not and I am suspicious that this is the problem. Can anyone verify this please and what can I do about it. My Java updates are up-to-date as of yesterday and are automatic.
Thanks.I was quite amazed I never got a reply to this, in the past people here have been helpful. In any case I was finally able to enter this website on the exceptions list in the Java panel, and I believe it is okay now.
Maybe you are looking for
-
Sharing my iTunes Library with other Users on my computer?
...hi guys! Nice to find this friendly commumity! I wonder if any of you have worked out how to share the library across other users on the computer yet? I share a PC with my girlfriend, and all of our downloads on iTunes are from our CD collection.
-
Access Table Space Map in Oracle 10g EM
From where can I access Access Table Space Map in Oracle 10g EM? Thanks
-
Homing switch causing motion control problems
I am controlling a dome for a telescope. I have a home position switch and motion control using one of NI's motion controllers. Everything works fine except for one bug. The dome just goes around and around. I can run a Home type reference search and
-
WorkStation 11 shared VM's suddenly get a red X and "unable to read configuration data"
This will usually follow a re-boot of the host machine, running Windows Server 2012. I can then REMOVE the machine(s) And open the .vmx file from the file manager ... After which I can again share the file. What can I do to prevent this? Has anyone
-
Using of Modulus function in Assignment Expressions
Hello! While trying to use Modulus function in Assignment Expression I found out that it gives strange results in some cases. For example, the remainder of 1037739010891 divided by 11 is 0, but Modulus function gives 4, the remainder of 1037739010892