luc ndabaneze

Greenhorn
+ Follow
since May 06, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by luc ndabaneze

hello Nat

thr reason why i wanted to create more than one rmi server is because i want to control the amount of job sent to a processor, so i partitioned job into small chunks and sent to differents processors. i guess my question is if a abstract class implements the interface and its children instantiated depending on the method you calling
would work on rmi?
or
in the alternative way does RMI support registering more than one server at the time?
thanks
20 years ago
hi everyone
i have a client class that i want to access objects remotely from several sources (client java class slave)
as those sources are doing different things they cannot shares the same interface from which the client can ask for service , because they would have to implement all the methods declared in the inteface.
so i 'd like to know one thing
can i create more than one interface and bind the server to each or should i create an abstract class that implements the interface and child classes for each service i want?
20 years ago
hi rachel
sorry here is the code

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class canvas1 extends JFrame {
man mandel;
public canvas1() {
setTitle("MandelbrotSet");
setSize(600,600);

getContentPane().setLayout(new BorderLayout() );
JPanel Bottom = new JPanel();
JButton StartButton = new JButton("START");
StartButton.setEnabled(true);
mandel= new man();
getContentPane().add(mandel,BorderLayout.CENTER );
Thread runner = new Thread(mandel);
runner.start();



//StartButton.addActionListener(mandel);
Bottom.add(StartButton);
getContentPane().add(Bottom,BorderLayout.SOUTH );}
public Insets getInsets() {

return new Insets(2,2,2,2);
}



class man extends JComponent implements Runnable {

Graphics offscreen;
Image im;
double xscale,yscale;
boolean running;



double xmax = 2;
double ymax = 2;
double xmin = -1.2;
double ymin = -0.2;



public void paintComponent(Graphics g) {

if (im == null) {
g.setColor(Color.red);
g.fillRect(0,0,getWidth(),getHeight()) ; }
else
{
g.drawImage(im,0,0,null) ;}




}

public void run() {

Dimension d = getSize();
int maxX = d.width - 1;
int maxY = d.height - 1;
im = createImage(maxX,maxY);
offscreen = im.getGraphics();
offscreen.setColor(Color.black);
offscreen.fillRect(0,0,maxX,maxY);
double dx,dy;

xscale = (xmax-xmin)/d.width;
yscale = (ymax-ymin)/ d.height;

for ( int i= 0 ; i<maxX ; i++ ) {
dx= (xmin+ xscale) ;
for ( int j = 0;j<maxY;j++) {
dy = (ymin + yscale) ;
offscreen.setColor(Color.getHSBColor(calculate(dx,dy)/100.0f,1f,1f));
offscreen.fillRect(i,j,10,10);
paintImmediately(i,j,10,10);
try {
Thread.currentThread().sleep(1000) ;
}
catch (InterruptedException e) { }
dy= dy + yscale;

}
dx = dx + xscale;

}


}


int calculate(double a, double bi){

double c,ci,d,z,zi;
int Max = 250;
a= 0;
bi= 0;
int count = 0;
//c=0.2;
//ci=0.2;
d=0;

while ( count < Max && d<4) {
z= a*a- bi*bi + xmin ;
zi = 2*(a*bi) +ymin ;
a=z;
bi=zi;
d = (a*bi);

count++ ; }


return count; }

}

public static void main(String[] args) {
try {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {}

canvas1 application = new canvas1();
application.show();




application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE) ;




}

thanks
}
20 years ago
hello guys
i have this drawing application where i compute pixel on a Jpanel with different colors , as i did not want to use an applet, i created a JFrame as the container of my Jpanel, My Jpanel implements Runnable as well , when i tried to called the public void run()method of the Jpanel by calling start inside the construtor of JFrame , it says nullpointer exception , could anyone tell me why and where is the best place to call my runnable?

thanks
20 years ago
hello there
i have been trying to produce a mandelbrot set java apps
and i keep banging my head to the wall
can anybody tell me what is wrong with my code?

import java.awt.*;
import java.awt.event.*;
import java.util.EventListener;
import javax.swing.*;




