| How can JComboBox listener to MouseEvent? |
|
 |
Index ‹ java-programmer
|
- Previous
- 2
- Java data objects to XMLI am trying to figure out a *smart* way of generating XML documents from
custom data objects. Of course, to be able to apply different XSLTs in the
presentation layer.
The custom data objects will be JavaBeans with attributes and/or collections
of other JavaBeans.
One way would be to create specific converter classes with hard coded XML
tags for each JavaBean that needs to be converted but that isn't very
maintainable. Changes in data objects require changes in the converter
classes.
I see two possibilities:
1. Having a more general converter that is able to convert data objects
according to some DTDs. DTDs could be used for mapping between the data
objects and wanted XML document.
2. Using some open source framework, Quick seems to be suitable.
http://qare.sourceforge.net/web/2001-12/products/quick/
Have any of you solved this problem previously?
David
- 3
- null pointer exception while using arraysNot sure why this code doesn't work, keep getting null pointer
exception problem.
Array_test is a class that has variables of type array, boolean,
String. The idea is to have an array of Array_test objects from which I
can add and delete objects but where all the objects are stored at the
very start with no ull spaces.
Am I wrong in assuming that having null spaces in an array with a class
of type that you have implemented is okay?
Anywho here's the code, and at the end are some tests and results from
the main.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
// For the app only one instance of Trackeris created, it keeps track
of all segs that are created
public class Tracker {
// Tracker has just one variable that's an array of objects
of type Array_test class which is predefined
private Array_test segholder[];
// construct.
public Tracker(int size_of_array){
segholder = new Array_test[size_of_array];
}
// retrive from array at i position
public Array_test getElementFromArray(int element_location) {
return segholder[element_location];
}
// retrive from array at i position
public String getElementFromArrayName(int element_location) {
String its_name;
its_name = segholder[element_location].getIdentifier();
return its_name;
}
// adds a object type array_test to the first null position in the
array segholder
public void addToArray(Array_test new_seg) {
int i = 0;
while ( i < (segholder.length - 1) ) {
if (segholder[i] == null){
segholder[i] = new_seg;
i = segholder.length;
}
i++;
}
}
// delete from an array
public void deleteFromArray(String old_seg) {
int i = 0;
while (i < segholder.length) {
if (segholder[i].getIdentifier() == old_seg) {
segholder[i] = null;
i = segholder.length;
}
i++;
}
// now remove the null space
String[] remove = {null};
List templist = new ArrayList(Arrays.asList(segholder));
templist.removeAll(new ArrayList(Arrays.asList(remove)));
segholder = (Array_test[]) templist.toArray(new Array_test[1000 -
templist.size()]);
}
}
**********MAIN********
Array_test o1 = new arrray_test("o1", 50);
Array_test o2 = new arrray_test("o2", 50);
Array_test o3 = new arrray_test("o3", 50);
Array_test o4 = new arrray_test("o4", 50);
Array_test o5 = new arrray_test("o5", 50);
Array_test o6 = new arrray_test("o6", 50);
track.addToArray(o1);
track.addToArray(o2);
track.addToArray(o3);
track.addToArray(o4);
track.addToArray(o5);
track.addToArray(o6);
System.out.println(track.getElementFromArrayName(0));
System.out.println(track.getElementFromArrayName(1));
System.out.println(track.getElementFromArrayName(2));
System.out.println(track.getElementFromArrayName(3));
System.out.println(track.getElementFromArrayName(4));
System.out.println(track.getElementFromArrayName(5));
Result, works as expected:
o1
o2
o3
o4
o5
o6
add this next line and get null pointer exception
System.out.println(track.getElementFromArrayName(6));
The delete function works fine... until I put it into a GUI listener,
then I get the same exception
Could SOMEONE please explain to me what is happening and why.
Cheers,
Gaff
- 6
- 8
- 9
- Java EE Developer-HOT HOT OPENINGSTitle: Java EE Developer
Trinity Consultancy Services
Skills: Java EE, EJB, Java, JSF, Spring, Hibernate, JSP
Trinity Consultancy Services is seeking applications from qualified
and experienced software engineers with above skills for various
requirements with their Clients.
Job description:
The Java EE Developer handles web application development using Java
EE and various open source frameworks and technologies.
Responsibilities include the development and implementation of large
and small-scale Java projects using agile methodologies for a variety
of Fortune 500 clients. Technologies and frameworks include: Java EE,
EJB, Java, JSF, Spring, Hibernate, JSP, Servlets, ANT, XML, JBoss,
WebLogic, WebSphere, and Oracle.
Required Experience:
* Bachelor's degree.
* Strong full life cycle software application development background
is required.
* Experience with Struts and/or JSF frameworks
* 1-3 years of solid Java EE development experience in a professional
environment
* Solid knowledge of Object Oriented Analysis and Design techniques.
* Excellent oral and written communication skills.
* Prior project leadership experience is a plus.
* Experience in Financial, Insurance, Commercial Retail or Government
industries.
Trinity Consultancy Services is a leading source of Information
Technology, Engineering and Management Experts that corporations of
all sizes turn to, from Global 2000 corporations to mid-sized and
small organizations nationwide. With the commitment to excellence, is
subtly managed to find, recruit, screen, submit and effectively
organize a technical workforce anywhere in the United States for
various Technical needs of corporation irrespective of its size.
Trinity Consultancy Services is one of its unique kind of the leading
information technology consulting services, and business process
outsourcing organizations committed for excellence.
Trinity provides business consulting, systems integration, application
development, staffing services and managed services to Global 2000
Corporations, medium-sized businesses, and government organizations
throughout the United States.
Trinity can mobilize the right resources, skills and technologies to
enable our clients to reach their dreams by enhanced performance. With
deep industry and business process expertise and broad global
resources, Trinity Consultancy Services is committed for excellence.
Please contact our Human Resource Manager Ms. Ann and send your
detailed Resume with your work authorization status, current salary
and expectations.
Mention the position you are applying in the subject line.
Email: email***@***.com
www.trinityconsultancy.com
- 10
- Making Internet DialerGreetings;
I am trying to build a windows internet dialer... I have gained
control of my modem through javax.comm API and I can dial a number
through my modem... the problem is I can not figure out how to pass
the username and password to my ISP.
I want to know what steps are involved in getting connected to my
isp... and also I want my windows O/S to know that i am connected.
Any resource given will be helpful.
I hope someone can help me in this regard.
Thanks
- 10
- XML inputstreamI have used the SAXparser to read XML into a class using
parse(java.io.File f, DefaultHandler dh)
Now I want something different, I want to pass the XML directly, without
a file. I found that I have to use parse(java.io.InputStream is,
DefaultHandler dh) instead. My problem is, how do I generate the
InputStream, since I can only read from an InputStream? How can I have
my class generating an InputStream for the parser?
--
Peter Grison
- 10
- java applet screenshotdear experts,
i am wondering if this simple screenshot.java program, developed by
Marco Schmidt could be ported as a applet?
I would like to port such a program as an applet i.e. take a
screenshot of the web user's browser's front window, get the picture
transferred and written on the server side and email the resulting
image back to the web user. My aim is also that all the whole process
remains painless for the user.
My question: do you know if such an implementation the current program
is possible? Is it possible to send the BufferedImage image =
robot.createScreenCapture() and write it on the server side? Would any
restrictions occur, or certificate need to be established?
You would save me all a lot of time if you could answer the question.
for a complete link to the following code, please take a look at:
http://www.geocities.com/marcoschmidt.geo/java-save-screenshot.html
/*
* Screenshot.java (requires Java 1.4+)
*/
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
public class Screenshot {
public static void main(String[] args) throws Exception {
// make sure we have exactly two arguments,
// a waiting period and a file name
if (args.length != 2) {
System.err.println("Usage: java Screenshot " +
"WAITSECONDS OUTFILE.png");
System.exit(1);
}
// check if file name is valid
String outFileName = args[1];
if (!outFileName.toLowerCase().endsWith(".png")) {
System.err.println("Error: output file name
must " +
"end with \".png\".");
System.exit(1);
}
// wait for a user-specified time
try {
long time = Long.parseLong(args[0]) * 1000L;
System.out.println("Waiting " + (time / 1000L)
+
" second(s)...");
Thread.sleep(time);
} catch(NumberFormatException nfe) {
System.err.println(args[0] + " does not seem
to be a " +
"valid number of seconds.");
System.exit(1);
}
// determine current screen size
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
Rectangle screenRect = new Rectangle(screenSize);
// create screen shot
Robot robot = new Robot();
BufferedImage image =
robot.createScreenCapture(screenRect);
// save captured image to PNG file
ImageIO.write(image, "png", new File(outFileName));
// give feedback
System.out.println("Saved screen shot (" +
image.getWidth() +
" x " + image.getHeight() + " pixels) to file
\"" +
outFileName + "\".");
// use System.exit if the program hangs after writing
the file;
// that's an old bug which got fixed only recently
// System.exit(0);
}
}
thank you,
antoine
- 10
- changing the classpath at runtime in codeIs it possible for a java app to change it's classpath at runtime. I
tried:
System.setProperty("java.class.path","foo")
The reason for wanting to try is URLClassLoader will not physically
reread a class file if it is in the classpath. See
http://groups.google.com/group/comp.lang.java.programmer/browse_thread/thread/793a9146df18365a/ceaa154348f6f271#ceaa154348f6f271
- 11
- enterprise beans - inter bean dependenciesHi,
I am using JBoss and an entity bean which caches data and is dependent
on another entity bean's cache.
The caches are built within the constructor.
How do I ensure one entity bean has been created - before I call it
with the other entity bean?
Or does this just happen by default with the home find method?
thanks
Tim
- 11
- How to define a default font for JLabel or whole program?I don't really like how Java2 default font is bold. I think the plain
looks much better.
How can I set the default font for a JLabel or for the whole program.
I would like to change it from BOLD to PLAIN.
About half of my JLabels in my program are anonymous. It would quite a
pain to go and define a bunch of new JLabels, then change the font to
plain.
- 11
- J2ME HTTP Post Method ProblemHello,
I built a midlet that sends an information by POST method in HTTP
connection.
in the emulators (such as Nokia 6270,6230, 6230i..) I See the "post
data" in the diagnostic, but the data doesn't arrive to the server. I
tried several servers and they didn't work. I tried to run the SDK's on
different computers and it was the same.
If I run my midlet on my Cellphone (6230) everything works fine.
Example for the post data:
action=Login&Username=tony&password=1234
is a known problem?
Any suggestions on how to solve it ?
Here is additional information:
My J2ME Code:
String params = new String("action=Login&username=&password=");
httpConn = (HttpConnection)Connector.open(url, Connector.READ_WRITE );
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Content-Type", "text/plain");
os = httpConn.openOutputStream();
byte postmsg[] = params.getBytes();
for(int i=0;i<postmsg.length;i++) {
os.write(postmsg[i]);
}
os.flush();
StringBuffer sb = new StringBuffer();
is = httpConn.openDataInputStream();
int chr;
while ((chr = is.read()) != -1) {
sb.append((char) chr);
}
response = new String(sb.toString().getBytes(),"UTF-8");
Here is Simple PHP file which is on the server:
<?php
header('Content-type: text/plain');
if ($_POST["action"]=="Login") {
if($_POST["username"]=='tony') {
echo "<?xml version=\"1.0\"?>\n";
echo "<dictionary>\n";
echo "<Status>1</Status>\n";
echo "<Reason>0</Reason>\n";
echo "<Key>JFKDL54GFDYU85T43NJKGH89N543KGFD</Key>\n";
echo "</dictionary>\n";
exit;
}
else {
echo "<?xml version=\"1.0\"?>\n";
echo "<dictionary>\n";
echo "<Status>0</Status>\n";
echo "<Reason>Wrong Username</Reason>\n";
echo "</dictionary>\n";
exit;
}
}
echo "Not Good!";
?>
When I run the midlet on my cellphone, the server recognize the value
of $_POST["action"]
but when I run the midlet on the emulators, the server doesn't
recognize the value of $_POST["action"]. in other words, the server
doesn't get the string.
But, when I look in the Diagnostic of the emulator I see that the data
were sent.
Here is the log of the Request operation:
Location = [http://10.0.0.101/dic.php]
Request Method = [POST]
Post Data = [action=Login&username=&password=]
Headers (8)
Host = [10.0.0.101]
Content-Type = [ text/plain]
User-Agent = [ Nokia6270/2.0 (p03.20) Profile/MIDP-2.0
Configuration/CLDC-1.1 Profile/MIDP-1.0 Confirguration/CLDC-1.0,
Nokia6270/2.0 (p03.20) Profile/MIDP-2.0 Configuration/CLDC-1.1
UNTRUSTED/1.0]
Content-Length = [ 32]
Connection = [ Keep-Alive]
x-wap-profile = [
"http://nds1.nds.nokia.com/uaprof/N6270r100.xml"]
Here is the log og the response:
Request Status = 200: "OK"
Location = [http://10.0.0.101/dic.php]
Headers (6)
Transfer-Encoding = [ chunked]
Date = [ Tue, 13 Jun 2006 23:30:08 GMT]
Content-Type = [ text/plain]
Server = [ Apache/1.3.33 (Unix) PHP/4.3.10]
X-Powered-By = [ PHP/4.3.10]
Via = [ 1.1 Bezeq-L2TP-MED-Stack1 (NetCache NetApp/5.6.2R1)]
Content Data: 9 bytes, text/plain; ISO-8859-1
Not Good!
(The Not good is the string that appears in the end of the php. we get
there only if the "IF" statment is false.
- 12
- Front EndWe have a large application running over a network environment using RMI
as commnuication between the front-end GUI and the backend server
(primarily database activity). All the Java code also resides on the
same machine as the "backend" server. On occassion software updates are
required on this backend to add new features.
What I want to do is : When users log on or connect to a network (lets
consider a LAN or VPN at this point instead of the internet), how can I
ensure that the user on a remote machine will always have the latest
programs without the need to upgrade their machine each time a software
update is done on the server.
I want to only install the minimal files on the client machine in order
to connect to and run the GUI front end. I don't want to install the
required JRE either, the required code should come from the server.
Now, I know browsers can do something like what I am thinking about when
an applet is embedded with the HTML code. That is, it will bring across
the required Java classes. But Java is still required on the client machine.
Any suggestions?
Terry
- 12
- Problem in running external processHello all,
I am facing problem in running external process .
Well i want to run the an external command "HMMBUILD" with two
arguments as "seq.hmm" and "seq.msf"
I have written the following code:
import java.io.*;
public class Test {
public static void main(String argv[ ]) {
try {
String[ ] cmd = {"C:/hmmer-2.3/hmmbuild","abc.hmm","abc.msf"};
String line;
Process p = Runtime.getRuntime ().exec(cmd);
BufferedReader input = new BufferedReader(new
InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close ();
}
catch (Exception err) {
err.printStackTrace();
}
}
}
But i m not getting any output.
I would of great help to me if anyone could tell me the possible error
that i m commiting.
- 16
- Online Cheap Cigarets storesBuy Cigarets online - Online Cheap Cigarets stores
This Week Top Online buy cigarets online. Ranks #1, because Now Offers
4 - 7 Day Priority Shipping of Top quality Cigarettes at European
Prices!!!
http://www.cigarettes--online.com/buy-cigarets-online.html
buy cigarets online - Online Cheap Cigarettes Discount Stores Reviews.
Buy Tax Free Marlboro $19.58, Camel $16.75, Newport Cigarettes... Buy
Cheap Cigarettes Online Guide
buy cigarets online sales
Wholesale buy cigarets online sales to retail buyers continue to
increase in the United States. Ever wonder why buy cigarets online
cost so much in the USA? buy cigarets online taxes imposed by federal,
state, and local governments, account for most of the cost of
cigarettes in the USA. New York City cigarette smokers pay some of the
highest taxes in the USA. A package of cigarettes in the City of New
York is burdened with $0.39 in federal excise tax, $1.50 in state tax,
and another $1.50 in city tax.
Online discount cigarettes has become a catchphrase amon
Next, let's examine the economic and public finance implications of
higher cigarette prices. For starters, more than half of any price
increases will be paid by smokers with annual incomes under $30,000;
only 1 percent will be paid by smokers earning more than $100,000. In
other words, cigarettes surcharges are brutally regressive; they
represent a wealth transfer from generally poor smokers to more
affluent non-smokers. If prices rise by $2.00 per pack, a two-pack-a-
day smoker will be hit with $1,460 in added expense each year. That's
an enormous burden for a low-income consumer.
g the patrons of premium brands such as Marlboro, Newport, Doral,
Parliament, Camel and Barclay. With the advent of discount cigarettes,
one can now enjoy their favorite brand at a much lower cost. Websites
displaying the "buy cigarets online" tag offer a variety of premium
and generic cigarette brands at heavily discounted prices, owing to
the tax exemption that online sales enjoy. However, "buy cigarets
online" websites desist from supplying cigarettes to some states
because of the strict laws that have been applied to online sales.
Related Keywords: cheap cigarettes, buy cigarettes, discount
cigarettes, buy cigarettes online, cheap cigarettes online, Marlboro
cigarettes, Camel cigarettes, Newport cigarettes, cigarette brands,
menthol, lights, mild, buy cheap cigarettes
http://www.cigarettes--online.com/buy-cigarets-online.html
|
| Author |
Message |
RC

|
Posted: 2007-3-20 4:30:00 |
Top |
java-programmer, How can JComboBox listener to MouseEvent?
Since JComboBox and JButton both are
extends from JComponent.
When I addMouseListener(this);
for jButton, it listens to the MouseEvent.
But jComboBox doesn't listen to the MouseEvent.
public void mouseEntered(MouseEvent me) {
System.out.println("mouse entered");
jComboBox.setToolTipText("mouse entered"); // not work
jButton.setToolTipText("mouse entered button"); // works fine
}
mouseEntered just move your mouse pointer on
the object, no need to click (pressed and released).
I just want to detect the mouse entered on JComboBox
(i.e. popup a ToolTip) before I click it for select an item.
Do I miss something? Do I need to setXXX and/or enableXXX
JComboBox before I addMouseListener?
Thank Q for your help!
|
| |
|
| |
 |
Tom Hawtin

|
Posted: 2007-3-20 4:50:00 |
Top |
java-programmer >> How can JComboBox listener to MouseEvent?
RC wrote:
>
> Since JComboBox and JButton both are
> extends from JComponent.
> When I addMouseListener(this);
> for jButton, it listens to the MouseEvent.
> But jComboBox doesn't listen to the MouseEvent.
JComboBox is implemented as a number of components (a text field, the
button and the container for them both). If you add a low level listener
to the container, it wont receive the events of its children.
Oddly, mouse events do bubble up if the child has no mouse listeners.
Unfortunately if you add mouse listeners recursively, you might end up
preventing events bubbling up that the PL&F expects.
As an alternative, you can either push an EventQueue and filter through
dispatched events, or add an AWTEventListener through Toolkit.
But probably what you want to do is reconsider what you were doing in
the first place.
Tom Hawtin
[Followup-To: comp.lang.java.gui]
|
| |
|
| |
 |
phillip.s.powell@gmail.com

|
Posted: 2007-3-22 3:16:00 |
Top |
java-programmer >> How can JComboBox listener to MouseEvent?
On Mar 19, 4:29 pm, RC <email***@***.com> wrote:
> Since JComboBox and JButton both are
> extends from JComponent.
> When I addMouseListener(this);
> for jButton, it listens to the MouseEvent.
> But jComboBox doesn't listen to the MouseEvent.
>
> public void mouseEntered(MouseEvent me) {
> System.out.println("mouse entered");
> jComboBox.setToolTipText("mouse entered"); // not work
> jButton.setToolTipText("mouse entered button"); // works fine
>
> }
>
> mouseEntered just move your mouse pointer on
> the object, no need to click (pressed and released).
>
> I just want to detect the mouse entered on JComboBox
> (i.e. popup a ToolTip) before I click it for select an item.
>
> Do I miss something? Do I need to setXXX and/or enableXXX
> JComboBox before I addMouseListener?
>
> Thank Q for your help!
I am not thinking that you'd want a MouseListener for the JComboBox,
but instead consider a PopupMenuListener instead, chances are that
will give you the results you want within the JComboBox.
Phil
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- newbie java/OOP questionPerhaps someone here can help me with this, I tried asking someone else
about this but couldn't quite describe my question.
I understand that this syntax calls a method on behalf of an object:
b1.method();
but in some java example code I see stuff like this (from a link list app) :
answer.head = IntNode.listCopy(head);
I know that "head" is an instance variable of the class, specfically an
IntNode. I also know that "answer" is a method variable of the type
IntLinkedBag.
My question is: what the heck is going on during the "answer.head"
operation? I don't understand how answer is interacting with head.
They're just two objects. What does the period do when it connects two
objects?
Any pointers or keywords to look up would be apprecited.
--
Mike
Block Banner Ads Now
http://everythingisnt.com/hosts.html
- 2
- 3
- java/81177: java patch server down
>Number: 81177
>Category: java
>Synopsis: java patch server down
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-java
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Tue May 17 20:30:07 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Ron
>Release: FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD justok.thuisnetwerk.nl 5.4-STABLE FreeBSD 5.4-STABLE #0: Sat May 14 16:24:15 CEST 2005 email***@***.com:/usr/obj/usr/src/sys/MYKERNEL i386
>Description:
jdk14 and jdk15 can not be installed, because http://www.eyesbeyond.com/freebsddom/java/jdk15.html is down.
<code/input/activities to reproduce the problem (multiple lines)>
Use any webbrowser to visit the URL, and see that it's down.
>How-To-Repeat:
>Fix:
Someone should bring up the webserver or let the URL point to a webserver that is up.
>Release-Note:
>Audit-Trail:
>Unformatted:
- 4
- JDO nad MYSQLHello.
Im looking form examples usage JDO (opensource) to MYSQL. It's possible to
it ???
Where can I find it ???
Thanks for Your help
E.N
- 5
- Welcome Back Roedy Green!Have you been back for awhile? (Maybe I'm just stupid!)
I was . . surprised to see a post from you
:)
- 6
- SET CLASSPATHhi, i'm using the abstract class definition, and when compiling the abstract
class it's ok, but the problem is when compiling the subclass: i get the
following message:
Rect.java:9: cannot resolve symbol
symbol : class GeoFigure
location: class figures.Rect
public class Rect extends GeoFigure
^
1 error
the abstract class is called: GeoFigure;
and the subclass is Rect
so how cn use the set classpath at command line, should it include the
directory where are located all the package files(the abstract class and
subclass .java files), or should it point at onel evel before the directory
that contains the package files?
thank's!
--
SAID BARA
- 7
- Download a webpage that contains javascriptI am trying to download the html page at
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1
Using the code
public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
BufferedReader webRead = new BufferedReader(new
InputStreamReader(url.openStream()));
String line;
while ((line = webRead.readLine()) != null)
{
System.out.println(line);
}
}
}
But all I am getting is
<HTML><HEAD><SCRIPT
LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replace("http://www.dreamteamfc.com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.
Any help appeciated!
pat
- 8
- Doubt regarding InterfacesThanks everyone for your replies!
I have a basic question - in the above instance Runnable is an
interface and interfaces cannot be instantiated. So something like 'new
Runnable()' seems puzzling to me. Is this syntax for instantiating an
object of the Anonymous class?
Also, is the above snippet similar to the following in the end result:
class ac implements Runnable{
public void run() {
System.out.println("Hello World on " +
Thread.currentThread());
}
};
ac doHelloWorld = new ac();
- 9
- JNI: passing Objects containing non-primitive types back and forthHi folks,
looked through a lot a threads overhere already but did not find an
answer detailed enough:
I want to map a c-structure like this created in my native code
struct mystruct {
long pid ;
long data[] ;
long meta[][] ;
} ;
to a java-object within my Java-code which would look like this IMHO:
public class ComplexData {
final int maxdata = 100 ;
final int maxmeta = 5 ;
private long pid ;
private data[] = new long[maxdata] ;
private meta[][] = new long[maxdata][maxmeta] ;
public void ComplexData() {
// Assigning values
pid = 1234 ;
data[0] = ...
}...
As far as I understood it is now possible to pass this Java-object to
the native code using the JNI-Function NewObject and read the members
and assign their values to the c-structure's members (to make them
available from within c) and the other way round, assign the values
from the c-structure to the members within the Java-object (possibly
without the initialization in the "Java-world" (I need both
directions).
My problem now is: How do I access the object's members (especially
the array types) from within c? Functions pointed to in different
threads (e.g. (Get|Set)LongArrayRegion ) need the reference to the
array, but I have only the reference to the object up to now.
Any code snippets based on the code above would be helpful.
Cheers
Bernd
- 10
- Recognize Windows ShutdownHi,
how can i recognize that Windows is shutting down (when i'm logged off)?
Sorry for stupid questions, but i didn't found the right solution!
Greets,
Nico
-> remove the underscores in the email <-
- 11
- changing code while program is runningHello,
I would like to have my class code loaded into application, which is
already running. I tried something like this:
public class Main
{
...
private void reloadClass() throws Exception
{
new Pair("","").print(); //class to be reloaded
System.in.read (); //interval - here comes manual class recompilation
ClassLoader.getSystemClassLoader ().loadClass ("Pair"); //reload class
new Pair("","").print(); //check if new version loaded
}
}
It seems that ClassLoader.loadClass checks the presence of the Pair
class in memory and doesn't relod it. How to omit it?
regards
blacky
- 12
- Implementing inheritance in JAVAHi,
I am a naive JAVA user. Can you please tell me, oh how to implement
the following scenario
A
^ ^
/ \
B C
^ ^
\ /
D
Classes B and C extends class A, but how to define class D, such that
members of both B and C are available to D.
Thanks
>> manjunath
- 13
- 14
- Removing Item From JList - getSelectedIndex problemHi all,
I am currently working on a JList that populates data into a JList
from a CSV file. I have a button that is supposed to get the Selected
index and then delete that item from the JList. Below is the code that
I am using:
int index = lstComputerExceptions.getSelectedIndex();
System.out.println("index is: " + index);
model.remove(0);
int size = model.getSize();
if (size == 0) { //Nobody's left, disable firing.
btnDelete.setEnabled(false);
} else { //Select an index.
if (index == model.getSize()) {
//removed item in last position
index--;
}
lstComputerExceptions.setSelectedIndex(index);
lstComputerExceptions.ensureIndexIsVisible(index);
}
I have printed out what index is and no matter what item I have in the
Jlist I have selected it will always print out
-1. Therefore keeps on causing my program to crash and not delete the
item out of the Jlist.
Any help in this matter would be highly appreicated.
Thank you
- 15
- emailtosmsemail***@***.com wrote:
> Anyone know how to send sms from email i [sic] mean email to sms
Set the phone number as the destination address, according to the standard
mapping of phone numbers to email addresses set by the devices service provider.
--
Lew
|
|
|