JEditorPane's paint method problem (urgent)

Hi all, I have JEditorPane that displays HTML formatted text.
My task requirement is to display a compay logo as static backgdound in this jeditorPane
(The logo must be displayed always in the center nevermind the text scrolling)...
So I overrided JEditorPane's paint method like that:
public void paint(Graphics g) {
      super.paint(g);
      int scrolled_down = (int) ( (JViewport)this.getParent()).getViewPosition().
          getY();
      Rectangle visibleRectangle = new Rectangle();
      int width = visibleRectangle.getBounds().width;
      int height = visibleRectangle.getBounds().height;
      ImageIcon logo = IconFactory.getInstance().getIngLogoPaleIcon();
      g.drawImage(logo.getImage(), (width - logo.getIconWidth()) / 2,
                  scrolled_down + (height - logo.getIconHeight()) / 2, this);
    }But the problem is that I drow the logo over the some part of the text and the text is not visible.
If I call super.paint(Graphics) mehtod after I drow the logo, the logo is overpainted and is not visible.
(This logo is very pale transparent gif image).
So my question is how can I achieve the effect this logo to be behind the text displayed in JEditorPane
(I tried if it's possible to use CSS body attributes for static background image,but as I expected they are not supported)
Thanks for every help in advance

Hi!
myEditorPane.setOpaque(false) This allows components under the EditorPane to show through.
Thus, add a label with the desired image into a JLayeredPane, (if using in a JDeskTopPane you have acces to its FRAME_CONTENT_LAYER).
Add your EditorPane on top of this after setting opaque to false and viola!
Be aware that you should use caution when choosing a forground, (font ), color as the underlying image will affect how your text appears....
:)