public class display extends JFrame {


public display(){
setTitle("MandelbrotSet");
setSize(300,300);
setBackground(Color.white);
mandelbrot mandel;
getContentPane().setLayout(new BorderLayout() );
JPanel Bottom = new JPanel();
JButton StartButton = new JButton("START");
StartButton.setEnabled(true);
mandel= new mandelbrot();
getContentPane().add(mandel , BorderLayout.CENTER);
//Thread t = new Thread(mandel);
//t.start();
StartButton.addActionListener(mandel);
Bottom.add(StartButton);
getContentPane().add(Bottom,BorderLayout.SOUTH);


}
class Complex {
double real,imag ;

Complex() {
real= 0.0;
imag= 0.0;
}
Complex(double x, double y) {

real= x;
imag= y;
}
double length(Complex z){
return (z.real*z.imag);
}
};



class mandelbrot extends JPanel implements Runnable,ActionListener {

Graphics offscreen ;
Image im;
// offscreen = im.getGraphics();
Thread runner ;

double xscale,yscale;
double xmin = -2;
double xmax = 2.5;
double ymin = -2;
double ymax = 2.5;
int width =300; //getSize().width;
int height = 300;//getSize().height;


//private int width = 300;
//private int height = 300;
Complex z = new Complex();
public void actionPerformed(ActionEvent event){
String command = event.getActionCommand();
if (command.equals("START")) {
startRunning();
}
}
void startRunning() {
//coloredCoordinates();
//update(offscreen);}
runner = new Thread(this);
runner.start();
}


public void paint(Graphics g) {
if (im == null) {

g.setColor(Color.blue);
g.fillRect(0,0,getWidth(),getHeight());
}
else {
g.drawImage(im,0,0,null);
}


}


int caliter(){

Complex c;
c= new Complex(0,0);
z.real= c.real;
z.imag= c.imag;
int count;
count=0;

while (count< 256 && z.length(z)<4) {
z.real= (z.real*z.real) - (z.imag*z.imag) + c.real;
z.imag = 2*(z.real*z.imag)+ c.imag;
c.real=z.real;
c.imag= z.imag;
}
count++;
return count;
}

void coloredCoordinates(){
//int width = getSize().width;
//int height = getSize().height;

xscale= (xmax - xmin)/width;
yscale = (ymax - ymin)/height;


for (int x = 0 ;x<width;x++) {
x=(int)(xmin+ (x*xscale)) ;
for (int y =0 ; y<height;y++) {

y= (int)(ymin + (y*yscale));
int index = caliter();

setPixel(offscreen ,x,y,index);
}
}
}

void setPixel( Graphics g,int x, int y,int colour) {

g.setColor(Color.getHSBColor(colour,0f,1f));

g.fillRect( x, y, 1,1);

}


public void run()
{
//int width = getSize().width;
//int height = getSize().height;
Image im = createImage(width,height);
offscreen = im.getGraphics();

offscreen.setColor(Color.white);
offscreen.fillRect(0,0,width,height);


coloredCoordinates();

repaint();


}
}

public static void main (String[] args) {

try {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());


catch (Exception e) {}

display application = new display();
application.show();

application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE) ;

}
}


i'd appreciate
20 years ago
thanks guys , here is the code ,

protected static ImageIcon createImageIcon(String path,
String description) {
java.net.URL imgURL = CelsiusConverter2.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}

this the method i used to load my images and everytime it is saying " couldn't find the file" and my image file is on the same directory with
it, that is why i think it is my classpath the problem than my code..
20 years ago
hello ,
i am working on my GUI skill and i stumble on a pretty silly problem but well i guess it is not that silly to me, as i am using no IDE , instead a simple dos command to run my program and a notepad to write my classes,and i can't seem to be able to get my code to find my image file and load them can anybody let me know how to set the path?
20 years ago
Hi there
i m trying to launch my career in software developpement,as i have no experience whatsoever , i found it hard to get a job , i've passed SCJP and plan to take a shot at the developper one soon, but i like to know if this is the right approach ,alternatively there are some companies that provide some programming courses at exorbitant prices but guarantee you job in the end of it , what do you guys think ?

i'd appreciated
20 years ago
hi
i may be wrong and the odds are i probably am , but those S and P remind me of quadratic equations formula x^2 + Sx + p where S = x+y and P = xy and knowing both can resolve the roots
could it have anything to do with it?
21 years ago
thanks guys
anyone has a good advice on how to proceed from here?
21 years ago
got 86%, very happy about it, althought i run out of time ,
i owe this to sierra's book, and javacertificate.com , they both pretty helpful

thanks guys
21 years ago
yes u're right franco , corey's tiplines are even better explanation
thanks guys
sorry mark
i was replying to Casoula, i guess you are right
thanks
hi
i hate to disagree but in kathy sierra's book page 101 it says " the rule is , a static method of a class can't access a non-static(instance) menber method or variable- of it's own class " (sic)
so , i think that the reason it compile it because the compiler is only interested to know wheter the reference is of the class type , but a run time error should be thrown...
what do you think ?