When to use super.paint(g) ?

Hello everyone,
I have some issues in basic animations that I need to clear, I'd be very happy if you helped.
I have 3 applications in hand that work differently concerning refreshing of the images with the repaint() method. The two initial ones use timers to repaint, the last one (that I copied from "Learning Java") follows mouse dragging gestures -I don't know if it has to do anything with that, however.
The first one needs desperately a super.paint(g) line to erase older frames of a moving ball animation:
package cms_tp23;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Balle extends JFrame implements ActionListener, KeyListener {
     JButton bNord = new JButton("Start!");
     JButton bSud = new JButton("Stop!");
     JPanel panel = new JPanel();
     Object source;
     Timer timer = new Timer(30,this);
     int hei = 300, wid = 300, x = 100, y = 65, count = 0;
     boolean flag1 = false, flag2 = false;
     char key;
     Color red = Color.RED, blue = Color.BLUE, aux = Color.BLUE;
     public Balle ()
          this.setTitle("Balle");
          this.setResizable(false);
          this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
          Toolkit tk = Toolkit.getDefaultToolkit();
          Dimension monitord = tk.getScreenSize();
          this.setBounds((monitord.width-wid)/2,(monitord.height-hei)/2, wid, hei);
          x = wid/2 - 20;
          Container cp = this.getContentPane();
          setVisible(true);
          bNord.addActionListener(this);
          bSud.addActionListener(this);
          bNord.addKeyListener(this);
          bSud.addKeyListener(this);
          add(bNord,BorderLayout.NORTH);
          add(bSud,BorderLayout.SOUTH);
          panel.setBackground(Color.WHITE);
          add(panel);
          bNord.requestFocus();
          setVisible(true);
     public void actionPerformed(ActionEvent e)
          source = e.getSource();
          if (source == bNord)
               timer.start();
          if (source == bSud)
               timer.stop();
          if (source == timer)
               repaint();
     public void keyPressed(KeyEvent ke)
     public void keyReleased(KeyEvent ke)
     public void keyTyped(KeyEvent ke)
          key = ke.getKeyChar();
          if (key == '\n')
               timer.start();
          if (key == '\u001B')
               timer.stop();
     public void paint(Graphics g)
          super.paint(g);
          g.setColor(aux);
          g.fillOval(x,y,40,40);
          if (y > hei - 69 || y < 61)
               flag1 = !flag1;
               aux = g.getColor();
               if (aux == red) aux = blue; else aux = red;
          if (!flag1) y = y+1;
          else y = y-1;
          if (x > wid-43 || x < 3)
               flag2 = !flag2;
               aux = g.getColor();
               if (aux == red) aux = blue; else aux = red;
          if (!flag2) x = x+1;
          else x = x-1;
     public static void main(String[] args) {
          Balle maBalle = new Balle();
}The second one doesn't display the backround color I've fixed if I don't use the super.paint(g) instruction:
//file: Fenetre.java
package cms_tp23;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Fenetre extends JFrame implements ActionListener, KeyListener {
     JButton bNord = new JButton("Start!");
     JButton bSud = new JButton("Stop!");
     Object source;
     Timer timer = new Timer(1,this);
     int hei = 600, wid = 600;
     char key;
     static JLabel label = new JLabel("");
     public Fenetre()
          this.setTitle("Balle");
          this.setResizable(true);
          this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
          Toolkit tk = Toolkit.getDefaultToolkit();
          Dimension monitord = tk.getScreenSize();
          this.setBounds((monitord.width-wid)/2,(monitord.height-hei)/2, wid, hei);
          Container cp = this.getContentPane();
          this.setVisible(true);
          bNord.addActionListener(this);
          bSud.addActionListener(this);
          bNord.addKeyListener(this);
          bSud.addKeyListener(this);
          add(bNord,BorderLayout.NORTH);
          add(bSud,BorderLayout.SOUTH);
          Panneau panneau = new Panneau();
          panneau.setBackground(new Color(149,74,74));
          label.setForeground(Color.ORANGE);
          panneau.add(label);
          add(panneau);
          bNord.requestFocus();
          this.setVisible(true);
     public static void main(String[] args) {
          Fenetre fenetre = new Fenetre();
     public void actionPerformed(ActionEvent e) {
          source = e.getSource();
          if (source == bNord)
               aksiyon('1');
          if (source == bSud)
               aksiyon('2');
          if (source == timer)
               repaint();
     public void keyTyped(KeyEvent ke) {
          key = ke.getKeyChar();
          if (key == '\n')
               if (timer.isRunning()) aksiyon('2'); else aksiyon('1');
          if (key == '\u001B')
               timer.stop();
     public void aksiyon(char c)
          if (c == '1')
               timer.start();
          else if (c == '2')
               timer.stop();
     public void keyPressed(KeyEvent arg0) {
     public void keyReleased(KeyEvent arg0) {
//file: Panneau.java
package cms_tp23;
import java.awt.*;
import javax.swing.*;
import java.util.Date;
public class Panneau extends JPanel {
     double lastDate;
     double dt;
     double x;
     double y = 0;
     double x0;
     double y0;
     double vx;
     double vy;
     double vx0;
     double vy0 = 0;
     double gravite = 1;
     double frottement = 0.00;
     double diametre = 30;
     boolean firstjump = false;
     public void paint(Graphics g)
          super.paint(g);
          g.setColor(Color.GREEN);
          dt = 1;
          x = (getSize().width - diametre)/2;
          if (!firstjump)
               vy += vy0 + gravite*dt;
               vy *= 1 - frottement;
               y +=(y0 + vy*dt)/5.0f;
          else
               vy -= vy0 + gravite*dt;
               vy *= 1 - frottement;
               y -=(y0 + vy*dt)/500.0f;
               firstjump = false;
          g.fillOval((int)x,(int)y,(int)diametre,(int)diametre);
          if (y >= getSize().height - diametre && vy >= 0)
               vy = -vy;
               firstjump = true;
}And the third one (that I just rewrote) doesn't seem to need the famous line to work properly:
//file: HelloJava2
import java.awt.*;
import javax.swing.*;
public class HelloJava2  {
     public static void main(String[] args) {
          JFrame frame = new JFrame("Hello, Java!");
          HelloComponent hello = new HelloComponent("Hello Java!");
          frame.getContentPane().add(hello);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(new Dimension(300,300));
          frame.setVisible(true);
//file: HelloComponent
import javax.swing.*;
import java.awt.event.*;
import java.awt.Graphics;
class HelloComponent extends JComponent implements MouseMotionListener {
     String theMessage;
     int messageX = 100, messageY = 100;
     public HelloComponent(String message)
          theMessage = message;
          addMouseMotionListener(this);
     public void paintComponent(Graphics g) {
          g.drawString(theMessage, messageX, messageY);
     public void mouseDragged(MouseEvent arg0) {
          messageX = arg0.getX();
          messageY = arg0.getY();
          repaint();
     public void mouseMoved(MouseEvent arg0) {
}Now, if anyone could help me out... I hope the third one doesn't lead to a copyright infringement, I don't think it does.
Thanks.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BalleRx extends JFrame implements ActionListener, KeyListener {
    JButton bNord = new JButton("Start!");
    JButton bSud = new JButton("Stop!");
//    JPanel panel = new JPanel();
    Object source;
    char key;
    int hei = 300, wid = 300, x;
    BallePanel ballePanel;
    public BalleRx() {
        this.setTitle("Balle");
        this.setResizable(false);
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension monitord = tk.getScreenSize();
        this.setBounds((monitord.width-wid)/2,(monitord.height-hei)/2, wid, hei);
        x = wid/2 - 20;
//        setVisible(true);
        bNord.addActionListener(this);
        bSud.addActionListener(this);
        bNord.addKeyListener(this);
        bSud.addKeyListener(this);
        ballePanel = new BallePanel();
//        Container cp = this.getContentPane();
        add(bNord,BorderLayout.NORTH);
        add(bSud,BorderLayout.SOUTH);
        // instead you can do cp.setbackground(...
//        panel.setBackground(Color.WHITE);
//        add(panel);
        add(ballePanel);
        bNord.requestFocus();
        setVisible(true);
    public void actionPerformed(ActionEvent e) {
        source = e.getSource();
        if (source == bNord)
            ballePanel.start();
        if (source == bSud)
            ballePanel.stop();
    public void keyTyped(KeyEvent ke) {
        key = ke.getKeyChar();
        if (key == '\n')
            ballePanel.start();
        if (key == '\u001B')    // KeyEvent.VK_ESCAPE
            ballePanel.stop();
    public void keyPressed(KeyEvent ke) { }
    public void keyReleased(KeyEvent ke) { }
    public static void main(String[] args) {
        BalleRx maBalle = new BalleRx();
class BallePanel extends JPanel implements ActionListener {
    Timer timer = new Timer(30,this);
    int x = 100, y = 65, count = 0, DIA = 40;
    boolean flag1 = false, flag2 = false;
    Color red = Color.RED, blue = Color.BLUE, aux = Color.BLUE;
    public void actionPerformed(ActionEvent e) {
        repaint();
    protected void paintComponent(Graphics g) {
        // this clears the background
        // (if you don't you get artifacts)
        super.paintComponent(g);
        // or you can do this to clear it
        //((Graphics2D)g).setBackground(Color.white);
        //g.clearRect(0, 0, getWidth(), getHeight());
        // or this
        //g.setColor(Color.white);
        //g.fillRect(0, 0, getWidth(), getHeight());
        g.setColor(aux);
        g.fillOval(x,y,DIA,DIA);
//        if (y > hei - 69 || y < 61) {    // no insets to mess with
        if (y > getHeight() - DIA || y < 0) {
            flag1 = !flag1;
            aux = g.getColor();
            if (aux == red) aux = blue; else aux = red;
        if (!flag1) y = y+1;
        else y = y-1;
        if (x > getWidth() - DIA || x < 3) {
            flag2 = !flag2;
            aux = g.getColor();
            if (aux == red) aux = blue; else aux = red;
        if (!flag2) x = x+1;
        else x = x-1;
    public void start() {
        if(!timer.isRunning())
            timer.start();
    public void stop() {
        timer.stop();
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FenetreRx extends JFrame implements ActionListener, KeyListener {
    JButton bNord = new JButton("Start!");
    JButton bSud = new JButton("Stop!");
    Object source;
    Timer timer = new Timer(1,this);
    int hei = 600, wid = 600;
    char key;
    static JLabel label = new JLabel("");
    public FenetreRx() {
        this.setTitle("Balle");
        this.setResizable(true);
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension monitord = tk.getScreenSize();
        this.setBounds((monitord.width-wid)/2,(monitord.height-hei)/2, wid, hei);
//        Container cp = this.getContentPane();
//        this.setVisible(true);
        bNord.addActionListener(this);
        bSud.addActionListener(this);
        bNord.addKeyListener(this);
        bSud.addKeyListener(this);
        add(bNord,BorderLayout.NORTH);
        add(bSud,BorderLayout.SOUTH);
        PanneauRx panneau = new PanneauRx();
        panneau.setBackground(new Color(149,74,74));
        label.setForeground(Color.ORANGE);
        panneau.add(label);
        add(panneau);
        bNord.requestFocus();
        this.setVisible(true);
    public static void main(String[] args) {
        FenetreRx fenetre = new FenetreRx();
    public void actionPerformed(ActionEvent e) {
        source = e.getSource();
        if (source == bNord)
            aksiyon('1');
        if (source == bSud)
            aksiyon('2');
        if (source == timer)
            repaint();
    public void keyTyped(KeyEvent ke) {
        key = ke.getKeyChar();
        if (key == '\n')
            if (timer.isRunning()) aksiyon('2'); else aksiyon('1');
        if (key == '\u001B')
            timer.stop();
    public void aksiyon(char c) {
        if (c == '1') {
            timer.start();
        else if (c == '2') {
            timer.stop();
    public void keyPressed(KeyEvent arg0)  { }
    public void keyReleased(KeyEvent arg0) { }
class PanneauRx extends JPanel {
    double lastDate;
    double dt;
    double x;
    double y = 0;
    double x0;
    double y0;
    double vx;
    double vy;
    double vx0;
    double vy0 = 0;
    double gravite = 1;
    double frottement = 0.00;
    double diametre = 30;
    boolean firstjump = false;
    public void paintComponent(Graphics g) {
        // draws the default JPanel background including
        // any background color you may have set
        super.paintComponent(g);
        // if you like you can omit the call to
        // super.paintComponent and fill in the
        // background yourself with:
        //g.setColor(Color.pink);
        //g.fillRect(0, 0, getWidth(), getHeight());
        // or with:
        //((Graphics2D)g).setBackground(Color.red);
        //g.clearRect(0, 0, getWidth(), getHeight());
        g.setColor(Color.GREEN);
        dt = 1;
        x = (getSize().width - diametre)/2;
        if (!firstjump) {
            vy += vy0 + gravite*dt;
            vy *= 1 - frottement;
            y +=(y0 + vy*dt)/5.0f;
        else {
            vy -= vy0 + gravite*dt;
            vy *= 1 - frottement;
            y -=(y0 + vy*dt)/500.0f;
            firstjump = false;
        g.fillOval((int)x,(int)y,(int)diametre,(int)diametre);
        if (y >= getSize().height - diametre && vy >= 0) {
            vy = -vy;
            firstjump = true;
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics;
import javax.swing.*;
public class HJ2 {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Hello, Java!");
        HC hello = new HC("Hello Java!");
        frame.getContentPane().add(hello);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(300,300));
        frame.setVisible(true);
* using JComponent here is tricky because it is non-opaque
class HC extends JComponent implements MouseMotionListener {
    String theMessage;
    int messageX = 100, messageY = 100;
    public HC(String message) {
        theMessage = message;
        setOpaque(true);
        addMouseMotionListener(this);
    protected void paintComponent(Graphics g) {
        // JComponent is non-opaque
        // so it doesn't do anything with this
        //super.paintComponent(g);
        // now we're left to our own devices
        // see what happens without these next 2 lines
        g.setColor(getBackground());
        g.fillRect(0, 0, getWidth(), getHeight());
        g.setColor(Color.black);
        g.drawString(theMessage, messageX, messageY);
    public void mouseDragged(MouseEvent arg0) {
        messageX = arg0.getX();
        messageY = arg0.getY();
        repaint();
    public void mouseMoved(MouseEvent arg0) { }
}

Similar Messages

  • Splitting a Flattened Image into Layers so I can use the Paint Bucket to change colors

    I have what I think is a flattened image that is part of a Website template. (I'm assuming the image is flattened, because when I use the paint bucket to change the color, it colors the whole thing; and when I use the magic wand, the whole image is selected). I need to be able to use the paint bucket to change the colors. What do I have to do to make the image work that way? The image is made to look like you're looking left to right at four file folders. The folder labels are a different color. Is there some way to separate the folders (now in green), the folder labels (now in yellow), and the white background from each other, so I can apply the paint bucket to different layers later? I've worked on this for hours now, and can't seem to find the answer. I'll have to change the colors in the image at least 10 different times, so I was hoping I wouldn't have to resort to using the brush or pencil tools.

    Darlene,
    Another way is to use the Replace Color Tool. The Hue/Saturation method is probably easier, but I thought I'd mention Replace Color for your information.
    http://www.pixentral.com/show.php?picture=18IBCKnJchzoxfLEaw7Bu93j9W5jS
    In my example I changed the 3rd label in your picture to red.
    1. Roughly select the label using the Lasso tools.
    2. Enchance>Adjust Color>Replace Color.
    3. Click on the label in the picture; it will appear in the box as white on black background. In general you would move the fuzziness slider until just the portion you wish to change appears white. In this case since the yellow is uniform with sharp border the fuzziness slider had minimal additional effect, but I did move it all the way right to capture the fringe pixels.
    4. Play with the 3 Transform sliders to get the desired result.
    In this next example I changed the top of the lighthouse from red to green (why I would want to do that, I don't know!).
    http://www.pixentral.com/show.php?picture=1XhqCAvgc0zVWReJDkUB2OLDQChSy
    Note that in this case I didn't have to move the fuzziness all the way right.

  • Hi when do we use 'super'?

    hi im just reading a text again again but its a bit hard to understand
    when do we have to use super reference?? can someone plz explain me
    as easy as possible?? so thai i can undertand... and btw, what is polymorphism???
    can anyone explain me plz ,
    thanks in advance

    Hiya!
    You'll find pretty good answers to both of your questions in Bruce Eckel's "Thinking in Java" which is available as a free download.
    As to the use of the 'super' keyword: Sometimes you change the behaviour of an object by subclassing it's class (inheritance) and overwriting the methods that don't suit your particular needs. A pretty good example for this is the javax.swing.JComponent's 'paintComponent(Graphics g)' method.
    In this case you'll want to start the method's code with a call to super.paintComponent(g) to make sure your JComponent is set-up and painted properly before you start adding your own code to change the object's behaviour (fill or draw a rectangle, display an image ...).
    Polymorphism, on the other hand, helps you to write code that is easier to maintain (or to understand, in the first place ;-)) but needs a certain amount of understanding of class design and object-oriented techniques in general.
    If you are new to Java let's say to know when to use the 'super' keyword will make your programming-life easier. Polymorphic techniques won't (at least not yet). But, as I stated earlier, you'll find better explanations in "Thinking in Java" which is probably one of the best introductory Java books ever-written.
    Regards,
    Steffen

  • I have Photoshop CS6 Extended Students and Teachers Edition.  When I go into the Filter/Oil paint and try to use Oil paint a notice comes up "This feature requires graphics processor acceleration.  Please check Performance Preferences and verify that "Use

    I have Photoshop CS6 Extended Students and Teachers Edition.  when I go into the Filter/Oil paint and try to use Oil Paint a notice comes up "This feature requires graphics processor acceleration.  Please Check Performance Preferences and verify that "Use Graphics Processor" is enabled.  When I go into Performance Preferences I get a notice "No GPU available with Photoshop Standard.  Is there any way I can add this feature to my Photoshop either by purchasing an addition or downloading something?

    Does you display adapter have a supported  GPU with at least 512MB of Vram? And do you have the latest device drivers install with Open GL support.  Use CS6 menu Help>System Info... use its copy button and paste the information in here.

  • I just put a solid state hard drive in my mac book pro and used super duper to copy the hard drive and move the data over to thew new ssd, but most of my music isn't in iTunes when I turned it on? How do I get my music to show up in my new drive?

    I just put a solid state hard drive in my mac book pro and used super duper to copy the hard drive and move the data over to thew new ssd, but most of my music isn't in iTunes when I turned it on? How do I get my music to show up in my new drive?

    Many thanks lllaass,
    The Touch Copy third party software for PC's is the way to go it seems and although the demo is free, if you have over 100 songs then it costs £15 to buy the software which seems not a lot to pay for peace of mind. and restoring your iTunes library back to how it was.
    Cheers
    http://www.wideanglesoftware.com/touchcopy/index.php?gclid=CODH8dK46bsCFUbKtAod8 VcAQg

  • Why do we use super when there is no superclass?

    Hello,
    I have a question about the word "super " and the constructor. I have read about super and the constructor but there is somethong that I do not understand.
    In the example that I am studying there is a constructor calles " public MultiListener()" and there you can see " super" to use a constructor from a superclass. But there is no superclass. Why does super mean here?
    import javax.swing.*;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import java.awt.Dimension;
    import java.awt.Color;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class MultiListener extends JPanel
                               implements ActionListener {
        JTextArea topTextArea;
        JTextArea bottomTextArea;
        JButton button1, button2;
        final static String newline = "\n";
        public MultiListener() {
            super(new GridBagLayout());
            GridBagLayout gridbag = (GridBagLayout)getLayout();
            GridBagConstraints c = new GridBagConstraints();
            JLabel l = null;
            c.fill = GridBagConstraints.BOTH;
            c.gridwidth = GridBagConstraints.REMAINDER;
            l = new JLabel("What MultiListener hears:");
            gridbag.setConstraints(l, c);
            add(l);
            c.weighty = 1.0;
            topTextArea = new JTextArea();
            topTextArea.setEditable(false);
            JScrollPane topScrollPane = new JScrollPane(topTextArea);
            Dimension preferredSize = new Dimension(200, 75);
            topScrollPane.setPreferredSize(preferredSize);
            gridbag.setConstraints(topScrollPane, c);
            add(topScrollPane);
            c.weightx = 0.0;
            c.weighty = 0.0;
            l = new JLabel("What Eavesdropper hears:");
            gridbag.setConstraints(l, c);
            add(l);
            c.weighty = 1.0;
            bottomTextArea = new JTextArea();
            bottomTextArea.setEditable(false);
            JScrollPane bottomScrollPane = new JScrollPane(bottomTextArea);
            bottomScrollPane.setPreferredSize(preferredSize);
            gridbag.setConstraints(bottomScrollPane, c);
            add(bottomScrollPane);
            c.weightx = 1.0;
            c.weighty = 0.0;
            c.gridwidth = 1;
            c.insets = new Insets(10, 10, 0, 10);
            button1 = new JButton("Blah blah blah");
            gridbag.setConstraints(button1, c);
            add(button1);
            c.gridwidth = GridBagConstraints.REMAINDER;
            button2 = new JButton("You don't say!");
            gridbag.setConstraints(button2, c);
            add(button2);
            button1.addActionListener(this);
            button2.addActionListener(this);
            button2.addActionListener(new Eavesdropper(bottomTextArea));
            setPreferredSize(new Dimension(450, 450));
            setBorder(BorderFactory.createCompoundBorder(
                                    BorderFactory.createMatteBorder(
                                                    1,1,2,2,Color.black),
                                    BorderFactory.createEmptyBorder(5,5,5,5)));
        public void actionPerformed(ActionEvent e) {
            topTextArea.append(e.getActionCommand() + newline);
            topTextArea.setCaretPosition(topTextArea.getDocument().getLength());
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("MultiListener");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new MultiListener();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    OP wrote:
    >
    Isn't that simplier to use the constructor instead of using "super"? I mean using the constructor jpanel () ?
    >
    You can't call the super class constructor directly if you are trying to construct the sub-class. When you call it directly it will construct an instance of the super class but that instance will NOT be an integral part of the 'MultiListener' sub class you are trying to create.
    So since 'MultiListener' extends JPanel if you call the JPanel constructor directly (not using super) your code constructing a new instance of JPanel but that instance will not be an ancestor of your class that extends JPanel. In fact that constructor call will not execute until AFTER the default call to 'super' that will be made without you even knowing it.
    A 'super' call is ALWAYS made to the super class even if your code doesn't have an explicit call. If your code did not include the line:
    super(new GridBagLayout()); Java would automatically call the public default super class constructor just as if you had written:
    super();If the sub class cannot access a constructor in the super class (e.g. the super class constructor is 'private') your code won't compile.

  • Photoshop CS6 Extended crashing when using Oil Paint filter

    I replaced a standard hard drive with a new SSD drive and did a fresh install of Windows 7 and all of my programs.  I made sure all Win 7 updates, program updates and drivers are current.  The good news is Photoshop CS6 Extended loads much faster.  The bad news is now Photoshop crashes when I attempt to use the Oil Paint filter. The only hardware change is the new SSD, I haven't changed any video devices and I never had any issues running the Oil Paint filter before I swapped out hard drives and did the software reinstallations. I've tried the OpenGL Drawing Mode in basic, normal and advanced, and still get crashes when attempting to use oil paint.  Any ideas on how to fix this?
    System info:
    Adobe Photoshop Version: 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00) x64
    Operating System: Windows 7 64-bit
    Version: 6.1 Service Pack 1
    System architecture: Intel CPU Family:6, Model:10, Stepping:7 with MMX, SSE Integer, SSE FP, SSE2, SSE3, SSE4.1, SSE4.2, HyperThreading
    Physical processor count: 4
    Logical processor count: 8
    Processor speed: 3502 MHz
    Built-in memory: 16281 MB
    Free memory: 11464 MB
    Memory available to Photoshop: 14666 MB
    Memory used by Photoshop: 65 %
    Image tile size: 128K
    Image cache levels: 4
    OpenGL Drawing: Enabled.
    OpenGL Drawing Mode: Basic
    OpenGL Allow Normal Mode: True.
    OpenGL Allow Advanced Mode: True.
    OpenGL Allow Old GPUs: Not Detected.
    Video Card Vendor: NVIDIA Corporation
    Video Card Renderer: GeForce GTX 260/PCIe/SSE2
    Display: 1
    Display Bounds:=  top: 0, left: 0, bottom: 1200, right: 1920
    Video Card Number: 2
    Video Card: Intel(R) HD Graphics 3000
    OpenCL Unavailable
    Driver Version: 9.17.10.2932
    Driver Date: 20121212000000.000000-000
    Video Card Driver: igdumd64.dll,igd10umd64.dll,igd10umd64.dll,igdumd32,igd10umd32,igd10umd32
    Video Mode:
    Video Card Caption: Intel(R) HD Graphics 3000
    Video Card Memory: 896 MB
    Video Rect Texture Size: 8192
    Video Card Number: 1
    Video Card: NVIDIA GeForce GTX 260
    OpenCL Unavailable
    Driver Version: 8.17.13.142
    Driver Date: 20120515000000.000000-000
    Video Card Driver: nvd3dumx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvd3dum,nvwgf2um,nvwgf2um
    Video Mode: 1920 x 1200 x 4294967296 colors
    Video Card Caption: NVIDIA GeForce GTX 260
    Video Card Memory: 896 MB
    Video Rect Texture Size: 8192
    Serial number: 92628903515484833330
    Application folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\
    Temporary file path: C:\Users\Dave\AppData\Local\Temp\
    Photoshop scratch has async I/O enabled
    Scratch volume(s):
      Z:\, 931.5G, 591.4G free
      W:\, 1.82T, 1.79T free
      H:\, 698.5G, 493.9G free
    Required Plug-ins folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Required\
    Primary Plug-ins folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Plug-ins\
    Additional Plug-ins folder: not set
    Installed components:
       A3DLIBS.dll   A3DLIB Dynamic Link Library   9.2.0.112  
       ACE.dll   ACE 2012/01/18-15:07:40   66.492997   66.492997
       adbeape.dll   Adobe APE 2012/01/25-10:04:55   66.1025012   66.1025012
       AdobeLinguistic.dll   Adobe Linguisitc Library   6.0.0  
       AdobeOwl.dll   Adobe Owl 2012/02/09-16:00:02   4.0.93   66.496052
       AdobePDFL.dll   PDFL 2011/12/12-16:12:37   66.419471   66.419471
       AdobePIP.dll   Adobe Product Improvement Program   6.0.0.1654  
       AdobeXMP.dll   Adobe XMP Core 2012/02/06-14:56:27   66.145661   66.145661
       AdobeXMPFiles.dll   Adobe XMP Files 2012/02/06-14:56:27   66.145661   66.145661
       AdobeXMPScript.dll   Adobe XMP Script 2012/02/06-14:56:27   66.145661   66.145661
       adobe_caps.dll   Adobe CAPS   6,0,29,0  
       AGM.dll   AGM 2012/01/18-15:07:40   66.492997   66.492997
       ahclient.dll    AdobeHelp Dynamic Link Library   1,7,0,56  
       aif_core.dll   AIF   3.0   62.490293
       aif_ocl.dll   AIF   3.0   62.490293
       aif_ogl.dll   AIF   3.0   62.490293
       amtlib.dll   AMTLib (64 Bit)   6.0.0.75 (BuildVersion: 6.0; BuildDate: Mon Jan 16 2012 18:00:00)   1.000000
       ARE.dll   ARE 2012/01/18-15:07:40   66.492997   66.492997
       AXE8SharedExpat.dll   AXE8SharedExpat 2011/12/16-15:10:49   66.26830   66.26830
       AXEDOMCore.dll   AXEDOMCore 2011/12/16-15:10:49   66.26830   66.26830
       Bib.dll   BIB 2012/01/18-15:07:40   66.492997   66.492997
       BIBUtils.dll   BIBUtils 2012/01/18-15:07:40   66.492997   66.492997
       boost_date_time.dll   DVA Product   6.0.0  
       boost_signals.dll   DVA Product   6.0.0  
       boost_system.dll   DVA Product   6.0.0  
       boost_threads.dll   DVA Product   6.0.0  
       cg.dll   NVIDIA Cg Runtime   3.0.00007  
       cgGL.dll   NVIDIA Cg Runtime   3.0.00007  
       CIT.dll   Adobe CIT   2.0.5.19287   2.0.5.19287
       CoolType.dll   CoolType 2012/01/18-15:07:40   66.492997   66.492997
       data_flow.dll   AIF   3.0   62.490293
       dvaaudiodevice.dll   DVA Product   6.0.0  
       dvacore.dll   DVA Product   6.0.0  
       dvamarshal.dll   DVA Product   6.0.0  
       dvamediatypes.dll   DVA Product   6.0.0  
       dvaplayer.dll   DVA Product   6.0.0  
       dvatransport.dll   DVA Product   6.0.0  
       dvaunittesting.dll   DVA Product   6.0.0  
       dynamiclink.dll   DVA Product   6.0.0  
       ExtendScript.dll   ExtendScript 2011/12/14-15:08:46   66.490082   66.490082
       FileInfo.dll   Adobe XMP FileInfo 2012/01/17-15:11:19   66.145433   66.145433
       filter_graph.dll   AIF   3.0   62.490293
       hydra_filters.dll   AIF   3.0   62.490293
       icucnv40.dll   International Components for Unicode 2011/11/15-16:30:22    Build gtlib_3.0.16615  
       icudt40.dll   International Components for Unicode 2011/11/15-16:30:22    Build gtlib_3.0.16615  
       image_compiler.dll   AIF   3.0   62.490293
       image_flow.dll   AIF   3.0   62.490293
       image_runtime.dll   AIF   3.0   62.490293
       JP2KLib.dll   JP2KLib 2011/12/12-16:12:37   66.236923   66.236923
       libifcoremd.dll   Intel(r) Visual Fortran Compiler   10.0 (Update A)  
       libmmd.dll   Intel(r) C Compiler, Intel(r) C++ Compiler, Intel(r) Fortran Compiler   10.0  
       LogSession.dll   LogSession   2.1.2.1640  
       mediacoreif.dll   DVA Product   6.0.0  
       MPS.dll   MPS 2012/02/03-10:33:13   66.495174   66.495174
       msvcm80.dll   Microsoft® Visual Studio® 2005   8.00.50727.6195  
       msvcm90.dll   Microsoft® Visual Studio® 2008   9.00.30729.1  
       msvcp100.dll   Microsoft® Visual Studio® 2010   10.00.40219.1  
       msvcp80.dll   Microsoft® Visual Studio® 2005   8.00.50727.6195  
       msvcp90.dll   Microsoft® Visual Studio® 2008   9.00.30729.1  
       msvcr100.dll   Microsoft® Visual Studio® 2010   10.00.40219.1  
       msvcr80.dll   Microsoft® Visual Studio® 2005   8.00.50727.6195  
       msvcr90.dll   Microsoft® Visual Studio® 2008   9.00.30729.1  
       ONCore7.dll   ONCore   7.0.0.0  
       ONCoreFoundation7.dll   ONCoreFoundation7   7, 0, 0, 0  
       ONDocument7.dll   ONDocument   7.0.0.0  
       ONProxySupport7.dll   ONProxySupport   1.0.0.0  
       pdfsettings.dll   Adobe PDFSettings   1.04  
       Photoshop.dll   Adobe Photoshop CS6   CS6  
       Plugin.dll   Adobe Photoshop CS6   CS6  
       PlugPlug.dll   Adobe(R) CSXS PlugPlug Standard Dll (64 bit)   3.0.0.383  
       PSArt.dll   Adobe Photoshop CS6   CS6  
       PSViews.dll   Adobe Photoshop CS6   CS6  
       SCCore.dll   ScCore 2011/12/14-15:08:46   66.490082   66.490082
       ScriptUIFlex.dll   ScriptUIFlex 2011/12/14-15:08:46   66.490082   66.490082
       tbb.dll   Intel(R) Threading Building Blocks for Windows   3, 0, 2010, 0406  
       tbbmalloc.dll   Intel(R) Threading Building Blocks for Windows   3, 0, 2010, 0406  
       TfFontMgr.dll   FontMgr   9.3.0.113  
       TfKernel.dll   Kernel   9.3.0.113  
       TFKGEOM.dll   Kernel Geom   9.3.0.113  
       TFUGEOM.dll   Adobe, UGeom©   9.3.0.113  
       updaternotifications.dll   Adobe Updater Notifications Library   6.0.0.24 (BuildVersion: 1.0; BuildDate: BUILDDATETIME)   6.0.0.24
       WRServices.dll   WRServices Friday January 27 2012 13:22:12   Build 0.17112   0.17112
       wu3d.dll   U3D Writer   9.3.0.113  
       Required plug-ins:
       3D Studio 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Accented Edges 13.0
       Adaptive Wide Angle 13.0
       ADM 3.11x01
       Angled Strokes 13.0
       Average 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Bas Relief 13.0
       BMP 13.0
       Chalk & Charcoal 13.0
       Charcoal 13.0
       Chrome 13.0
       Cineon 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Clouds 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Collada 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Color Halftone 13.0
       Colored Pencil 13.0
       CompuServe GIF 13.0
       Conté Crayon 13.0
       Craquelure 13.0
       Crop and Straighten Photos 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Crop and Straighten Photos Filter 13.0
       Crosshatch 13.0
       Crystallize 13.0
       Cutout 13.0
       Dark Strokes 13.0
       De-Interlace 13.0
       Dicom 13.0
       Difference Clouds 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Diffuse Glow 13.0
       Displace 13.0
       Dry Brush 13.0
       Eazel Acquire 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Embed Watermark 4.0
       Entropy 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Extrude 13.0
       FastCore Routines 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Fibers 13.0
       Film Grain 13.0
       Filter Gallery 13.0
       Flash 3D 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Fresco 13.0
       Glass 13.0
       Glowing Edges 13.0
       Google Earth 4 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Grain 13.0
       Graphic Pen 13.0
       Halftone Pattern 13.0
       HDRMergeUI 13.0
       IFF Format 13.0
       Ink Outlines 13.0
       JPEG 2000 13.0
       Kurtosis 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Lens Blur 13.0
       Lens Correction 13.0
       Lens Flare 13.0
       Liquify 13.0
       Matlab Operation 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Maximum 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Mean 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Measurement Core 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Median 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Mezzotint 13.0
       Minimum 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       MMXCore Routines 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Mosaic Tiles 13.0
       Multiprocessor Support 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Neon Glow 13.0
       Note Paper 13.0
       NTSC Colors 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Ocean Ripple 13.0
       Oil Paint 13.0
       OpenEXR 13.0
       Paint Daubs 13.0
       Palette Knife 13.0
       Patchwork 13.0
       Paths to Illustrator 13.0
       PCX 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Photocopy 13.0
       Photoshop 3D Engine 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Picture Package Filter 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Pinch 13.0
       Pixar 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Plaster 13.0
       Plastic Wrap 13.0
       PNG 13.0
       Pointillize 13.0
       Polar Coordinates 13.0
       Portable Bit Map 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Poster Edges 13.0
       Radial Blur 13.0
       Radiance 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Range 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Read Watermark 4.0
       Reticulation 13.0
       Ripple 13.0
       Rough Pastels 13.0
       Save for Web 13.0
       ScriptingSupport 13.0
       Shear 13.0
       Skewness 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Smart Blur 13.0
       Smudge Stick 13.0
       Solarize 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Spatter 13.0
       Spherize 13.0
       Sponge 13.0
       Sprayed Strokes 13.0
       Stained Glass 13.0
       Stamp 13.0
       Standard Deviation 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Sumi-e 13.0
       Summation 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Targa 13.0
       Texturizer 13.0
       Tiles 13.0
       Torn Edges 13.0
       Twirl 13.0
       U3D 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Underpainting 13.0
       Vanishing Point 13.0
       Variance 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Variations 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Viveza 2 2.1.0.22656
       Water Paper 13.0
       Watercolor 13.0
       Wave 13.0
       Wavefront|OBJ 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       WIA Support 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       Wind 13.0
       Wireless Bitmap 13.0 (13.0 20120315.r.428 2012/03/15:21:00:00)
       ZigZag 13.0
    Optional and third party plug-ins:
       Alien Skin Autolayer 3 3.0.0 20463 2012-03-23 12:39
       BackgroundFilter 2.2.0.22656
       Bokeh 2.0.1
       Camera Raw 7.4
       Color Efex Pro 4 4,20
       Color Efex Pro 4 4,20
       Dfine 2 2.2.0.22656
       FineStructuresFilter 2.2.0.22656
       FocalPoint 2.1 2.1.1
       FocalPoint 2.1 Filter 2.1.1
       FocalPoint 2.1 Smart Filter 2.1.1
       HDR Efex Pro 2 2,10
       HotPixelsFilter 2.2.0.22656
       iCorrect EditLab Pro 6.0 5.5.0r1
       Lucis Pro 6.0 NO VERSION
       Lucis Pro 6.0 NO VERSION
       Merge to HDR Efex Pro 2 2,10
       Nik Collection Selective Tool 2.1.5.22621
       Perfect BW 1 1.0.1
       Perfect BW 1 Filter 1.0.1
       Perfect BW 1 Smart Filter 1.0.1
       Perfect Effects 4 4.0.2
       Perfect Effects 4 Filter 4.0.2
       Perfect Effects 4 Smart Filter 4.0.2
       Perfect Mask 5.2 5.2.1
       Perfect Mask 5.2 Filter 5.2.1
       Perfect Mask 5.2 Smart Filter 5.2.1
       Perfect Portrait 2 2.0.1
       Perfect Portrait 2 Filter 2.0.1
       Perfect Portrait 2 Smart Filter 2.0.1
       Perfect Resize 7.5 7.5.1
       Perfect Resize 7.5 Engine Automation 7.5.1
       Perfect Resize 7.5 Engine Filter 7.5.1
       Perfect Resize 7.5 Filter 7.5.1
       Perfect Resize Format 7.5.1
       Portrait Professional 1, 5, 1, 0
       ShadowsFilter 2.2.0.22656
       Sharpener Pro 3: (1) RAW Presharpener 3.1.0.22665
       Sharpener Pro 3: (2) Output Sharpener 3.1.0.22665
       Silver Efex Pro 2 2,100
       Silver Efex Pro 2 2,100
       SkinFilter 2.2.0.22656
       SkyFilter 2.2.0.22656
       StrongNoiseFilter 2.2.0.22656
       Topaz BW Effects 2 10.0
       Topaz Detail 3 10.0
       Topaz photoFXlab 10.0
       Topaz ReMask 3 10.0
       Topaz Simplify 4 10.0
       TopazRemaskAutomate NO VERSION
    Plug-ins that failed to load: NONE
    Flash:
       onOne
       Mini Bridge
       Kuler
    Installed TWAIN devices: NONE

    Crash info helps, but it would seem that you just see the old "intel chips don't cut it" problem. Turn of the intel graphics unit in the driver or even in the BIOS/ EFI. Perhaps updating your storage/ SATA driver when installing the SSD simply has re-enabled it.
    Mylenium

  • When to use Paint over Photoshop?

    Im newer to Photoshop so its easier for me to throw my images into Paint to resize and crop them.
    I was curious if other community members ever use Microsoft Paint for tasks and if so what?
    Also, should I be doing this or would it benefit me to use Photoshop for resizing and croping images?  I plan on using Photoshop but I rarely have it open since I mostly use the development programs within CS5 and it takes magnitudes longer to open Photoshop than Paint.  But even with Fireworks running and the image attended for Fireworks I still through my image into paint because it seems faster.  Am I dumb? Should I give up the paint? Some hot keys for this task probably would be better ahhhh... any insight?
    Thanks,

    I do not think that I have used MS Paint, since about Windows 2.0. I did not even realize that it was still around.
    I just use PS for everything, with the exception of JPEG's, with bum header info, that PS will not open. Then, I just use either ThumbsPlus, or IrfanView, to Open, then Save with proper header info.
    I do not have any data on the Scaling (Resizing) algorithms in Paint, but would think that those in PS would be better. They do offer you a good range of choices, but maybe Paint has similar? Same when Cropping. What part of those operations do you find easier in Paint?
    Though I use PS a lot, and have for a very long time, image editing software is but a tool in a process. Using the right tool, or the one that the artist is most comfortable with, is the trick. I use Painter (now Corel) for a lot of treatments, but almost always finish up in PS. Over the decades, PS has become closer to Painter, than in days past. Still, there are treatments that I want to apply in Painter, and part of those choices will be my personnal comfort level. I might have something very similar in my newer PS, but if I know every step by heart in Painter, my comfort level rises.
    Use what you like for different operations, but I would do a visual check with an operation, like Scale/Resize. Do the same exact operation in each program, using the same base Image, and the same exact settings. Compare the results of the two programs critically.
    Good luck,
    Hunt

  • "cannot resolve symbol" error when using super.paintComponent

    I am trying to override the paintComponent method in a class extending a JFrame, but when I call super.paintComponent(g) from inside the overridden method I get the error
    QubicGUI.java:63: cannot resolve symbol
    symbol : method paintComponent (java.awt.Graphics)
    location: class javax.swing.JFrame
    super.paintComponent(g);
    ^
    1 error
    I can't see where I am deviating from examples I know work. It is a very small program, so I have included it here:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import java.net.URL;
    class QubicGUI extends JFrame
         private int width;
         private int height;
         private Image background;
         public int getWidth()
         {     return width;     }
         public int getHeight()
         {     return height;     }
         public boolean isOpaque()
    return true;
         public QubicGUI()
              super("Qubic"); //set title
              // The following gets the default screen device for the purpose of finding the
              // current settings of height and width of the screen
         GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice device = environment.getDefaultScreenDevice();
              DisplayMode display = device.getDisplayMode();
              width = display.getWidth();
              height = display.getHeight();
              // Here we set the window to cover the entire screen with a black background, and
              // remove the decorations. (This includes the title bar and close, minimize and
              // maximize buttons and the border)
              setUndecorated(false);
              setVisible(true);
              setSize(width,height);
              setResizable(false);
              setBackground(Color.black);
              // Initializes the background Image
              Image background = Toolkit.getDefaultToolkit().getImage("background.gif");
              // This is included for debugging with a decorated window.
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } // end constructor
              public void paintComponent(Graphics g)
                   super.paintComponent(g);     
              } // end paintComponenet
    } // end QubicGUI

    Two things I want to know:
    1. I was trying to access a variable as JLabel
    myLabel; defined in the constructor of a class from
    the constructor of another class. I got this error
    message - "Cannot access non-static variable from a
    static context". Why(When both are non-static am I
    getting the message as static context)?Post some code. It's hard to pinpoint a syntax error like that without seeing the code.
    Also, there may be cleaner ways of doing what you want without having classes sharing labels.
    2. I am using a map to set the attributes of a font.
    One of the key-value pair of the map is
    TextAttributesHashMap.put(TextAttribute.FOREGROUND,Colo
    .BLUE);
    But when I using the statement g.drawString("First
    line of the address", 40, 200); the text being
    displayed is in black and not blue. Why?You need to use the drawString that takes an AttributedCharacterIterator:
    import java.awt.*;
    import java.awt.font.*;
    import java.text.*;
    import javax.swing.*;
    public class Example  extends JPanel {
        public static void main(String[] args)  {
            JFrame f = new JFrame("Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container cp = f.getContentPane();
            cp.add(new Example());
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            String text = "Every good boy does fine always";
            AttributedString as = new AttributedString(text);
            as.addAttribute(TextAttribute.FAMILY, "Lucida Bright");
            as.addAttribute(TextAttribute.SIZE, new Float(16));
            as.addAttribute(TextAttribute.FOREGROUND, Color.BLUE, 0, 5);
            as.addAttribute(TextAttribute.FOREGROUND, Color.GREEN, 6, 10);
            as.addAttribute(TextAttribute.FOREGROUND, Color.RED, 11, 14);
            as.addAttribute(TextAttribute.FOREGROUND, Color.YELLOW, 15, 19);
            as.addAttribute(TextAttribute.FOREGROUND, Color.MAGENTA, 20, 24);
            as.addAttribute(TextAttribute.FOREGROUND, Color.CYAN, 25, 31);
            g.drawString(as.getIterator(), 10, 20);

  • Adding a JButton when there's a paint method

    I'm creating a game application, sort of like a maze, and I want to add buttons to the levelOne panel to be able to move around the maze. When I add the buttons to the panel they don't appear, I assume the paint method is the reason for this. here's my code, I have 3 files, ill post the user_interface, and the levels class, where the level is created and where i tried to add the button. I tried putting the buttons in a JOptionPane, but then my JMenu wouldn't work at the same time the OptionPane was opened. If anyone knows a way around this instead, please let me know. I also tried using a separate class with a paintComponent method in it, and then adding the button (saw on a forum, not sure if it was this one), but that didn't work either. Also, if there is a way just to simply have the user press the directional keys on the keyboard and have the program perform a certain function when certain keys are pressed, I'd like to know, as that would solve my whole problem. Thanks.
    //Libraries
    import java.awt.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    public class User_Interface extends JFrame
    static Levels l = new Levels ();
    static Delay d = new Delay ();
    private Container contentPane = getContentPane ();
    private JPanel main, levelOne;
    private String level;
    private CardLayout cc = new CardLayout ();
    private GridBagConstraints gbc = new GridBagConstraints ();
    private JPanel c = new JPanel ();
    private String label = "MainMenu";
    public User_Interface ()
    //Generates the User-Interface
    super ("Trapped");
    main = new JPanel ();
    GridBagLayout gbl = new GridBagLayout ();
    main.setLayout (gbl);
    c.setLayout (cc);
    // set_gbc (gbc, 2, 2, 5, 5, GridBagConstraints.NONE);
    c.add (main, "Main Page");
    contentPane.add (c, BorderLayout.CENTER);
    cc.show (c, "Main Page");
    levelOne = new JPanel ();
    levelOne.setLayout (new GridBagLayout ());
    levelOne.setBackground (Color.black);
    c.add (levelOne, "LevelOne");
    JMenuBar menu = new JMenuBar ();
    JMenu file = new JMenu ("File");
    JMenu help = new JMenu ("Help");
    JMenuItem about = new JMenuItem ("About");
    JMenuItem mainmenu = new JMenuItem ("Main Menu");
    mainmenu.addActionListener (
    new ActionListener ()
    public void actionPerformed (ActionEvent event)
    cc.show (c, "Main Page");
    label = "MainMenu";
    JMenuItem newGame = new JMenuItem ("New Game");
    newGame.addActionListener (
    new ActionListener ()
    public void actionPerformed (ActionEvent event)
    l.xCord = 2;
    l.yCord = 2;
    l.xLoc = 140;
    l.yLoc = 140;
    JPanel entrance = new JPanel ();
    entrance.setLayout (new FlowLayout ());
    c.add (entrance, "Entrance");
    label = "Entrance";
    level = "ONE";
    cc.show (c, "Entrance");
    JMenuItem loadgame = new JMenuItem ("Load Game");
    JMenuItem savegame = new JMenuItem ("Save Game");
    JMenuItem exit = new JMenuItem ("Exit");
    exit.addActionListener (
    new ActionListener ()
    public void actionPerformed (ActionEvent event)
    JFrame frame = new JFrame ();
    frame.setLocation (10, 10);
    JOptionPane.showMessageDialog (frame, "Come Back Soon!", "TRAPPED", JOptionPane.INFORMATION_MESSAGE);
    System.exit (0);
    file.add (about);
    file.add (mainmenu);
    file.add (newGame);
    file.add (loadgame);
    file.add (savegame);
    file.add (exit);
    menu.add (file);
    menu.add (help);
    setJMenuBar (menu);
    //Sets the size of the container (columns by rows)
    setSize (750, 550);
    //Sets the location of the container
    setLocation (10, 10);
    //Sets the background colour to a dark blue colour
    main.setBackground (Color.black);
    //Makes the container visible
    setVisible (true);
    public void paint (Graphics g)
    super.paint (g);
    g.setColor (Color.white);
    if (label == "MainMenu")
    for (int x = 0 ; x <= 50 ; ++x)
    g.setColor (Color.white);
    g.setFont (new Font ("Arial", Font.BOLD, x));
    g.drawString ("T R A P P E D", 100, 125);
    d.delay (10);
    if (x != 50)
    g.setColor (Color.black);
    g.drawString ("T R A P P E D", 100, 125);
    if (label == "Entrance")
    l.Entrance ("ONE", g);
    label = "LevelOne";
    if (label == "LevelOne")
    l.LevelOne (g, levelOne, gbc);
    label = "";
    public static void main (String[] args)
    // calls the program
    User_Interface application = new User_Interface ();
    application.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    } //End of Main Method
    //Libraries
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Levels extends Objects
    private JFrame frame = new JFrame ();
    //Sets location, size, and visiblity to the frame where the JOptionPane
    //will be placed
    frame.setLocation (600, 600);
    frame.setSize (1, 1);
    frame.setVisible (false);
    public int xCord = 2;
    public int yCord = 2;
    public void LevelOne (Graphics g, JPanel one, GridBagConstraints gbc)
    ***Trying to add the button, doesn't appear. Tried adding to the container, and any JPanel i had created***
    JButton button1 = new JButton ("TEST");
    one.add (button1);
    g.setColor (Color.white);
    g.fillRect (500, 100, 200, 300);
    g.setColor (Color.black);
    g.drawRect (500, 100, 200, 300);
    g.setFont (new Font ("Verdana", Font.BOLD, 25));
    g.setColor (Color.black);
    g.drawString ("LEVEL ONE", 525, 80);
    //ROW ONE
    counter = -80;
    counter2 = 200;
    for (int a = 1 ; a <= 7 ; ++a)
    if (xCord < a && yCord == 0)
    g.setColor (darkGray);
    g.fillRect (xLoc + counter, yLoc - 80, 40, 40);
    g.setColor (Color.black);
    g.drawRect (xLoc + counter, yLoc - 80, 40, 40);
    if (xCord > a - 1 && yCord == 0)
    g.setColor (darkGray);
    g.fillRect (xLoc + counter2, yLoc - 80, 40, 40);
    g.setColor (Color.black);
    g.drawRect (xLoc + counter2, yLoc - 80, 40, 40);
    counter += 40;
    counter2 += 40;
    *****Theres 9 more rows, just edited out to save space****
    int y = 100;
    int x = 100;
    for (int a = 0 ; a < 20 ; ++a)
    g.setColor (Color.white);
    g.fillRoundRect (x, y, 40, 40, 5, 5);
    g.setColor (Color.black);
    g.drawRoundRect (x, y, 40, 40, 5, 5);
    y += 40;
    if (a == 9)
    x += 320;
    y = 100;
    x = 140;
    y = 100;
    for (int a = 0 ; a < 14 ; ++a)
    g.setColor (Color.white);
    g.fillRoundRect (x, y, 40, 40, 5, 5);
    g.setColor (Color.black);
    g.drawRoundRect (x, y, 40, 40, 5, 5);
    x += 40;
    if (a == 6)
    x = 140;
    y += 360;
    g.setColor (Color.black);
    g.drawRect (100, 100, 360, 400);
    ImageIcon[] images = new ImageIcon [4];
    images [0] = new ImageIcon ("arrow_left.gif");
    images [1] = new ImageIcon ("arrow_up.gif");
    images [2] = new ImageIcon ("arrow_down.gif");
    images [3] = new ImageIcon ("arrow_right.gif");
    int direction = -1;
    *****This is where I tried to have the OptionPane show the directional buttons******
    //frame.setVisible (true);
    // direction = JOptionPane.showOptionDialog (frame, "Choose Your Path:", "Trapped", JOptionPane.YES_NO_CANCEL_OPTION,
    // JOptionPane.QUESTION_MESSAGE,
    // null,
    // images,
    // images [3]);
    // if (direction == 0)
    // if (xCord - 1 > 0)
    // xCord -= 1;
    // xLoc += 40;
    // if (direction == 1)
    // if (yCord - 1 > 0)
    // yCord -= 1;
    // yLoc += 40;
    // if (direction == 2)
    // if (yCord + 1 < 9)
    // yCord += 1;
    // yLoc -= 40;
    // if (direction == 3)
    // if (xCord + 1 < 13)
    // xCord += 1;
    // xLoc -= 40;
    //LevelOne (g, one, gbc);
    }

    i tried adding a keylistener, that didn't work too well, i had tried to add it to a button and a textarea which i added to the 'one' frame, it didn't show up, and it didn't work. How would i go about changing the paint method so that it doesn't contain any logic? That's the only way I could think of getting the program to move forward in the game. Thanks.
    //Libraries
    import java.awt.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    public class User_Interface extends JFrame
        static Levels l = new Levels ();
        static Delay d = new Delay ();
        private Container contentPane = getContentPane ();
        private JPanel main, levelOne;
        private String level;
        private CardLayout cc = new CardLayout ();
        private GridBagConstraints gbc = new GridBagConstraints ();
        private JPanel c = new JPanel ();
        private String label = "MainMenu";
        public User_Interface ()
            //Generates the User-Interface
            super ("Trapped");
            main = new JPanel ();
            GridBagLayout gbl = new GridBagLayout ();
            main.setLayout (gbl);
            c.setLayout (cc);
            // set_gbc (gbc, 2, 2, 5, 5, GridBagConstraints.NONE);
            c.add (main, "Main Page");
            contentPane.add (c, BorderLayout.CENTER);
            cc.show (c, "Main Page");
            levelOne = new JPanel ();
            levelOne.setLayout (new GridBagLayout ());
            levelOne.setBackground (Color.black);
            c.add (levelOne, "LevelOne");
            JMenuBar menu = new JMenuBar ();
            JMenu file = new JMenu ("File");
            JMenu help = new JMenu ("Help");
            JMenuItem about = new JMenuItem ("About");
            JMenuItem mainmenu = new JMenuItem ("Main Menu");
            mainmenu.addActionListener (
                    new ActionListener ()
                public void actionPerformed (ActionEvent event)
                    cc.show (c, "Main Page");
                    label = "MainMenu";
            JMenuItem newGame = new JMenuItem ("New Game");
            newGame.addActionListener (
                    new ActionListener ()
                public void actionPerformed (ActionEvent event)
                    l.xCord = 2;
                    l.yCord = 2;
                    l.xLoc = 140;
                    l.yLoc = 140;
                    JPanel entrance = new JPanel ();
                    entrance.setLayout (new FlowLayout ());
                    c.add (entrance, "Entrance");
                    label = "Entrance";
                    level = "ONE";
                    cc.show (c, "Entrance");
            JMenuItem loadgame = new JMenuItem ("Load Game");
            JMenuItem savegame = new JMenuItem ("Save Game");
            JMenuItem exit = new JMenuItem ("Exit");
            exit.addActionListener (
                    new ActionListener ()
                public void actionPerformed (ActionEvent event)
                    JFrame frame = new JFrame ();
                    frame.setLocation (10, 10);
                    JOptionPane.showMessageDialog (frame, "Come Back Soon!", "TRAPPED", JOptionPane.INFORMATION_MESSAGE);
                    System.exit (0);
            file.add (about);
            file.add (mainmenu);
            file.add (newGame);
            file.add (loadgame);
            file.add (savegame);
            file.add (exit);
            menu.add (file);
            menu.add (help);
            setJMenuBar (menu);
            //Sets the size of the container (columns by rows)
            setSize (750, 550);
            //Sets the location of the container
            setLocation (10, 10);
            //Sets the background colour to a dark blue colour
            main.setBackground (Color.black);
            //Makes the container visible
            setVisible (true);
        public void paint (Graphics g)
            super.paint (g);
            g.setColor (Color.white);
            if (label == "MainMenu")
                for (int x = 0 ; x <= 50 ; ++x)
                    g.setColor (Color.white);
                    g.setFont (new Font ("Arial", Font.BOLD, x));
                    g.drawString ("T    R    A    P    P    E    D", 100, 125);
                    d.delay (10);
                    if (x != 50)
                        g.setColor (Color.black);
                        g.drawString ("T    R    A    P    P    E    D", 100, 125);
            if (label == "Entrance")
                l.Entrance ("ONE", g);
                label = "LevelOne";
            if (label == "LevelOne")
                l.LevelOne (g, levelOne, gbc);
                label = "";
            //g.setColor (new Color
        public static void main (String[] args)
            // calls the program
            User_Interface application = new User_Interface ();
            application.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        } //End of Main Method
    //Libraries
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.ActionMap;
    import javax.swing.plaf.*;
    public class Levels extends Objects
        implements KeyListener
        //static final String newline = System.getProperty ("line.separator");
        JButton button;
        private JFrame frame = new JFrame ();
            //Sets location, size, and visiblity to the frame where the JOptionPane
            //will be placed
            frame.setLocation (600, 600);
            frame.setSize (1, 1);
            frame.setVisible (false);
        JButton button1;
        public int xCord = 2;
        public int yCord = 2;
        public void LevelOne (Graphics g, JPanel one, GridBagConstraints gbc)
        //    button = new JButton ("TEST");
        //    ButtonHandler handler = new ButtonHandler ();
         //   button.addActionListener (handler);
          //  one.add (button);
            g.setColor (Color.white);
            g.fillRect (500, 100, 200, 300);
            g.setColor (Color.black);
            g.drawRect (500, 100, 200, 300);
            g.setFont (new Font ("Verdana", Font.BOLD, 25));
            g.setColor (Color.black);
            g.drawString ("LEVEL ONE", 525, 80);
            //ROW ONE
            counter = -80;
            counter2 = 200;
            for (int a = 1 ; a <= 7 ; ++a)
                if (xCord < a && yCord == 0)
                    g.setColor (darkGray);
                    g.fillRect (xLoc + counter, yLoc - 80, 40, 40);
                    g.setColor (Color.black);
                    g.drawRect (xLoc + counter, yLoc - 80, 40, 40);
                if (xCord > a - 1 && yCord == 0)
                    g.setColor (darkGray);
                    g.fillRect (xLoc + counter2, yLoc - 80, 40, 40);
                    g.setColor (Color.black);
                    g.drawRect (xLoc + counter2, yLoc - 80, 40, 40);
                counter += 40;
                counter2 += 40;
            int y = 100;
            int x = 100;
            for (int a = 0 ; a < 20 ; ++a)
                g.setColor (Color.white);
                g.fillRoundRect (x, y, 40, 40, 5, 5);
                g.setColor (Color.black);
                g.drawRoundRect (x, y, 40, 40, 5, 5);
                y += 40;
                if (a == 9)
                    x += 320;
                    y = 100;
            x = 140;
            y = 100;
            for (int a = 0 ; a < 14 ; ++a)
                g.setColor (Color.white);
                g.fillRoundRect (x, y, 40, 40, 5, 5);
                g.setColor (Color.black);
                g.drawRoundRect (x, y, 40, 40, 5, 5);
                x += 40;
                if (a == 6)
                    x = 140;
                    y += 360;
            g.setColor (Color.black);
            g.drawRect (100, 100, 360, 400);
            ImageIcon[] images = new ImageIcon [4];
            images [0] = new ImageIcon ("arrow_left.gif");
            images [1] = new ImageIcon ("arrow_up.gif");
            images [2] = new ImageIcon ("arrow_down.gif");
            images [3] = new ImageIcon ("arrow_right.gif");
            int direction = -1;
            //frame.setVisible (true);
            // direction = JOptionPane.showOptionDialog (frame, "Choose Your //\Path:", "Trapped", JOptionPane.YES_NO_CANCEL_OPTION,
            //         JOptionPane.QUESTION_MESSAGE,
            //         null,
            //         images,
            //         images [3]);
            // if (direction == 0)
            //     if (xCord - 1 > 0)
            //         xCord -= 1;
            //         xLoc += 40;
            // if (direction == 1)
            //     if (yCord - 1 > 0)
            //         yCord -= 1;
            //         yLoc += 40;
            // if (direction == 2)
            //     if (yCord + 1 < 9)
            //         yCord += 1;
            //         yLoc -= 40;
            // if (direction == 3)
            //     if (xCord + 1 < 13)
            //         xCord += 1;
            //         xLoc -= 40;
            one.addKeyListener (this);
            // one.add (button1);
            if (xCord == 1)
                LevelOne (g, one, gbc);
        /** Handle the key typed event from the text field. */
        public void keyTyped (KeyEvent e)
        /** Handle the key pressed event from the text field. */
        public void keyPressed (KeyEvent e)
            if (e.getSource () == "Up")
                JOptionPane.showMessageDialog (null, "Hi", "Hi", 0, null);
        /** Handle the key released event from the text field. */
        public void keyReleased (KeyEvent e)
            // displayInfo (e, "KEY RELEASED: ");
    }

  • Super.paint() before or after?

    Hi,
    I am overriding paint, like so
    public void paint(Graphics g) {
          super.paint(g);
         Graphics2D g2d = (Graphics2D) g;
         g2d.drawImage(image, x, y, null);
    }I have a panel, which has smaller "floating" panles on top of it, and i am painting an image in the center. if a panel is dragged over top of the image, i want the image to not be visible.....the image should only be visible when nothing is on top of it. i realize this has to do with the order in which i paint...
    so should i draw the image, and then do super.paint(g) ? or do i need to do super.paint(g2d)?
    can u post the correct way of doing it, using the code given above.
    thanks

    protected void paintComponent(Graphics g) {
              if (myimage != null) {
                   g.drawImage(myimage, 10, 10, null);
              setOpaque(false);
                    g.setColor(getBackground());
              g.fillRect(0, 0, getWidth(), getHeight());
              g.setColor(getForeground());
              super.paintComponent(g);
         }now i have a background color i want...but the image disappeared....in what order should i do these things?
    thanks

  • How do I get Integer in JTable cell to be selected when edit using keyboard

    I have some cells in a JTable, when I double-click on the cell to edit it the current value (if any) is selected and is replaced by any value I enter, which is the behaviour I want. But when I use the keyboard to navigate to the cell and start editing, new values are added to the end of the current value which is not what I want.
    I have created my own IntegerCellEditor (see below) and added a focus event or the textfield used when editing to select all the current text but it has no effect, any ideas please ?
    public class IntegerCellEditor extends DefaultCellEditor
        public IntegerCellEditor( JTextField textfield )
            super( textfield );    
            //Ensure old value is always selected, when start editing
            ((JTextField)getComponent()).addFocusListener(new FocusAdapter()
                    public void focusGained(FocusEvent fe){
                        ((JTextField)getComponent()).selectAll();
            ((JTextField)getComponent()).setHorizontalAlignment(JTextField.RIGHT);
         * Return as Integer (because delegate converts values to Strings).
        public Object getCellEditorValue()
            return Integer.valueOf((String)delegate.getCellEditorValue());
    }

    But when I use the keyboard to navigate to the cell and start editing,
    new values are added to the end of the current value which is not what I want.How does the use know that typing will replace the text and not append? Usually if text is to be deleted, it is highlighted to give the user a visual cue.
    Here is a renderer that does this, in case your interested:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=752727

  • How can i make the radiobutton use screen painter?

    hey experts,
    i paint 3 radiobuttons in group1 use screen painter,
    but when i execute the screen,all of the radiobutton are black, it means radio1='x',radio2 = 'x',radio3 = 'x'.
    i only want radio1 = 'x',radio2 = ' ', radio3 = ' '.
    how to do that?
    and i can't do it in screen 1000.
    thank you.

    Hi,
    Select the three radio buttons in the screen painter,
    Edit->Grouping->Radiobutton group-> define.
    In this case all the radio buttons will be under one group and at a time only one will be active.
    Thanks,
    rajinikanth

  • *when we use at user -command and give smaple code fro at user-command*

    Hi experts,
    i am new to abap can any body tell me when we use AT USER-COMMAND and give a sample code for that.
    point will be rewarded.
    thanks.

    Hi,
    AT USER-COMMAND  is a list Event.This Event is triggered when user make an action on the Application Toolber Or Menubar.
    Here is the Program.
    START-OF-SELECTION.
      SET PF-STATUS 'TEST'.
      WRITE:  'Basic list, SY-LSIND =', sy-lsind.
    AT LINE-SELECTION.
      WRITE:  'LINE-SELECTION, SY-LSIND =', sy-lsind.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'TEST'.
          WRITE:  'TEST, SY-LSIND =', sy-lsind.
      ENDCASE.
    This program uses a status TEST, defined in the Menu Painter.
    Function key F5 has the function code TEST and the text Test for demo.
    Function code TEST is entered in the List menu.
    The function codes PICK and TEST are assigned to pushbuttons.
    The user can trigger the AT USER-COMMAND event either by pressing F5 , or by choosing List -> Test for demo, or by choosing the pushbutton 'Test for demo'.The user can trigger the AT LINE-SELECTION event by selecting a line.
    Hopr This Will help You.
    Regards,
    Sujit

  • I pick a photo, make a copy, add a mask and when I use a brush nothing happens to the mask or the picture. White or black?

    I pick a photo, make a copy, add a mask and when I use a brush nothing happens to the mask or the picture. White or black.

    If I understand you correctly, you have
    Opened an image, and copied the background layer. 
    Added a layer mask, and finding that painting in the mask makes no difference whether you paint with black or white.
    That is what you would expect to happen if both layers are identical.  To demonstrate, make a change to the copied layer.  Either change the blend mode to Multiply, or lower the opacity, or paint big red stripes across it.  Now when you paint with black, the red stripes will disappear where the mask is black, and be visible where the make is white.

Maybe you are looking for

  • How to open a excel with VBA button using I_OI_DOCUMENT_PROXY

    same this image: http://www.ImageThe.net/show-image.php?id=d367faef6ed7333acc2edd0290481fc8 how to use OPEN_ACTIVEX_DOCUMENT?   CALL METHOD DOCUMENT->OPEN_ACTIVEX_DOCUMENT     EXPORTING       DOCUMENT_URL = ITEM_URL     IMPORTING       ERROR        =

  • Sorting tree with Sortset/Treeset

    Have anyone tried sorting a jtrees nodes using sortset or treeset? I just want the children for each directory in my tree to be sorted. Collections like treeset and sortset should do the trick, but i have failed in my quest for the right solution. Ca

  • JDBC for SQL SERVER 2000

    I have downloaded it and installed it on my NT box. How do I use this? What's the syntax for making the connection? Any help is greatly appreciated.

  • How to delete unwanted email addresses from Mai

    How can I delete out of date email addresses from Mail, in Yosemite. This no longer seems to be an option. Thanks in advance for any help!

  • BIEE access to Essbase and Oracle

    I need to access Essbase through BIEE, and lookup the description from Oracle DB using the Essbase id retrieved at particular levels. I experienced that even though I select two dimensions out of the five dimensions, all dimensions will be accessed w