Similar Messages

  • Problem in paint() method

    i have defined a new class which extends JPanel. In that I have defined a paintComponent() method. i dont know how to use the repaint() method.
    can anyone help?

    i have defined a new class which extends JPanel. In
    that I have defined a paintComponent() method. i dont
    know how to use the repaint() method.I do not fully understand your problem, sorry. Could you please clarify a bit?
    The repaint()-method is there to draw an image to the screen once again, to make changes visible. As far as I know, it calls the update()- and paint()-methods whenever you call it.

  • Problem about calling paint method

    I have created a class to ask user input 3 floating-point numbers, using JApplet. the code list below
    import java.awt.Graphics;
    import javax.swing.*;
    public class Numbers
    double average,sum,product;
    String result;
    public void init()
    String firstNumber,secondNumber,thirdNumber;
    double num1,num2,num3;
    firstNumber=JOptionPane.showInputDialog("enter first number");
    secondNumber=JOptionPane.showInputDialog("Enter second number");
    thirdNumber=JOptionPane.showInputDialog("Enter thrid number");
    num1=Double.parseDouble(firstNumber);
    num2=Double.parseDouble(secondNumber);
    num3=Double.parseDouble(thirdNumber);
    sum=num1+num2+num3;
    product=num1*num2*num3;
    average=(num1+num2+num3)/3;
    result="";
    if(num1<num2 && num2<num3)
    result=result+num3+" is the largest number";
    if(num2>num1 && num2>num3)
    result=result+num2 +" is the largest number";
    if(num1>num2 && num2>num3)
    result=result+ num1+" is the largest number";
    public void paint(Graphics g)
    super.paint(g);
    g.drawString("sum is"+sum,25,25);
    g.drawString("product is"+ product,25,40);
    g.drawString("average is"+ average,25,60);
    g.drawString(" the largest number is"+result,25,80);
    however, after I compiled, it gave me the error message as:
    java:40: cannot resolve symbol
    symbol : method paint (java.awt.Graphics)
    location: class java.lang.Object
    super.paint(g);
    ^(pointer should point to the dot)
    don't know why,
    Message was edited by:
    ritchie_lin

    your class doesn't extend japplet or any other object for that matter. It does extend Object as all classes do, and Object has no paint method.
    Consider changing:
      public class Numbersto
      public class Numbers extends JAppletAlso, please use code tags next time you're posting code.
    Addendum: If this is not the JApplet portion of your code, it still has to subclass a Swing component that can accept painting such as JPanel. Also, with Swing you use paintComponent rather than paint.
    Message was edited by:
    petes1234

  • 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: ");
    }

  • Paint() method is in infinite loop when focus is set to JTextPane

    Hi All,
    I am creating one JScrollPane, JPanel and JTextPane. JPanel is added to JScrollPane and JTextPane is added to JPanel. If I override paint() method in JPanel, its in infinite loop. I don't know why it is behaving like this. Can anyone solve my problem. Since, I am doing so much drawings in paint() method, its getting to slow.
    Here is the code what I wrote.
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TestTextPane1 extends JFrame {
         JPanel panel;
         JScrollPane pane;
         public TestTextPane1() {
              panel = new JPanel(new BorderLayout()) {
                   public void paint(Graphics g) {
                        super.paint(g);
                        System.out.println("inside paint");
              JTextPane textPane = new JTextPane();
              panel.add(textPane);
              pane = new JScrollPane(panel);
              getContentPane().add(pane);
              setSize(300, 200);
              setVisible(true);
         public static void main(String [] args) {
              new TestTextPane1();
    Any help will be useful for me.
    Regards
    Kishore.

    What are you trying to do? You are adding the textPane to the panel and then overriding the paint() method. The textPane will never be painted if you do this.
    In Swing, you should override the paintComponent() method, not the paint() method. See the Swing tutorial on Painting:
    http://java.sun.com/docs/books/tutorial/uiswing/overview/draw.html
    Don't forget to read the "Working With Graphics" link at the bottom.

  • How to use an object's paint method

    I have created a class imagePanel which extends a jPanel to display an image. When I create a new imagePanel object I pass it an image argument which is used to paint my image on the jPanel, so far so good. I don't wish to have to continuously create new ImamePanels to display new images so I thought I could make a set_Image method that would set a new image in an exising imagePanel object. This is where I run into problems how to use the existing object paint method to replace the image. I tried this without success:
    public Image setMyImage (Image myImage)
    imageX = myImage; // imageX is the image that is painted by the imagePanel object's paint method
    paint(g);
    Something must be wrong on how I access the paint method. Thanks for any help.
    Jack

    Yahoooo, got it. This was the code I needed and thanks for your help:
    public void setImage (Image myImage)
    imageX = myImage;
    repaint(300);
    }

  • How to call paint() method during creating object

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    class SomeShape extends JPanel {
         protected static float width;
         protected BasicStroke line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
    class Oval extends SomeShape {
         Oval(float width) {
              this.width = width;
              line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
              repaint();
         public void paint(Graphics g) {
              Graphics2D pen = (Graphics2D)g;
              int i = 10;
              super.paint(g);
                   g.setColor(Color.blue);
                   g.drawOval(90, 0+i, 90, 90);
                   System.out.println("paint()");
    public class FinalVersionFactory {
        JFrame f = new JFrame();
        Container cp = f.getContentPane();
        float width = 0;
        SomeShape getShape() {
             return new Oval(width++); //I want to paint this oval when I call getShape() method
         public FinalVersionFactory() {
              f.setSize(400, 400);
    //          cp.add(new Oval()); without adding
              cp.addMouseListener(new MouseAdapter() {
                   public void mouseReleased(MouseEvent e) {
                        getShape();
              f.setVisible(true);
         public static void main(String[] args) { new FinalVersionFactory(); }
    }I need help. When I cliked on the JFrame nothing happened. I want to call paint() method and paint Oval when I create new Oval() object in getShape(). Can you correct my mistakes? I tried everything...Thank you.

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    class SomeShape extends JPanel {
         protected static float width;
         protected static BasicStroke line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
    class Oval extends SomeShape {
         static int x, y;
         Oval(float width, int x, int y) {
              this.width = width;
              this.x = x;
              this.y = y;
              line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
         public void paint(Graphics g) {
              Graphics2D pen = (Graphics2D)g;
                   g.setColor(Color.blue);
                   pen.setStroke(line);
                   g.drawOval(x, y, 90, 90);
                   System.out.println("Oval.paint()"+"x="+x+"y="+y);
    class Rect extends SomeShape {
         static int x, y;
         Rect(float width, int x, int y) {
              this.width = width;
              this.x = x;
              this.y = y;
              line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
         public void paint(Graphics g) {
              Graphics2D pen = (Graphics2D)g;
                   g.setColor(new Color(250, 20, 200, 255));      
                   pen.setStroke(line);
                   g.drawRect(x, y, 80, 80);
                   System.out.println("Rect.paint()"+"x="+x+"y="+y);
    public class FinalVersionFactory extends JFrame {
        Container cp = getContentPane();
        float width = 0;
        int x = 0;
        int y = 0;
            boolean rect = false;
        SomeShape getShape() {
             SomeShape s;
              if(rect) {
                   s = new Rect(width, x, y);
                   System.out.println("boolean="+rect);
              } else {
                   s = new Oval(width++, x, y);
                   System.out.println("boolean="+rect);
              System.out.println("!!!"+s); //print Oval or Rect OK
              return s; //return Oval or Rect OK
         public FinalVersionFactory() {
              setSize(400, 400);
              SomeShape shape = getShape();
              cp.add(shape); //First object which is add to Container(Oval or Rect), returned by getShape() method
              //will be paint all the time. Why? Whats wrong?
              cp.addMouseListener(new MouseAdapter() {
                   public void mouseReleased(MouseEvent e) {
                        x = e.getX();
                        y = e.getY();
                        rect = !rect;
                        getShape();
                        cp.repaint(); //getShape() return Oval or Rect object
                                      //but repaint() woks only for object which was added(line 67) as first
              setVisible(true);
         public static void main(String[] args) { new FinalVersionFactory(); }
    }I almost finish my program but I have last problem. I explained it in comment. Please look at it and correct my mistakes. I will be very greatful!!!
    PS: Do you thing that this program is good example of adoption Factory Pattern?

  • Determining if printing is going on in paint method

    By looking at the source of the existing visual components, I have found out that JComponent.paintChildren uses getFlag(IS_PRINTING) to determine wether or not the current call to paint will paint to screen or to a printer.
    The problem is that both getFlag and the constants it uses are declared as private in JComponent. This is why I am wondering why Sun chose to keep this information private to the JComponent class, while this information could be very useful in some situations.
    Also, would there be any alternatives to determine wether or not printing is occuring from a paint method besides managing flags the same way JComponent does?
    Thanks in advance.

    I gave a try to your approach but it doesn't seem that the graphics object passed to the paint method during the printing process implements PrintGraphics. I'll keep trying stuff with that idea until some new input is given, but thanks for the idea, it sure could have worked out ;)

  • More than one paint method?

    Hi
    Im wondering if it is possible to have more than one paint method. It should look something like this.
    public class MyApplet extends JApplet {
    public void paint(Graphics g) { // the normal paint method
    public void SecondPaint(Graphics gr) { // should i name the Graphics
    // to the same as in the normal paint method ( Graphics g) ?
    }And if its possible how would i repaint the other method?
    This is for the normal
    repaint(); and how would i do for the second paint method?
    please write an example program with two paint methods and just write below how to repaint.
    Thanks you som much if you reply

    (sorry to hijack this thread...) Yes, it'swindows,
    but right now my problem isn't even that. It'sjust
    catching and correcting basic c-coding errors.
    Witness my embarrassment in the JNI forum:
    http://forum.java.sun.com/thread.jspa?threadID=5213196
    &tstart=15
    Now if only I lived in "middle-of-no-where"Virginia!
    Nice! ;-)I saw your note about "middle-of-nowhere" Virginia a little too late. And you don't need to live here; my Solaris machine is up and running 24/7 and is open for SSH and XClient. (Also open for telnet, which comes built into windows, I believe.) If you'd like to brush up on Solaris C, C++ and Java development, just let me know. You're more than welcome to use the machine. I have tons of space on the drive and a dedicated connection just to that machine. There is an application for windows called CygwinX which is an XClient for Solaris. You can use that to remotely log into the Solaris desktop. There are about fifteen other people that I let use the machine for various reasons. I host myriad open source projects for development that you're more than welcome to mess around with. Tools available to you would be NetBeans 5.5, Sun Studio (with the Sun C/C++/Fortran compiler - which is beautiful by the way); and the whole suite of GNU compilers. I have the CDE and the JavaDesktop built in. I also have tons of Motif tutorials and demonstrations if you're interested in those. Heads up, though ... XServer tends to run pretty slowly when I have more than about four users logged onto a desktop at once. But like I said, if you (or just about anyone else for that matter) are interested, let me know and I'd be more than glad to set you up.

  • Passing Data to a Paint Method

    Total newbie here just learning the basics of Java on my own. Working a little application that will display a filled polygon which shows the correct heading of ship based on previously input Ship Heading, length and width. I have the application working fine to generate the 5 points, and then it will display correctly when I enter the points in the paint method by hand. Thing is I want to have the coords passed to the paint method. and am having some trouble doing this. All the examples I have seen show the points to be displayed already being declared in the paint method. Here is the Paint Method I have come up with based on examples I have seen. Still pretty new and trying to read through the APIs and other books, but haven't broken the code on understanding them.
    import java.awt.*;
    import javax.swing.*;
    public class DrawShip5
       public static void main(String[] a)
        JFrame f = new JFrame();
        f.setTitle("Ship Heading");
        f.setSize(700,700);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(new DrawShip2());
        f.setVisible(true);
       static class DrawShip2 extends JComponent
           static public void paintData(int [] finalCoordsArray )
        int finalBowACoordX = finalCoordsArray[0];
        int finalBowACoordY = finalCoordsArray[1];
        int finalPortMidACoordX = finalCoordsArray[2];
        int finalPortMidACoordY = finalCoordsArray[3];
        int finalPortSternACoordX = finalCoordsArray[4];
        int finalPortSternACoordY = finalCoordsArray[5];
        int finalStarSternACoordX = finalCoordsArray[6]; 
        int finalStarSternACoordY = finalCoordsArray[7]; 
        int finalStarMidACoordX = finalCoordsArray[8];
        int finalStarMidACoordY = finalCoordsArray[9];       
        public void paint(Graphics g )
             // Am sure my problem lies in here
            int finalBowACoordX = paintData.finalBowACoordX;
            int finalBowACoordY = paintData.finalBowACoordY;
            int finalPortMidACoordX = paintData.finalPortMidACoordX;
            int finalPortMidACoordY = paintData.finalPortMidACoordY;
            int finalPortSternACoordX = paintData.finalPortSternACoordX;
            int finalPortSternACoordY = paintData.finalPortSternACoordY;
            int finalStarSternACoordX = paintData.finalStarSternACoordX; 
            int finalStarSternACoordY = paintData.finalStarSternACoordY; 
            int finalStarMidACoordX = paintData.finalStarMidACoordX;
            int finalStarMidACoordY = paintData.finalStarMidACoordY;    
             g.setColor(Color.black);
             g.drawLine(350, 0, 350, 700);
             g.drawLine(0, 350, 700, 350);
             g.setColor(Color.blue);
             Polygon shipPic = new Polygon();
             shipPic.addPoint( finalBowACoordX, finalBowACoordY ); // Bow Coords
             shipPic.addPoint( finalPortMidACoordX, finalPortMidACoordY ); // Port Midship Coords
             shipPic.addPoint( finalPortSternACoordX, finalPortSternACoordY ); // Port Aft Coords
             shipPic.addPoint( finalStarSternACoordX, finalStarSternACoordY ); // Starboard Aft Coords
             shipPic.addPoint( finalStarMidACoordX, finalStarMidACoordY ); // Starboard Midship Coords
             g.fillPolygon( shipPic );
    } Thanks for any help

    Looks like I was typing as Malcom was responding....where would I add that bit of code?
    import java.awt.*;
    import javax.swing.*;
    public class DrawShip5
       public static void main(String[] a)
        JFrame f = new JFrame();
        f.setTitle("Ship Heading");
        f.setSize(700,700);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(new DrawShip2());
        f.setVisible(true);    
        // Place the code here? Get an error for the finalCoordsArray not recognized
       static class DrawShip2 extends JComponent
                private int finalBowACoordX;
             private int finalBowACoordY;
             private int finalPortMidACoordX;
             private int finalPortMidACoordY;
             private int finalPortSternACoordX;
             private int finalPortSternACoordY;
             private int finalStarSternACoordX; 
             private int finalStarSternACoordY; 
             private int finalStarMidACoordX;
             private int finalStarMidACoordY; 
              static public void setCoords(int [] finalCoordsArray)
                 int finalBowACoordX = finalCoordsArray[0];
                 int finalBowACoordY = finalCoordsArray[1];
                 int finalPortMidACoordX = finalCoordsArray[2];
                 int finalPortMidACoordY = finalCoordsArray[3];
                 int finalPortSternACoordX = finalCoordsArray[4];
                 int finalPortSternACoordY = finalCoordsArray[5];
                 int finalStarSternACoordX = finalCoordsArray[6]; 
                 int finalStarSternACoordY = finalCoordsArray[7]; 
                 int finalStarMidACoordX = finalCoordsArray[8];
                 int finalStarMidACoordY = finalCoordsArray[9];
              // Print final coords after array passed and parsed
                 System.out.println("Paint Final Bow Coords: (" + finalBowACoordX + ", " + finalBowACoordY + ")");
                 System.out.println("Paint Final Port Midship Coords: (" + finalPortMidACoordX + ", " + finalPortMidACoordY + ")");
                 System.out.println("Paint Final Port Stern Coords: (" + finalPortSternACoordX + ", " + finalPortSternACoordY + ")");
                 System.out.println("Paint Final Starboard Stern Coords: (" + finalStarSternACoordX + ", " + finalStarSternACoordY + ")");
                 System.out.println("Paint Final Starboard Midship Coords: (" + finalStarMidACoordX + ", " + finalStarMidACoordY + ")");
          public void paintComponent(Graphics g )
            g.setColor(Color.black);
             g.drawLine(350, 0, 350, 700);
             g.drawLine(0, 350, 700, 350);
             g.setColor(Color.blue);
             Polygon shipPic = new Polygon();
             shipPic.addPoint( finalBowACoordX, finalBowACoordY ); // Bow Coords
             shipPic.addPoint( finalPortMidACoordX, finalPortMidACoordY ); // Port Midship Coords
             shipPic.addPoint( finalPortSternACoordX, finalPortSternACoordY ); // Port Aft Coords
             shipPic.addPoint( finalStarSternACoordX, finalStarSternACoordY ); // Starboard Aft Coords
             shipPic.addPoint( finalStarMidACoordX, finalStarMidACoordY ); // Starboard Midship Coords
             g.fillPolygon( shipPic );
    }Tried placing that code in a few spots and got errors.
    Appreciate the help, These are my first attempts at actually getting away from a single method program. Am getting it ...slowly, but I am getting it.

  • J2EE StartUp Problem, URGENT.

    Hi all!
    I'm having a problem since friday with the J2EE Engine Startup. The problem is that MMC says me that the server is running but i can access to the server by anyway. The developer trace of the jcontrol process is:
    [Thr 2968] Tue Aug 09 13:59:50 2005
    [Thr 2968] JControlICheckProcessList: process server0 started (PID:1544)
    JStartupStartJLaunch: program = C:\usr\sap\J2E\JC00/j2ee/os_libs/jlaunch.exe
    -> arg[00] = C:\usr\sap\J2E\JC00/j2ee/os_libs/jlaunch.exe
    -> arg[01] = pf=C:\usr\sap\J2E\SYS\profile\J2E_JC00_toshiba-user
    -> arg[02] = -DSAPINFO=J2E_00_sdm
    -> arg[03] = -file=C:\usr\sap\J2E\JC00\SDM\program\config\sdm_jstartup.properties
    -> arg[04] = -nodeName=sdm
    -> arg[05] = -nodeId=2
    -> arg[06] = -syncSem=JSTARTUP_WAIT_ON_2964
    -> arg[07] = -jvmOutFile=C:\usr\sap\J2E\JC00\work\jvm_sdm.out
    -> arg[08] = -stdOutFile=C:\usr\sap\J2E\JC00\work\std_sdm.out
    -> arg[09] = -locOutFile=C:\usr\sap\J2E\JC00\work\dev_sdm
    -> arg[10] = -mode=JCONTROL
    -> arg[11] = pf=C:\usr\sap\J2E\SYS\profile\J2E_JC00_toshiba-user
    -> lib path = PATH=C:\j2sdk1.4.2_08\jre\bin\server;C:\j2sdk1.4.2_08\jre\bin;C:\oracle\WAS\92\bin;C:\oracle\WAS\92\jre\1.4.2\bin\client;C:\oracle\WAS\92\jre\1.4.2\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\j2sdk1.4.2_08\bin;C:\oracle\WAS\92\Appache\perl\5.00503\bin\MSWin32-x86;C:\usr\sap\J2E\SCS01\exe;C:\usr\sap\J2E\JC00\exe;C:\usr\sap\J2E\SYS\exe\run
    -> exe path = PATH=C:\j2sdk1.4.2_08\bin;C:\usr\sap\J2E\JC00\j2ee\os_libs;C:\oracle\WAS\92\bin;C:\oracle\WAS\92\jre\1.4.2\bin\client;C:\oracle\WAS\92\jre\1.4.2\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\j2sdk1.4.2_08\bin;C:\oracle\WAS\92\Appache\perl\5.00503\bin\MSWin32-x86;C:\usr\sap\J2E\SCS01\exe;C:\usr\sap\J2E\JC00\exe;C:\usr\sap\J2E\SYS\exe\run
    [Thr 2968] Tue Aug 09 13:59:51 2005
    [Thr 2968] JControlICheckProcessList: process SDM started (PID:1556)
    [Thr 1188] Tue Aug 09 14:01:01 2005
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] Tue Aug 09 14:01:58 2005
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] JControlMSMessageFunc: receive command:6, argument:1213679940 from Message Server
    [Thr 1188] Tue Aug 09 14:10:25 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:15:45 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:20:46 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:26:06 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:31:07 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:36:27 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:41:28 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    Then i try to login the visual admin gives me a windows error and the msg_server process shuts down alone. Then i restart that node and agregate the following lines to the trace:
    Thr 1188] Tue Aug 09 14:42:25 2005
    [Thr 1188] *** ERROR => MsINiRead: NiBufReceive failed (NIECONN_BROKEN) [msxxi.c      2488]
    [Thr 1188] *** ERROR => MsIReadFromHdl: NiRead (rc=NIECONN_BROKEN) [msxxi.c      1652]
    [Thr 1188] Tue Aug 09 14:42:27 2005
    [Thr 1188] ***LOG Q0I=> NiPConnect2: SiPeekPendConn (10061: WSAECONNREFUSED: Connection refused) [nixxi_r.cpp 8588]
    [Thr 1188] *** ERROR => MsIAttachEx: NiBufConnect to toshiba-user/3601 failed (rc=NIECONN_REFUSED) [msxxi.c      633]
    [Thr 1188] *** WARNING => Can't reconnect to message server (toshiba-user/3601) [rc = -100]-> reconnect [jcntrms.c    295]
    [Thr 1188] Tue Aug 09 14:42:32 2005
    [Thr 1188] *** ERROR => MsIAttachEx: NiBufConnect to toshiba-user/3601 failed (rc=NIECONN_REFUSED) [msxxi.c      633]
    [Thr 1188] *** WARNING => Can't reconnect to message server (toshiba-user/3601) [rc = -100]-> reconnect [jcntrms.c    295]
    [Thr 1188] Tue Aug 09 14:42:38 2005
    [Thr 1188] *** ERROR => MsIAttachEx: NiBufConnect to toshiba-user/3601 failed (rc=NIECONN_REFUSED) [msxxi.c      633]
    [Thr 1188] *** WARNING => Can't reconnect to message server (toshiba-user/3601) [rc = -100]-> reconnect [jcntrms.c    295]
    [Thr 1188] Tue Aug 09 14:42:44 2005
    [Thr 1188] *** ERROR => MsIAttachEx: NiBufConnect to toshiba-user/3601 failed (rc=NIECONN_REFUSED) [msxxi.c      633]
    [Thr 1188] *** WARNING => Can't reconnect to message server (toshiba-user/3601) [rc = -100]-> reconnect [jcntrms.c    295]
    [Thr 1188] Tue Aug 09 14:42:49 2005
    [Thr 1188] JControlMSConnect: reconnected to message server (toshiba-user/3601)
    [Thr 1188] Tue Aug 09 14:48:11 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:53:12 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    [Thr 1188] Tue Aug 09 14:58:32 2005
    [Thr 1188] JControlMSReadMessage: NiPeek() returns -5 NIETIMEOUT
    I try to login the visual admin again and gives me the following error: "Cannot open connection on host: 191.9.6.22 and port: 50004"
    Looking the log and trace files i see the following errors:
    - SAPEngine_System_Thread[impl:5]_5##0#0#Error#1#/System/Server#Plain###Encomi: failed to connect to toshiba-user/3201(Connection refused: connect)#
    - java.net.SocketException: socket closed
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.sap.engine.core.port.impl0.ServerSocketListener.run(ServerSocketListener.java:87)
    - erver socket listener opened by service on socket encountered error. The listener will be stopped.#2#p4#ServerSocket[addr=/0.0.0.0,port=0,localport=50004]
    I dont know whats happening, if somebody knows i hope that helps me. Please is urgent.
    Thx and Rgds.
    Gregory

    Hi, thx a lot both.
    Respect the link
    http://<hostname>:50<instanceno>00/sap/monitoring/SystemInfo , i cant access it. I cant access by telnet, by visual admin.
    In the work folder under \usr\sap\<sid>\JC00 i found that the last updated files are:
    - available.txt that contains the following data:
        Unavailable 08.08.2005 10:46:53 - 08.08.2005 10:58:54
        Available   08.08.2005 10:59:54 - 08.08.2005 13:52:54
        Unavailable 08.08.2005 13:53:54 - 08.08.2005 13:53:54
        Available   08.08.2005 13:54:54 - 08.08.2005 14:03:54
        Unavailable 08.08.2005 14:04:54 - 08.08.2005 14:04:54
        Available   08.08.2005 14:05:54 - 08.08.2005 14:34:54
        Unavailable 08.08.2005 14:35:54 - 08.08.2005 14:39:44
        Unavailable 08.08.2005 14:56:17 - 08.08.2005 16:24:13
        Unavailable 08.08.2005 16:28:07 - 08.08.2005 16:29:07
        Unavailable 08.08.2005 16:34:36 - 08.08.2005 17:17:58
        Unavailable 09.08.2005 08:13:36 - 09.08.2005 08:54:33
        Unavailable 09.08.2005 08:57:04 - 09.08.2005 12:46:25
        Available   09.08.2005 12:47:25 - 09.08.2005 13:26:25
        Available   09.08.2005 13:43:56 - 09.08.2005 13:55:56
        Unavailable 09.08.2005 13:56:40 - 09.08.2005 14:04:57
        Available   09.08.2005 14:05:57 - 09.08.2005 16:16:57
        Unavailable 09.08.2005 16:17:57 - 09.08.2005 17:27:12
        Unavailable 10.08.2005 08:10:30 - 10.08.2005 08:35:39
        Available   10.08.2005 08:36:39 - 10.08.2005 09:16:39
        Available   10.08.2005 12:33:51 - 10.08.2005 14:01:51
    - dev_jcontrol that contains the information displayed in the developer trace of jcontrol process(and y mentioned above)
    - dev_dispatcher that contains the following info:
        [Thr 2664] Wed Aug 10 08:33:04 2005
        [Thr 2664] JHVM_RegisterNatives: registering methods in com.sap.bc.proj.jstartup.JStartupFramework
        [Thr 2664] JLaunchISetClusterId: set cluster id 5761000
        [Thr 2664] JLaunchISetState: change state from [Initial (0)] to [Waiting for start (1)]
        [Thr 2664] JLaunchISetState: change state from [Waiting for start (1)] to [Starting (2)]
        [Thr 3320] Wed Aug 10 08:33:21 2005
        [Thr 3320] JLaunchISetP4Port: set p4 port 50004
        [Thr 3528] Wed Aug 10 08:33:26 2005
        [Thr 3528] JLaunchISetTelnetPort: set telnet port 50008
        [Thr 3528] JLaunchISetTelnetPort: set telnet port 50008
        [Thr 3584] Wed Aug 10 08:33:55 2005
        [Thr 3584] JLaunchISetHttpPort: set http port 50000
        [Thr 2664] Wed Aug 10 08:34:02 2005
        [Thr 2664] JLaunchISetState: change state from [Starting (2)] to [Running (3)]
        [Thr 2568] Wed Aug 10 08:34:08 2005
        [Thr 2568] JHVM_RegisterNatives: registering methods in com.sap.mw.rfc.driver.CpicDriver
        [Thr 3660] Wed Aug 10 08:35:07 2005
        [Thr 3660] JLaunchISetP4Port: set p4 port 50004
        [Thr 3600] Wed Aug 10 08:36:34 2005
        [Thr 3600] JLaunchISetHttpPort: set http port 50000
        [Thr 3612] Wed Aug 10 12:43:40 2005
        [Thr 3612] JLaunchISetHttpPort: set http port 50000
        [Thr 3612] JLaunchISetP4Port: set p4 port 50004
        [Thr 3612] JLaunchISetTelnetPort: set telnet port 50008
    - dev_server0 that contains:
        [Thr 2676] Wed Aug 10 08:33:06 2005
        [Thr 2676] JHVM_RegisterNatives: registering methods in com.sap.bc.proj.jstartup.JStartupFramework
        [Thr 2676] JLaunchISetClusterId: set cluster id 5761050
        [Thr 2676] JLaunchISetState: change state from [Initial (0)] to [Waiting for start (1)]
        [Thr 2676] JLaunchISetState: change state from [Waiting for start (1)] to [Starting (2)]
        [Thr 4296] Wed Aug 10 08:34:58 2005
        [Thr 4296] JHVM_RegisterNatives: registering methods in com.sap.mw.rfc.driver.CpicDriver
        [Thr 4296] Wed Aug 10 08:35:00 2005
        [Thr 4296] JHVM_RegisterNatives: registering methods in com.sap.mw.jco.util.SAPConverters
        [Thr 4296] JHVM_RegisterNatives: registering methods in com.sap.mw.jco.util.SAPCharToNUCByteConverter
        [Thr 4296] Wed Aug 10 08:35:01 2005
        [Thr 4296] JHVM_RegisterNatives: registering methods in com.sap.mw.jco.util.SAPNUCByteToCharConverter
        [Thr 2676] Wed Aug 10 08:35:07 2005
        [Thr 2676] JLaunchISetState: change state from [Starting (2)] to [Starting applications (10)]
        [Thr 208] Wed Aug 10 08:36:34 2005
        [Thr 208] JLaunchISetState: change state from [Starting applications (10)] to [Running (3)]
    I still dont know whats happening. And i need to solve the problem urgent. I hope u can help me.
    Thx and Rgds.
    Gregory.

  • Paint / Repaint problem

    Hi,
    I have a panel with a checkbox and a slider, and I want to put a string below the slider...so here is what i do...
         public void paint(Graphics g) {
              super.paint(g);
               * Get original font (need its height)
              originalFont = getFont();
              FontMetrics fm = getFontMetrics(originalFont);          
              setFont(some_new_font);
              FontMetrics fontMetrics = getFontMetrics(getFont());
               * String to paint.
              String seconds = "(seconds)";
               * Calculate where to place the string
              int strWidth = fontMetrics.stringWidth(seconds);                    //string width
              int origH    = fm.getHeight();                                             //original font height
              Point p      = sliderLengthOfTest.getLocation();                    //location of slider in the panel
              int w        = (int)sliderLengthOfTest.getSize().getWidth();     //width of slider
              int h        = (int)sliderLengthOfTest.getSize().getHeight();   //height of slider
              int x        = ((w - strWidth) / 2) + (int)p.getX();            //calculate X
              int y           = (int)p.getY() + h - origH;                              //calculate Y
              g.drawString(seconds, x , y);
         }that works...but when I check/uncheck the checkbox, the string i painted disappears...so i tried to do the same thing I do in the paint method, as in the repaint method...
    public void repaint(Graphics g) {
         super.paint(g);
          //....do same stuff here as I did in the paint method
    }but that did not solve the problem....any ideas?
    Thanks.

    Why don't you just put the slider in a panel, with a label under it ?
    (could be a panel with BorderLayout, for example... with Slider in CENTER and label in SOUTH)

  • Paint()/repaint() problem w/applet

    Hi all. Here's my dilemma: I'm trying to create an applet that asks for simple multiplication answers, and draws a string giving feedback after the question is answered ("Very good!" or "No, try again."). The problem is that the book says to draw everything from paint(), and gives the impression that repaint() should magically refresh everything on the applet, which it does not. How can I make the strings I drew in paint() go away and give way to new strings based on user answer (whether correct or not), instead of piling up on top of each other, because they don't refresh? Also, my JButton and JTextField aren't showing up until the mouse is scrolled over them. Thanks for your time!
    code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Week5Class extends JApplet implements ActionListener
        static int int1 = (int)(Math.random()*10);
        static int int2 = (int)(Math.random()*10);
        JTextField answer = new JTextField(3);
        JButton verifyAnswer = new JButton("Click to see if correct");
        public void init()
            Container myContainer = getContentPane();
            myContainer.add(answer);
            myContainer.add(verifyAnswer);
            verifyAnswer.addActionListener(this);
            myContainer.setLayout(new FlowLayout());
        static int j = 0;
        static int i;
        public void paint(Graphics gr)
              gr.drawString("How much is " + int1 + " * " + int2 + "?", 10, 70);
              if(i == 1)
                  gr.drawString("VeryGood!", 300, 200);
              else if(i == 0 && j != 0)
                  gr.drawString("No. Please try again.", 300, 200);
              j++;
        public void actionPerformed(ActionEvent e)
            int x = 300;
            int y = 200;
            if(Integer.parseInt(answer.getText()) == (int1*int2))
                int1 = (int)(Math.random()*10);
                int2 = (int)(Math.random()*10);
                i = 1;
                repaint();
            else
                i = 0;
                repaint();
    }

    The problem is that you're mixing doing your own drawing and using child objects. The paint method you've overriden would be the one that draws the text field and button.
    A far easier approach would be to use a JLabel to display your response message, and insert that as another component into the container, as you've inserted the button and input field.
    Then use setText() on the label to change the message.
    If you really want to have an area that you draw arbitary shapes on it's best to create your own child component, add it to the container, and override it's paintComponent method. Alternatively create a class which implments the Icon interface and put it in a JLabel.
    FlowLayout isn't very clever, by the way, try a BorderLayout or maybe a BoxLayout.

  • Mixing a paint method and labels???

    Hi,
    I've got a panel which has a paint method which draws various shapes, it also has someJLabels. The problem is when i add this paint method to the class then all the JLabels disappear! If i remove it then they display as normal.
    Please can someone help
    Cath

    I think you should be overriding the paintComponent() method of the JPanel.
    Here is a link to a section in the Swing tutorial titled "Painting".
    http://java.sun.com/docs/books/tutorial/uiswing/overview/draw.html
    Don't forget to continue with the "Working with Graphics" link at the bottom. (This will explain why you should use paintComponent() method).

  • Help with 2D Graphics - How do I send Variable data to paint method?

    I am working on a program that figures mortgage payments and an amortization schedule when a user inputs the principle, APR, and term length in years. After it figures all of those, I want to be able to display a chart that shows the principle and interest amounts for each year. My problem is, how do I get my loan information into my paint method so that I can draw a chart using that data? Any help would be greatly appreciated. The graph class in the code below is called after pressing a "Display Graph" button from my GUI.
    I'm pasting my code below. This does not include my main method or my GUI method. I can post those if necessary. Here is my code so far:
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.io.*;
    import java.lang.Math;
    public class Graph extends JFrame
         public Graph(double dCurrentBalance, double dMonthlyPmt, double dRate, int iTime)
              final double balance = dCurrentBalance;
              JFrame graphFrame;
              int iCounter = 0;
              int iPmtNumber = 0;
              double dCurrentInt = 0.0;
              double dCurrentPrinciple = 0.0;
              double dMPR = 0.0;
              int yCoordInt = 0;               //integer for Y coordinate for Interest
              int yCoordPrinciple = 0;     //integer for Y coordinate for Principle
              iTime *= 12;               //determine number of months for this loan
              iCounter = iTime;          //set loop counter to number of months for this loan
              dMPR = dRate/12;          //determine monthly periodic rate
              graphFrame = new JFrame ("mCalc Graph");
              graphFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              graphFrame.setSize(800,600);
              graphFrame.setResizable(false);
              // center graphFrame on the screen
         Dimension ScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
         Dimension FrameSize = graphFrame.getSize();
         if (FrameSize.height > ScreenSize.height)
         FrameSize.height = ScreenSize.height;
         if (FrameSize.width > ScreenSize.width)
         FrameSize.width = ScreenSize.width;
         graphFrame.setLocation((ScreenSize.width - FrameSize.width) / 2,
                   (ScreenSize.height - FrameSize.height) / 2);
              //Displays graphFrame
              Graphic graphicPane = new Graphic();
              graphFrame.add(graphicPane);
              graphFrame.setVisible(true);
              //This loops until all payments have been figured
              for (; iCounter > 0; )
         iPmtNumber++;
         dCurrentInt = dCurrentBalance * dMPR;
         dCurrentPrinciple = dMonthlyPmt - dCurrentInt;
         dCurrentBalance = dCurrentBalance - dCurrentPrinciple;
                   if (iPmtNumber%12 == 0)
    //           System.out.println("dCurrentBalance = " + dCurrentBalance);
    //                    System.out.println("Payment # = " + iPmtNumber);
    //                    System.out.println("dCurrentInt = " + dCurrentInt);
    //                    System.out.println("dCurrentPrinciple = " + dCurrentPrinciple);
         iCounter = iCounter-1;
              } //end for loop
         } //end Graph constructor
    /* This class needs to be personalized to include my own variable names,
    *     etc. I also need to find a way to bring in data from the Graph class.
         class Graphic extends JPanel
              public void paintComponent(Graphics comp)
                             int i; // Declare the variables used to generate the chart
    float xLoc = 50; // Location of the X Axis along Y
    float yLoc = 50; // Location of the Y Axis along X
    Line2D.Float LnA; //
    super.paintComponent(comp);
                   // Establish a tie between this subroutine and the Graphic
    Graphics2D comp2D = (Graphics2D) comp;
    // Cast the Graphics named comp to a Graphics2D as comp2D
    comp2D.setColor(Color.white);
    // Set the background color
    comp2D.fillRect(0,0,800,600);
    // Draw the X and Y axis
    comp2D.setColor(Color.black); // Set the pen color to black
    Line2D.Float YAxis = new Line2D.Float(50,50,50,getSize().height - 50); // Define the Y-Axis
    Line2D.Float XAxis = new Line2D.Float(50F,getSize().height - 50F, getSize().width -50F, getSize().height -50F); //Define the X-Axis
    comp2D.draw(YAxis); // Draw the Y-Axis
    comp2D.draw(XAxis); // Draw the X-Axis
    Font font = new Font("Dialog", Font.BOLD, 12); // Set the font for the Axis labels
    comp2D.setFont(font);
    float increment = 15;
    // Draw the line
    xLoc += increment;
    comp2D.setColor(Color.red);
    /* Need to find a way to bring in my own data to use for the
    * yLoc variables.
    for (i=1; i<=45; i++)
    { // Begin making the graph
    if (i < 30)
         yLoc += increment;
    } else {
         yLoc -= increment;
    // Scale the location to the graph height
    LnA = new Line2D.Float( xLoc, getSize().height - 50F , xLoc, yLoc); // Create the line
    comp2D.draw(LnA); // Draw the line
    xLoc += increment;
                             }//end for
                   }//end paintComponent
              } //end class Graphic
    } //end class Graph
    Any help would be GREATLY appreciated! Thanks.
    Message was edited by:
    russedl
    My email address iss [email protected] if you wish to reply privately. I can send my entire program code if that will help. Thanks!

    Hi Deca,
    You can use the CmdExecuteSync method of the DIAdem.TOCommand interface to set the value of a text channel. For example passing the string "CHT(1,1) := 'test'" as a parameter to the CmdExecuteSync method will set the 1st row of the 1st channel to "test". Please refer to the DIAdem help for more documentation on the CHT function.
    I hope this helps! Please post back if I wasn't clear enough in explaining how to do this or if you have any problems getting it to work.
    Regards,
    Sarah Miracle
    National Instruments

Maybe you are looking for

  • Drive won't read any dvd-ejects it automatically after spinning some time

    The SuperDrive on my MBP has stopped recognizing/reading any blank DVD media (and many recorded DVDs, including movie discs). It spins for some time with a noise and then ejects it out. The same media works fine in my wife's Sony Vaio laptop. There w

  • Bridge (and mini Bridge) shows no thumbnails

    Bridge CS6 doesn't seem to work at all. The program launches fine on my Mac, but when I point it to a folder of images, I get nothing. No thumbnails or metadata. If I double click on an image (blank thumb), the image properly launches in Photoshop or

  • Important:Text control

    Hi all, I have a mx:Text with width as 200 and this control is within the itemRenderer of HorizontalList and so the Text contents may vary based on the data. So is there any way to find the exact width of the text content in the mx:Text. When i do Te

  • SQL server support or can store data in multiple languages? If so, how is it done

    Hi All, Can you please let me know If SQL server support or can store data in multiple languages? If so, how is it done.. Thanks, Subbu Thanks, Subbu

  • WHERE'S THE 8i SERVER FORUM???????

    Seems a bit daft to me that there should be everything else BUT a forum for the 8i Server (std or enterprise) product. FORUM MANAGAERS: - Can you set it up?