How would I go about doing that, google and looking around haven't given me a straight answer that I can implement well without redesigning the whole program.
Here is the code for the keylisteners and their respective functions:
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { // init maxCount = 192; viewX = viewY = 0.0; zoom = 1.0; redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_SPACE) { // next fractal fractal = (fractal + 1) % 2; viewX = viewY = 0.0; zoom = 1.0; julia = false; if (fractal == 1) { juliaX = 0.56667; juliaY = -0.5; julia = true; } redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_I) { // zoom in viewX += 0.25 * zoom; viewY += 0.25 * zoom; zoom *= 0.5; redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_O) { // zoom out viewX -= 0.5 * zoom; viewY -= 0.5 * zoom; zoom *= 2.0; redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_J) { // julia julia = !julia; redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_P) { // next palette nextPalette(); redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_S) { // smoothing smooth = !smooth; redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_A) { // antialiasing antialias = !antialias; redraw(false); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { // move mode rect = false; if (toDrag) repaint(); } else if (e.getKeyCode() == KeyEvent.VK_CONTROL) { // preview mode if (!preview) { preview = true; redraw(true); } } }
Main for running the applet:
public static void main(String[] args) { Frame frame = new Frame("Fractal Viewer"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Applet applet = new MandelGen(); Button(); frame.add(applet, BorderLayout.CENTER); frame.setSize(1024, 768); frame.show(); applet.init(); applet.start(); } }
This post has been edited by TehRoot: 07 April 2012 - 08:03 PM