Click here to Skip to main content
16,004,587 members
Home / Discussions / Java
   

Java

 
QuestionCombo box containing Checkbox as its items Pin
PrajnaS23-Mar-09 20:56
PrajnaS23-Mar-09 20:56 
AnswerRe: Combo box containing Checkbox as its items Pin
TorstenH.24-Mar-09 20:53
TorstenH.24-Mar-09 20:53 
AnswerRe: Combo box containing Checkbox as its items Pin
PrajnaS24-Mar-09 21:01
PrajnaS24-Mar-09 21:01 
GeneralRe: Combo box containing Checkbox as its items [modified] Pin
TorstenH.24-Mar-09 21:12
TorstenH.24-Mar-09 21:12 
GeneralRe: Combo box containing Checkbox as its items Pin
PrajnaS24-Mar-09 21:16
PrajnaS24-Mar-09 21:16 
GeneralRe: Combo box containing Checkbox as its items Pin
TorstenH.24-Mar-09 21:18
TorstenH.24-Mar-09 21:18 
GeneralRe: Combo box containing Checkbox as its items Pin
PrajnaS24-Mar-09 22:31
PrajnaS24-Mar-09 22:31 
Questionjava Applets Pin
fesali23-Mar-09 0:08
fesali23-Mar-09 0:08 
i have the code of madelbrot but i dont know how to modify the program
so the question is:
how to modify the program Mandelbrot to allow a general rectangular region of the complex plane to be viewed in the image. The user may select the rectangle by dragging the mouse.
i have to modify this program but i dont know how
so would anyone help me for this problem:
<pre&gt
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;

public class Mandelbrot extends JApplet {
public static void main(String s[]) {
JFrame frame = new JFrame();
frame.setTitle("Mandelbrot set");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new Mandelbrot();
applet.init();
frame.getContentPane().add(applet);
frame.pack();
frame.setVisible(true);
}

public void init() {
JPanel panel = new MandelbrotPanel();
getContentPane().add(panel);
}
}

class MandelbrotPanel extends JPanel{
BufferedImage bi;

public MandelbrotPanel() {
int w = 500;
int h = 500;
setPreferredSize(new Dimension(w, h));
setBackground(Color.white);
bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
WritableRaster raster = bi.getRaster();
int[] rgb = new int[3];
float xmin = -2;
float ymin = -2;
float xscale = 4f/w;
float yscale = 4f/h;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
float cr = xmin + j * xscale;
float ci = ymin + i * yscale;
int count = iterCount(cr, ci);
rgb[0] = (count & 0x07) << 5;
rgb[1] = ((count >> 3) & 0x07) << 5;
rgb[2] = ((count >> 6) & 0x07) << 5;
raster.setPixel(j, i, rgb);
}
}
}

private int iterCount(float cr, float ci) {
int max = 512;
float zr = 0;
float zi = 0;
float lengthsq = 0;
int count = 0;
while ((lengthsq < 4.0) && (count < max)) {
float temp = zr * zr - zi * zi + cr;
zi = 2 * zr * zi + ci;
zr = temp;
lengthsq = zr * zr + zi * zi;
count++;
}
return max-count;
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(bi, 0, 0, this)
}
};</pre> tags
QuestionJava script required for local printing Pin
seenubhai22-Mar-09 20:35
seenubhai22-Mar-09 20:35 
AnswerRe: Java script required for local printing Pin
fly90423-Mar-09 6:43
fly90423-Mar-09 6:43 
Questionhow to implement Numbered list and Bulleted with JTextPane? Pin
@_csharp21-Mar-09 22:44
@_csharp21-Mar-09 22:44 
Questionhow to make user interface in java. Pin
vikss20-Mar-09 19:55
vikss20-Mar-09 19:55 
AnswerRe: how to make user interface in java. Pin
fly90421-Mar-09 2:09
fly90421-Mar-09 2:09 
QuestionWhat's your advice ? Pin
Mohammad Dayyan20-Mar-09 18:03
Mohammad Dayyan20-Mar-09 18:03 
AnswerRe: What's your advice ? Pin
N a v a n e e t h20-Mar-09 19:03
N a v a n e e t h20-Mar-09 19:03 
GeneralRe: What's your advice ? Pin
Mohammad Dayyan20-Mar-09 19:09
Mohammad Dayyan20-Mar-09 19:09 
AnswerRe: What's your advice ? Pin
jschell1-Apr-09 15:02
jschell1-Apr-09 15:02 
Questioncubic equation in java Pin
vikss20-Mar-09 11:17
vikss20-Mar-09 11:17 
AnswerRe: cubic equation in java Pin
fly90420-Mar-09 11:45
fly90420-Mar-09 11:45 
Questionjava..looping.... Pin
vitaminwater2219-Mar-09 21:23
vitaminwater2219-Mar-09 21:23 
AnswerRe: java..looping.... Pin
Cedric Moonen19-Mar-09 22:33
Cedric Moonen19-Mar-09 22:33 
AnswerRe: java..looping.... Pin
fly90419-Mar-09 23:57
fly90419-Mar-09 23:57 
GeneralRe: java..looping.... Pin
Nagy Vilmos20-Mar-09 10:30
professionalNagy Vilmos20-Mar-09 10:30 
GeneralRe: java..looping.... Pin
fly90420-Mar-09 11:43
fly90420-Mar-09 11:43 
Generalcode and srs for project of website development in java Pin
bindlas601719-Mar-09 18:21
bindlas601719-Mar-09 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.