| cannot call a paint function across classes? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- 1
- java.lang.NoClassDefFoundError when calling method from EJBI have a java app that runs on Websphere 6.0 and I needed a way to run
a scheduled task once a day that sends out emails. I used the
following link from IBM's site to develop a stateless EJB session bean
that ran the WAS task scheduler.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.zseries.doc/info/zseries/scheduler/tasks/tsch_schedulebtask.html
I placed a call in the implemented process method (just like the
example says) to a non-EJB method and I get a
java.lang.NoClassDefFoundError error on the method I am tryign to call.
I'm new to EJB so I'm not sure if you can even make a call from an EJB
to a normal (non-EJB) method. Any help would be appreciated.
- 3
- help with image display gui
hi wondered if anyone can help i want to create a dummy gui which looks
like a media player eg transition window buttons etc and have created
them as jpeg can someone help me in understanding how to inport them
into jframes etc and place there positions on the grid,
can gridbag place static images.is there any tutorials to do?
- 3
- Runtime.getRuntime().exec causing Windows 16-bit error!Hi there,
I'm trying to do something i've done many times before without problem, even
from signed applets...
trying to run a system command from Java.
I'm doing this:
import java.io.*;
public class SysCommand{
public static void main(Stirng[] args){
try{
Process proc =
Runtime.getRuntime().exec(
new String[]{"command.com",
"/C",
"echo",
"%windir%"});
BufferedReader reader =
new BufferedReader(
new InputStreamReader(
proc.getInputStream()));
System.out.println(reader.readLine());
proc.waitFor();
proc.destroy();
}
catch(Throwable th){
th.printStackTrace();
}
}
}
I'm trying to find out where the Windows directory is (i need to copy some
DLL's into there as part of an installation process).
When i run this, Windows raises a dialog box saying:
_______________________________________________________________
|16 bit MS-DOS Subsystem
|
|
|
| C:\WINNT\system32\ntvdm.exe
|
| Error while setting up environment for the application. Click 'Close'
to terminate |
---------------------------------------------------------------------------
---------
I'm running JDK 1.4.2_02 on a Win2K box.
Any ideas?
Thanks,
Paul
- 7
- javakeyHey Im in a spot of bother I have set the path in my windows xp to point to
java bin dir. and can run javac, but when ever I go to run javakey i gives
me "javakey" is not recognised as an internal or external command....
Im trying to sign some applets so they can open a network connection to
another computer. Im not 100% sure on how to do this or how difficult it
is, so any help would really be greatfully recieved.
Thanking you
niall
- 7
- Application for Nokia 3410 cell 'phone
This should be simple enough! I have a Nokia 3410. I have downloaded the
J2ME Wireless Toolkit. I would like to write some applications for the cell
'phone.
Now, I read that J2ME is a range of standards and applications, not a
platform. Fair enough.
Since this is in Java, I'd like to write my applications so that they run on
all cell 'phones - or all Nokia 'phones at least.
What I'd like to know is the following:
- What steps do I need to take to write and load a 'Hello World'application
into my 3410 and see it run?
If there is a document you can point me to, or a better newsgroup that would
be great!
Later on it would be nice to know how to advertise an cell 'phone
application so other people can download it and pay for it - but that can
wait until I have one fully written. For that I need to know the above!
--
"The pure and simple truth is rarely pure and never simple." - Oscar Wilde
- 8
- Learning ArraysHi, I am just learning arrays and I am trying to get this 2D array to print
out like this:
0 1 2 3 4 5 6
0 1 2 3 4 5 6
0 1 2 3 4 5 6
0 1 2 3 4 5 6
0 1 2 3 4 5 6
but insteads it prints out like this: 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4
5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6
I can get it to work with system.out.println but I need to use a
JOptionPane.showMessageDialog box as I have attempted to do. Any ideas?
(my code is below) Thanks!!!!!!!!!!
import javax.swing.*;
public class array5by7{
public static void main (String args[]){
String outputString = "";
int table[][] = new int [5][7];
for (int row=0; row<table.length; row++)
{
for (int col = 0; col <table[row].length; col++)
table[row][col] = 0 + col;
}
for (int row=0; row<table.length; row++)
{
for (int col = 0; col<table[row].length; col++)
outputString += (table[row][col] + " ");
}
JOptionPane.showMessageDialog (null, outputString + "\n");
}
}
- 11
- cannot start application server 8 ?installed the Sun Java System Application Server 8 recently. I run the
"asadmin start-domain --verbose domain1" command to try to start it,
however, it didn't happen. i'm using windows 2k server SP$.
thank's!
--
AbdelHalim MIMOUNI
- 11
- How to determine the PID of your Java programHi
I was unable to find a decent How-To for finding the PID of a Java
program running on Windows, that did not use JNI. Here is a solution
that uses netstat.
Hope this is useful. If you have a better strategy, let me know!
Thanks
Andrew
package pid;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.SocketTimeoutException;
/**
* Program to obtain the Process Identifier (PID) of the running Java
program
* Assumes the Windows program
* @author Andrew Ward
*/
public class GetPID {
public static void main(String[] args) {
getPid();
}
/**
* Obtain the PID, by listening on a port, then using netstat -ano
* to find the PID of the processing listening on the port
* @return the pid of this process
*/
public static int getPid() {
// Select a port between 50000 and 51000
final int port = 50000 + (int) (Math.round(Math.random() * 1000));
// Windows specific command line
// Netstat -ano will return many lines, one of which will match
// TCP 0.0.0.0:<port> 0.0.0.0:0 LISTENING
<pid>
final String cmd = "netstat -ano";
final String criteria = "0.0.0.0:" + port;
// Listen on the port for 5 seconds
new SocketListener(port, 5 * 1000).start();
int pid = -1;
try {
// Run netstat
Process process = Runtime.getRuntime().exec(cmd);
InputStream istr = process.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(istr));
String str;
while ((str = br.readLine()) != null) {
if (str.indexOf(criteria) > 0) {
String match = str.substring(1+str.lastIndexOf(" "));
pid = Integer.valueOf(match);
System.out.println("PID: " + pid + " {" + str + "}");
}
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
return pid;
}
/** listen on a socket */
public static class SocketListener extends Thread {
int port;
int wait;
public SocketListener(int port, int wait) {
this.port = port;
this.wait = wait;
}
public void run() {
try {
ServerSocket server = new ServerSocket(this.port);
server.setSoTimeout(this.wait);
server.accept();
server.close();
}
catch(SocketTimeoutException e)
{
// We are expecting the accept() call to timeout
// so ignore this exception
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
}
}
- 12
- Making Form results readableI have coded a simple form that sends the results to an email. The
form works, but when I recieve the data it is all together in one big
line. What kind of coding do I need to do to separate the data and
label it as well. Do I need to create some sort of template in
notepad??? I am a very beginner coder.
Thanks,
Lindsay
- 12
- Poserpoint slide file (PPS) open with wired characters in jspI included a PPS file as a hyperlink in the jsp file that was
developed in Weblogic 8.1.4 on Windows 2000 platform. However, when I
clicked the file, it opened it with strange characters file contents.
The same file opened correctly under ASP format as a same hyperlink
file. I have never need to specify filetype in ASP. Search couple
hours on Web, could not find any clue, not even a topic talked about
similar subject. Can anyone help? Thanks.
C Chang
- 14
- web browser plugin problem .... JRE not found?Hello,
I'm trying to load a Java 1.2 applet into IE 5 using the browser plugin.
When I do so, I get an error message telling me that the plugin cannot find
the JRE where in the path specified (ie., the path to which I just installed
the plugin).
What's going on here?
TIA,
- Boyd S.
- 14
- 15
- How Robots Will Steal Your Jobgoose wrote:
> until AI people can give us something which does not need them to
> "pull the strings to set it into motion", then i think that they
> are only merely playing games.
I think that's the point of neural nets. You just develop a general
mechanism that "learns" from input--similar to how our brains do.
We aren't anywhere near achieving the complexity of the human brain,
yet, but we will get there eventually.
And THEN we'll see if true intelligence is an emergent property of
complexity (possibly) or whether it requires something more than
mere machinary (possibly).
Until then, we're all just guessing. (-:
> no, it only gets emotional when you accuse everyone on the group
> of species vanity. thus far you have twice told an agnostic that
> their "religion" is preventing them from recognising that others
> (creatures) have intelligence. good job!!
The irony is that I believe Mr. Green experienced what most
theologians would call a "conversion experience" (with dolphins)
and now, like many, many of the converted, is something of a
fanatic on the matter. His posts have more a sense of preaching
than of discussing, and--as you note--he is intolerant of the
"non-believers".
[shrug] Which is fine. Takes all types to make a world, and it's
good to have people on the Side of the Animals. As you can see
from the volume, the thread has certainly captured people's interest.
--
|_ CJSonnack <email***@***.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|_______________________|
- 16
- Java Applet Parameter LimitHi all,
I would like to know the maximum number of parameters that can be passed
to an applet. While I think there is no theoretical maximum, I believe
there to be a practical limitation for browsers.
I am using winXP, IE6 and firefox1, and jre1.4.2.
I have a graphing applet which works very well except when there are a
large number of parameters i.e. 5000. When I load such an example with
appletviewer the applet opens fine. However when I load the same applet
in either IE6 or firefox1 then nothing happens except the page appears
to be loading but gets no where even if you leave it for hours - in
other words the browsers seem to hang. Java does not appear to load into
memory - the icon does not appear in the system tray which leads me to
believe that it is a browser limitation, rather than a java one.
Does anyone know if there is such a limitation? Do you think it could be
remedied by merging the tags - i.e. having less but longer params? Or is
there another way of passing data to the applet?
Many thanks,
Chris.
|
| Author |
Message |
Dilbert

|
Posted: 2003-11-12 18:58:00 |
Top |
java-programmer, cannot call a paint function across classes?
Just wondering if this is possible, as im having no luck working it out, no
matter what ive tried so far..
I have 2 classes, lets call them gP and kP. in gP ive got this function:
public void paint55(java.awt.Graphics graphics) {
Dimension d=getSize();
graphics.setColor(Color.RED);
graphics.fillRect(0, 0, (int)d.getWidth(), (int)d.getHeight());
graphics.setColor(Color.BLACK);
//call another function here
}
now, in the kP class, im using a jComboBox, the combo box works fine, but i
want to try and call that function from it
Ive tried
gP.paint55();
ive tried referencing it as gP paint55();
Just cant work it out, any ideas?
Thanks
|
| |
|
| |
 |
Thomas Fritsch

|
Posted: 2003-11-12 23:26:00 |
Top |
java-programmer >> cannot call a paint function across classes?
Dilbert wrote:
>Just wondering if this is possible, as im having no luck working it out, no
>matter what ive tried so far..
>
>I have 2 classes, lets call them gP and kP. in gP ive got this function:
>
"gP" is the name of your *class*, if I understood you correct.
>
> public void paint55(java.awt.Graphics graphics) {
> Dimension d=getSize();
> graphics.setColor(Color.RED);
> graphics.fillRect(0, 0, (int)d.getWidth(), (int)d.getHeight());
> graphics.setColor(Color.BLACK);
> //call another function here
>}
>
>
>now, in the kP class, im using a jComboBox, the combo box works fine, but i
>want to try and call that function from it
>Ive tried
>
>gP.paint55();
>
You call this function as if "gP" were the name of a *variable* in your
code.
>ive tried referencing it as gP paint55();
>
>Just cant work it out, any ideas?
>
>Thanks
>
>
It looks like you did not yet grasp the difference between Class and Object.
I suggest working through an introductory book on Java programming.
/Thomas
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Finding path of running classFile currentDir = new File(System.getProperty("user.dir"));
I need to know the path to a class that is running and have had
partial success. The code shown above finds the folder where the JVM
is running.
If I start my app from a terminal window or a native executable IDE,
the JVM will run in the folder where my class is located and
currentDir points to the folder that I need. But if I start the app
from an IDE written in Java, I get the folder where the IDE is located
rather than the folder where the app that I was running is located.
My app will be used in a classroom setting by people who will NOT have
command prompt permissions. They will have to run it from an IDE.
I'd really like to stick with the one that we're currently using
(written in Java).
Apparently, both the IDE and my application are running in the same
JVM. Is there any way to get the application to run in its own JVM so
user.dir points to that folder?
If not, any other suggestions?
TIA
tom
- 2
- How to get you Extenal/Real IP (Router)Hi All,
I am writing a code as a Java Application (not Applet or Servlet) and I
am trying to find out what is my real IP address (not 192.168. one). I
am behind my LinkSys router and everything I try I still get 192.168.
I have tried:
- InetAddress: Always returns 192.168 address (unless I am missing
something).
- Open Socket to www.cnn.com,80 and read local address (still 192.168).
- I am reading about Upnp but not sure if that's the way I can ask my
Router about my real IP.
- Calling http://www.whatismyip.com and parse the result seems too
strange.
Any idea?
Thanks in advance,
Homer
- 3
- Any good GUI design/prototyper tools?I'm looking for a tool that will let me quickly design/prototype Swing
GUI layouts so I can get screenshots for review by end users. The
emphasis is on design, not building as such - I'm not interested in
*using* any generated code at this stage, although the tool needs to
be able to save and load layouts, and preview the layouts.
What is really required is something that works like a drawing program
but with Swing components. Ideally it would:
o Allow absolute positioning and sizing, because at this stage I'm
essentially doing graphic design and don't want to be worrying about
implementation of layout managers
o Allow easy moving and alignment of elements or groups of elements
o Have a Property Editor, but with configuration of defaults so that I
don't have to, for example, change the font on every element.
o Have a quick build/preview so I can get screenshots easily.
I have looked at a few IDEs and GUI builder tools, but so far nothing
seems really orientated towards making this particular task quick and
easy. Does anyone know of anything that's appropriate... or should I
be thinking about coding something myself?
- 4
- Refusing TCP connections - ServerSocketI want to create a ServerSocket.
I want it to accept one connection.
If another connection request comes in, I want it to be refused, not queued.
Even if I set backlog to 1, on the OS I'm testing on (Linux) I'm able to
queue up a bunch more connections (5 or 6).
I know the actual backlog size is OS dependent even if I explicitly set it
in the ServerSocket constructor.
So, how do I refuse all subsequent connections after I accept that first one?
--
Steve Sobol, Victorville, CA PGP:0xE3AE35ED www.SteveSobol.com
Geek-for-hire. Details: http://www.linkedin.com/in/stevesobol
- 5
- junit test in eclipse
code from some tutorial
---------
import junit.framework.TestCase;
public class SampleTest extends TestCase {
...
}
---------
code from another tutorial
---------
import org.junit.*;
import static org.junit.Assert.*;
public class SampleTest {
...
}
---------
Second one is working well. I think second one is simpler, so I like it.
But I can't use them with TestSuite.
"
The method addTest(Test) in the type TestSuite is not applicable for the
arguments
(Class<ArmorTypeWrapperTest>)
"
---------
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
TestSuite suite = new TestSuite("Test for vanguard.wardrobe");
//$JUnit-BEGIN$
suite.addTest(ArmorTypeTest.class);
suite.addTest(ArmorTypeWrapperTest.class);
//$JUnit-END$
return suite;
}
}
---------
Thank you
Sean
- 6
- OutOfMemoryError - Any Way to Exit JVM?Hi all,
We're having a major problem keeping Java calculators (that were
written by a third party vendor) alive. They leak memory and
eventually cause OutOfMemoryErrors. We cannot address the problem
directly until the vendor does, so we need to manage these dying
calculators.
Unfortunately, they are all started in separate processes and an
OutOfMemory error seems to kill *only* the thread, NOT the JVM. Is
there a way to ensure that the JVM dies as well?
My real hope is that some JVM has a command line option to kill the
whole thing when it has an allocation error. Otherwise, perhaps we can
add another thread to the process that watches it, but that's harder.
Any help would be greatly appreciated.
Thanks,
Steve Lieberman
- 7
- close() of active socket does not work on FreeBSD 6On Wednesday 13 December 2006 04:49, Daniel Eischen wrote:
> On Tue, 12 Dec 2006, Poul-Henning Kamp wrote:
> > In message <email***@***.com>, Bruce Evans writes:
> >> On Mon, 11 Dec 2006, Daniel Eischen wrote:
> >>
> >> It's probably a nightmare in the kernel too. close() starts looking
> >> like revoke(), and revoke() has large problems and bugs in this area.
> >
> > There is the distinctive difference that revoke() operates on a name
> > and close() on a filedescriptor, but otherwise I agree.
>
> Well, if threads waiting on IO are interruptable by signals,
> can't we make a new signal that's only used by the kernel
> and send it to all threads waiting on IO for that descriptor?
> When it gets out to actually setup the signal handler, it
> just resumes like it is returning from an SA_RESTART signal
> handler (which according to another posting would reissue
> the IO command and get EBADF).
Stop using signal, it is slow for threaded process, first you don't
know which threads are using the descriptor, second, you have
to run long code path in kernel signal code to find and deliver
the signals to all interested threads, that is too expensive for
benchmark like apache benchmark.
David Xu
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 8
- 9
- JBoss e eccezioni...Ciao a tutti, ho un problema con JBoss! Ogni volta che entra in errore
la mia applicazione, JBoss s'impalla e rimango in pending 10 minuti
prima che mi lanci fuori un eccezione. Avete idea se ci sono variabili
da settare perch?non rimanga cos?tanto in attesa? Grazie.
- 10
- Positioning scrollable dataI have pasted a bare bones program below which demonstrates the
problem I am trying to solve.
I have a JTextArea on a JScrollPane, and the number of lines to be
displayed exceeds the display area. Thus scrolling is activated, and
the starting screen shows from line 1 onwards with the scrollbars
available for scrolling. So far so good.
Now I want to redisplay another screen. Once again the number of lines
exceeds the display area, This time around though, the END of the
lines are displayed. Instead of (for instance) lines 1 to 10 of 100
lines being displayed, lines 90 to 100 are being displayed.
I don't want this. Each time I want to data on the JTextArea to be
displayed from line 1 onwards.
Some research that I did indicated that getViewport().setViewPosition
would be my friend. However, as you can see in the code below, I DID
code this, but it would not work.
Does anybody have an idea how to change the code below so that I can
get the display that I want?
Thanks!
/*
* Example code to demonstrate the problem:
* The first time the data in the JTextArea is displayed,
* the data is positioned at the first line.
* Subsequently (after clicking the Next button), the data
* is positioned such that the last line is displayed.
* I want to reposition the data in the JTextArea such
* that each time after a refresh, the first line of the data
* should be displayed.
***********************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Example extends JFrame implements ActionListener
{
JTextArea textArea;
JScrollPane js;
JButton nextButton = new JButton( "Next" );
JButton endButton = new JButton( "End" );
int counter = -1;
Example()
{
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
textArea = new JTextArea( 15, 50);
textArea.append( " " );
js = new JScrollPane( textArea );
nextButton.addActionListener( this );
endButton.addActionListener( this );
JPanel pane = new JPanel();
pane.setLayout( new FlowLayout() );
pane.add( nextButton );
pane.add( endButton);
pane.add( js );
setContentPane( pane );
setLines();
setTitle("Example");
setSize(600,400);
setVisible(true);
} //end constructor
public void actionPerformed( ActionEvent evt )
{
Object source = evt.getSource();
if( source == nextButton )
{
setLines();
}
else if( source == endButton )
{
System.exit(0);
}
repaint();
}
void setLines()
{
textArea.setText( "" );
counter++;
for( int n=0; n<100; n++ )
{
textArea.append( counter + " " + n + "This line is filler
data to demonstrate problem\n" );
}
// Attempt to position to top of data... but it does not work :(
js.getViewport().setViewPosition( new Point( 0,0 ) );
}
public static void main( String[] args )
{
new Example();
}
}
- 11
- customize JScrollBarHello,
I want to scroll up/down by pressing buttons
other than the standards of JScrollBar(These
simple up und down arrows).
Is it possible?
- 12
- iulivarzariuda.. invites you to Going.comHey! Check out this cool new site Going.com. They'll keep you posted
on What's Happening and Who's Going around town.
- Be in the know about fun events, concerts, parties and see who's
going.
- Keep up with your friends and share what you are up to.
- Get invited to exclusive Going.com sponsored special events.
I figured you would want in on it too. Check it out at:
http://going.com/join_me/SsPiUUVYFC
iulivarzariuda..
This email was sent by the person in the from line and the subject
line. Please email them directly if you have any questions.
Going is compliant with the Can-Spam Act of 2003. For more
information, read our privacy policy at
http://going.com/privacy_policy.php.
Going, Inc - 8 Winter Street, Boston, MA 02108, USA
email***@***.com
- 13
- 14
- sending raw data to a printer driverIn Windows I have some win32 code that I use in VC++ programs to send
raw data to the printer driver. I would like to do the same thing in
Java; does anyone know how to do this. Specifically, I need to send
printer codes or language commands to a printer. Specifically in the
case I am trying to write is to be a able to send command codes to an
Intermec barcode printer through a text file which has IPL (Intermec
Printer Language) code in it. It is just text, but it instructs the
printer what to do. Of course the printer code is not restricted to
just printer codes. If I could figure out how to send raw data to the
printer driver, this would help a lot.
Z.K.
- 15
- How to add a button next to title at the JTabbedPaneHi,
I want to add a small button next to the title of each tabbed pane and
receive user's mouse click event at the small button.
And finally, the selected pane will be removed.
How to add other object, button, into Title part of JTabbedPane ?
Any ideas?
|
|
|