Paint JPanel problem

Hi All
I have 2 classes
class1. has a Jframe with a JPanel.
class1 2. A Has a JPanel called contact
I am calling class2 from class1.
It is placing the the contact Panel onto the JPanel in class1 but does not show. If I resize class1 it the shows that it is there.
I have tried repaint(); with out any luck
any other help would be helpfull
Thanks
Craig

Ok Here you go
I have class1 witch is my main frame called Command class
I have a menu class that has a jTree on it called Menu_Panel
Then I have a class called DataClient which is the panel that I am have Problems with.
Here is the Code
This is the jbInit in the Command Class.
    mainPanel.setLayout(borderLayout3);
    mainPanel.setLayout(borderLayout4);
    topPanel = new Panel_Top();
    mainPanel.add(topPanel, BorderLayout.NORTH);
    menuPanel = new Menu_Panel();
    dataPanel = new DataPanel();
    setMenuItems();
    contentPane = (JPanel)this.getContentPane();
    contentPane.setLayout(borderLayout1);
    this.setSize(new Dimension(900, 600));
    this.setTitle("Frame Title");
    jMenuFile.add(jMenuFileExit);
    jMenuHelp.add(jMenuHelpAbout);
    jMenuBar1.add(jMenuFile);
    jMenuBar1.add(jMenuHelp);
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.add(menuPanel, BorderLayout.WEST);
    mainPanel.add(topPanel, BorderLayout.NORTH);
    mainPanel.add(dataPanel, BorderLayout.CENTER);
    mainPanel.revalidate();
    this.setJMenuBar(jMenuBar1);
    fontResize();
    menuPanel.setDataPanel(dataPanel);   // This is where the Menu_Panel calls the show of DataPanel This is from the Menu_Panel at which point fires the menuPanel.setDataPanel(dataPanel); in the Command Class.
/** Required by TreeSelectionListener interface. */
  public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)
        tree.getLastSelectedPathComponent();
    if (node != null) {
      fromMenu = tree.getLastSelectedPathComponent().toString();
      checkMenuNames ();
public void checkMenuNames (){
  if(fromMenu.equals("Client")){
          dataPanel.showClient();
}This is the DataPanel Class
public class DataPanel
    extends JPanel {
  private DataClient dataClient;
  public void showClient() {
    //  dClient = new Data_Client();
if (dataClient == null){
  System.out.println("This worked");
dataClient = new DataClient();
this.add(dataClient);
}and this is the DataClient class
public class DataClient  extends JPanel{
  XYLayout xYLayout1 = new XYLayout();
  JLabel jLabel1 = new JLabel();
  public DataClient() {
    try {
      jbInit();
    catch(Exception e) {
      e.printStackTrace();
  private void jbInit() throws Exception {
    jLabel1.setText("This is Client");
    this.setLayout(xYLayout1);
    this.add(jLabel1,    new XYConstraints(110, 95, 179, -1));
}Hope you can help me :)
Craig

Similar Messages

  • Report painter performance problem...

    I have a client which runs a report group consists of 14 reports... When we  run this program... It takes about 20 minutes to get results... I was assigned to optimize this report...
    This is what I've done so far
    (this is a SAP generated program)...
    1. I've checked the tables that the program are using... (a customized table with more than 20,000 entries and many others)
    2. I've created secondary indexes  to the main customized table with (20,000) entries - It improves the performance a bit(results about 18 minutes)...
    3. I divided the report group by 4... 3 reports each report group... It greatly improves the performance... (but this is not what the client wants)...
    4. I've read an article about report group performance that it is a bug. 
    (sap support recognized the fact that we are dealing with a bug in the sap standard functionality)
    http://it.toolbox.com/blogs/sap-on-db2/sap-report-painter-performance-problem-26000
    Anyone have the same problem as mine?
    Edited by: christopher mancuyas on Sep 8, 2008 9:32 AM
    Edited by: christopher mancuyas on Sep 9, 2008 5:39 AM

    Report painter/Writer always creates a prerformance issue.i never preffred them since i have a option with Zreport
    now you can do only one thing put more checks on selection-screen for filtering the data.i think thats the only way.
    Amit.

  • Painting on JPanel problem

    i am new in java and im practicing on GUI...
    i wrote this stupid GUI that draw shapes on a JPanel, when i minimize the window and maximize again shapes disapear, i have been told to use the paintComponent( ) instead of getGraphics( ) but i didnt know how since my program is made out of two class...
    i will provide the code so please help a newbie
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.awt.image.RasterFormatException;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    public class can extends JFrame {
        private JPanel pic = new JPanel();
        private JButton b1 = new JButton("Clear");
        private JButton b2 = new JButton("Quit");
        private JButton b3 = new JButton("Save");
        private JRadioButton r, c, s;
        private JPanel p = new JPanel();
        public can() {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(800, 600);
            setTitle("Shape Drawer");
            setLayout(new BorderLayout());
            pic.setBackground(Color.white);
            pic.addMouseListener(new locationListener());
            this.add(pic, BorderLayout.CENTER);
            this.add(b1, BorderLayout.WEST);
            this.add(b2, BorderLayout.EAST);
            this.add(b3, BorderLayout.SOUTH);
            b1.addActionListener(new clearListener());
            b2.addActionListener(new quitListener());
            b3.addActionListener(new saveListener());
            r = new JRadioButton("rectangle");
            c = new JRadioButton("circle");
            s = new JRadioButton("square");
            ButtonGroup bg = new ButtonGroup();
            bg.add(r);
            bg.add(c);
            bg.add(s);
            r.setSelected(true);
            p.add(r);
            p.add(c);
            p.add(s);
            this.add(p, BorderLayout.NORTH);
        private class saveListener implements ActionListener {
             * Invoked when an action occurs.
            public void actionPerformed(ActionEvent e) {
                saveFile();
        private class clearListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                clear();
        private class quitListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                quit();
        private class locationListener implements MouseListener {
            public void mouseClicked(MouseEvent e) {
                shapes shape = new shapes();
                Graphics g = pic.getGraphics();
                if (r.isSelected()) {
                    shape.rect(g, e.getX() - 30, e.getY() - 20);
                if (c.isSelected()) {
                    shape.circles(g, e.getX() - 25, e.getY() - 25);
                if (s.isSelected()) {
                    shape.squares(g, e.getX() - 25, e.getY() - 25);
             * Invoked when a mouse button has been pressed on a component.
            public void mousePressed(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
             * Invoked when a mouse button has been released on a component.
            public void mouseReleased(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
             * Invoked when the mouse enters a component.
            public void mouseEntered(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
             * Invoked when the mouse exits a component.
            public void mouseExited(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
        private void quit() {
            System.exit(0);
        private void clear() {
            pic.repaint();
        private void saveFile() {
            int count = 1;
            String fileName = "picture.jpeg";
            File file = new File(fileName);
            if (file.exists()) {
                System.out.println("hello motto");
                fileName = "picture"+count+".jpeg";
                System.out.println(fileName);
                count++;
                System.out.println(count);
            pic = (JPanel) getContentPane();
            int w = pic.getWidth();
            int h = pic.getHeight();
            BufferedImage image = (BufferedImage) pic.createImage(w, h);
            Graphics g = image.getGraphics();
            if (g.getClipBounds() != null) {
                g.setClip(0, 0, w, h);
            pic.paint(g);
            try {
                FileOutputStream out = new FileOutputStream(file);
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                encoder.encode(image);
                out.flush();
                out.close();
            } catch (IOException ioe) {
            catch (RasterFormatException rfe) {
        public static void main(String[] args) {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception e) {
                System.out.println("ERROR: " + e);
            can c = new can();
            c.setVisible(true);
    }this was the first class and this is the second class that define the shapes
    import java.awt.*;
    public class shapes {
        public void squares(Graphics g, int x, int y) {
            g.setColor(Color.BLUE);
            g.fillRect(x, y, 50, 50);
        public void rect(Graphics g, int x, int y) {
            g.setColor(Color.RED);
            g.fillRect(x, y, 60, 40);
        public void circles(Graphics g, int x, int y) {
            g.setColor(Color.GREEN);
            g.fillOval(x, y, 50, 50);
    }i dunno how and where to implement the paintComponent( ) in this situation , please help me... and im also having another problemin the saveFile( ) method in the can class, it doesnt increment the naming of the file if it already exists...
    please help me...

    Hey, there were a few design issues in your code so I hope you dont mind me re-coding a few section of it to bring out the usage of the paintComponent(Graphics g) method.
    Also, the save was not working correctly because of the localization of the variables count and filename. I moved them and them global it to work. Also you had to re-create the file instance in order for it to be saved correctly with the new name.
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    public class Can extends JFrame {
        private JPanel p = new JPanel();
        private JButton b1 = new JButton("Clear");
        private JButton b2 = new JButton("Quit");
        private JButton b3 = new JButton("Save");
        private JRadioButton r, c, s;
        private PicturePanel pic = new PicturePanel();  
        private boolean shdClear = false;
        public Can() {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(800, 600);
            setTitle("Shape Drawer");
            setLayout(new BorderLayout());          
            JPanel buttonPanel = new JPanel();
                buttonPanel.add(b1);
                buttonPanel.add(b2);
                buttonPanel.add(b3);
            b1.addActionListener(new clearListener());
            b2.addActionListener(new quitListener());
            b3.addActionListener(new saveListener());      
            r = new JRadioButton("rectangle");       
            c = new JRadioButton("circle");
            s = new JRadioButton("square");       
            r.setSelected(true);
            p.add(r);
            p.add(c);
            p.add(s);
            ButtonGroup bg = new ButtonGroup();
                bg.add(r);
                bg.add(c);
                bg.add(s);
            getContentPane().add(pic, BorderLayout.CENTER);
            getContentPane().add(buttonPanel, BorderLayout.SOUTH );
            getContentPane().add(p, BorderLayout.NORTH);
        public class PicturePanel extends JPanel implements MouseListener {
            Shapes shape = new Shapes();
            MouseEvent e = null;
            BufferedImage backgroundImage = null;
            public PicturePanel() {
                super();
                setBackground(Color.white);
                addMouseListener(this);
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                if(e == null) {
                    return;
                if(shdClear) {
                    backgroundImage.getGraphics().dispose();
                    backgroundImage = null;
                if(backgroundImage == null) {
                    backgroundImage = new BufferedImage( getWidth(), getHeight(),
                        BufferedImage.TYPE_INT_RGB );
                    Graphics g2 = backgroundImage.getGraphics();
                        g2.setColor( getBackground() );
                        g2.fillRect(0,0, getWidth(), getHeight());
                    // added here for performance reasons
                    // could have been added above in the if(shdClear) section 
                    if(shdClear) {
                        shdClear = false;
                        return;
                Graphics g2 = backgroundImage.getGraphics();
                if (r.isSelected()) {
                    shape.rect(g2, e.getX() - 30, e.getY() - 20);
                if (c.isSelected()) {
                    shape.circles(g2, e.getX() - 25, e.getY() - 25);
                if (s.isSelected()) {
                    shape.squares(g2, e.getX() - 25, e.getY() - 25);
                if(backgroundImage != null) {
                    g.drawImage(backgroundImage, 0, 0, this);
            public void mouseClicked(MouseEvent e) {
                this.e = e;
                pic.repaint();
             * Invoked when a mouse button has been pressed on a component.
            public void mousePressed(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
             * Invoked when a mouse button has been released on a component.
            public void mouseReleased(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
             * Invoked when the mouse enters a component.
            public void mouseEntered(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
             * Invoked when the mouse exits a component.
            public void mouseExited(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
        private class saveListener implements ActionListener {
             * Invoked when an action occurs.
            public void actionPerformed(ActionEvent e) {
                saveFile();
        private class clearListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {           
                clear();
        private class quitListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                quit();
        private void quit() {
            System.exit(0);
        private void clear() {
            shdClear = true;
            pic.repaint();
        int count = 1; // moved so as not be recreated each time
        String fileName = "picture.jpeg";
        private void saveFile() {
            File file = new File(fileName);
            while (file.exists()) {
                System.out.println("hello motto");
                fileName = "picture" + count + ".jpeg";
                System.out.println(fileName);
                count++;
                System.out.println(count);
                file = new File(fileName); // recreate the file
            //pic = (JPanel) getContentPane();
            int w = pic.getWidth();
            int h = pic.getHeight();
            BufferedImage image = (BufferedImage) pic.createImage(w, h);
            Graphics g = image.getGraphics();
            if (g.getClipBounds() != null) {
                g.setClip(0, 0, w, h);
            pic.paint(g);
            try {
                FileOutputStream out = new FileOutputStream(file);
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                encoder.encode(image);
                out.flush();
                out.close();
                JOptionPane.showMessageDialog(null, fileName + " Saved", "File Saved",
                JOptionPane.INFORMATION_MESSAGE);
            } catch (IOException ioe) {
            } catch (RasterFormatException rfe) {
        public static void main(String[] args) {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception e) {
                System.out.println("ERROR: " + e);
            Can c = new Can();
            c.setVisible(true);
    class Shapes {
        public void squares(Graphics g, int x, int y) {
            g.setColor(Color.BLUE);
            g.fillRect(x, y, 50, 50);
        public void rect(Graphics g, int x, int y) {
            g.setColor(Color.RED);
            g.fillRect(x, y, 60, 40);
        public void circles(Graphics g, int x, int y) {
            g.setColor(Color.GREEN);
            g.fillOval(x, y, 50, 50);
    }ICE

  • Jsp and JPanel problem

    Hello. I've been to this forum many times, but have always been a bit gunshy about posting anything of my own. Now I have a problem I haven't seen before, so here goes. I have a JPanel in a java program that has all sorts of other componants added to it. I am trying to display the whole thing in a jsp page. This is what I am doing in the java file to return the image ("display" is the JPanel):
    public byte[] getImage(){
        int w = display.getWidth();
        int h = display.getHeight();
        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        display.paint(img.createGraphics());
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        ImageIO.write(img, "jpeg", os);
        return os.toByteArray();
    }and then in the jsp page I say:
    <%@ page contentType="image/jpeg" %>
    <%@ page import="myPackage.MyClass" %>
    <%
         MyClass picture = new MyClass();
         byte[] b = picture.getImage();
         OutputStream os;
         os = response.getOutputStream();
         os.write(b);
         os.flush();
    %>And the problem is that the page is displaying a blank JPanel and none of the componants that were added to it. If I save the the JPanel as a jpeg in the java program, though, it does contain all the componants, so I am not sure what I am doing wrong here. If there is some way to get the all the JPanel componants returned, that would be great to know. Thanks for any help.

    nope, that didn't work.
    Maybe I am going about solving the problem all wrong. The JPanel and its componants are kind of like a template. When a user of the system submits their information it automatically puts the data into the template and displays it on screen as a jpg. It works when I save the jpg as a file from the java program but not when i send the byte array to the jsp server. It just shows the blank panel....
    Is there a better way to go about doing this?

  • Urgent- Printing JPanel problem

    I want to print a JPanel by calling a Print utility class. JPanel is drawing with different shapes (Rectangle2D etc..)
    The problem is that I can only print the first page of the JPanel.
    My Print utility:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.print.*;
    public class PrintUtilities {
    private Component componentToBePrinted;
    public static void printComponent(Component c) {
    new PrintUtilities(c).print();
    public PrintUtilities(Component componentToBePrinted) {
    this.componentToBePrinted = componentToBePrinted;
    public void print() {
    PrinterJob printJob = PrinterJob.getPrinterJob();
    BookComponentPrintable printable1 = new BookComponentPrintable(componentToBePrinted);
    PageFormat pageFormat1 = printJob.pageDialog(printJob.defaultPage());
    Book book = new Book();
    book.append(printable1, pageFormat1);
    // Print the Book.
    printJob.setPageable(book);
    if (printJob.printDialog())
    try {
    printJob.print();
    } catch(PrinterException pe) {
    System.out.println("Error printing: " + pe);
    class BookComponentPrintable
    implements Printable {
    private Component mComponent;
    public BookComponentPrintable(Component c) {
    mComponent = c;
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
    if (pageIndex > 0) {
    return(NO_SUCH_PAGE);
    else
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    mComponent.paint(g2);
    return Printable.PAGE_EXISTS;
    What did I do wrong? Thanks in advance !!!

    Oh... it's just a mistake because of copy and paste.
    I did also have these code (without if (pageIndex > 0) {
    return(NO_SUCH_PAGE); ) but with these
    /* calculate the no. of pages to print */
    int totalNumPages = (int)Math.ceil((panelHeight) /
    height );
    if (pageIndex >= totalNumPages) return NO_SUCH_PAGE;
    and when I use :
    System.out.println("totalNumPages: " + String.valueOf(totalNumPages));
    I can see at there are two pages. But when it prints it can only print one. So...

  • Help!!! Please!!! jPanel problem.....

    Hi,
    I have MainFrame that contains jPanel1. ANd jPanel1 contains jPanel2, jPanel3, jPanel4.
    My problem is with jPanel2. jPanel2 contains jScrollPane.
    Let me just give tell you what i am doing.
    I wrote something which gets the image from database & displays the Multipage Tiff IMages in
    jScrollPane which is in jPanel2. I also have something which zooms the image from 10% to 120%.
    When i zoom the image to 30% the image is shown with only Vertical Scroll Bars. The image looks fine
    the first time its loaded. But when i move the vertical scroll bar the outside the image portion is shown
    with white and gray small areas each time i move the scroll bar.
    But when i zoom the image to 50% the image is shown with both scroll bars. SO when i scroll down or sideways
    I have no problem.
    Its only when i have vertical scroll bars.
    I have done repaint and validate on jPanel2 & jScrollPane but noting was solved.
    Any help or suggestions are always appreciated.
    Thanks in advance.

    Make sure you are calling invalidate() and validate() prior to the repaint. And since you are using a JPanel, try calling revalidate() as well. When ever I run into paint problems I just use trial an error on those 3 calls along with repaint() untill I find a combination that works. I really should spend 5 minutes figuring out which order to make these calls in and when but I have yet to do that :-(
    Bryan

  • A strange JPanel problem

    i have a JPanel which have a picture as a background the problem is when i wnat to add a JLabel or JTextField into this JPanel it didnt word but it works for labels bat JLabels no???why??
    here u are the code
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class d extends Container
        JTextField text1,text2,text3,text4,text5,text6;
         ImageIcon icon ;
       public d()
    {  super();
       setLayout(null );                                                                         
        setBackground(Color.RED);                                                                                                 
        text1=new JTextField();
       text2=new JTextField();
       text3=new JTextField();
       text4=new JTextField();
       text5=new JTextField();
        text6=new JTextField();
        panel p=new panel();
       p.setBounds(10,10,500,500);
         p.setLayout(null);
         p.setOpaque(true);
    p.setBackground(Color.WHITE);
    text1.setBounds(160,30,100,20);
    p.add(text1);
    text2.setBounds(10,30,100,20);
      p.add(text2);
      text3.setBounds(300,30,100,20);
      p.add(text3);
      text4.setBounds(10,100,100,20);
      p.add(text4);
    text5.setBounds(160,100,100,20);
      p.add(text5);
      text6.setBounds(300,100,100,20);
      p.add(text6);
    JLabel l1=new JLabel("touti");
    l1.setBackground(Color.WHITE);
      l1.setBounds(10,10,80,15);
      add(p);
       class panel extends JPanel
           public  void paint(Graphics g) {
           super.paint(g);
           icon=new ImageIcon("c:/bachir.jpg");
            g.drawImage(icon.getImage(),0,0, this);
    public static void main(String args[])
       JFrame frm = new JFrame( "test panel back ground" );
            frm.setBounds( 100, 100, 800, 800 );
            frm.getContentPane().setLayout( new BorderLayout() );
        d pnl=new d();
            frm.getContentPane().add(pnl , BorderLayout.CENTER );
      frm.setIconImage(Toolkit.getDefaultToolkit().getImage("c:/java/oicon.gif"));
            frm.setVisible( true );
    }

    You seem to be mixing AWT and Swing. You should use all AWT or all Swing but not a mixture. Try changing
    public class d extends Container
    to
    public class d extends JPanel.
    P.S. Your choice of class name stinks! It does not describes the role the class plays and it does not meet the Sun recommended coding standards.
    Message was edited by:
    sabre150

  • Painting JPanels and graphics

    I have a JPanel into which want to display boxes of data connected by lines. The boxes are JPanels (with a ScrollPane and JList) and the lines simply Graphics2D objects. I have overridden the paint(g) method of the enclosing panel to call super.paint(g) followed by my graphics calls. This works fine on start-up and repaint (from maximizing), but when I resize the main panel, the middle of the panel doesn't show the graphics (the inner panels display fine). I think I see the graphics being drawn then erased, but I'm not sure. Reviewing the Painting in AWT and Swing articles hasn't helped. I've tried various versions of paintComponent(), paintChildren(), etc. as alternatives, but the problem remains (or I never see the graphics at all). This seems like a timing and clipping problem but I can't figure it out. Can anyone explain what resize is doing that is different than a normal paint? How should one combine JPanels and graphics?Thanks.

    Unfortunately, overriding paintComponent() causes the graphics to be completely over-written for some reason. The problem is apparently when the inner Panels are written (I guess by paintChildren()). I'm following the directions in Doing Without a Layout Manager in the Java Tutorial: setting the outer JPanel's layout to null, explicitly setting the bounds of the inner JPanels and overwriting paint() with super.paint() (which paints the inner panels correctly) followed by my graphics code. All is well until I resize.
    Now the Doing Without a Layout Manager page states "However, creating containers with absolutely positioned containers can cause problems if the window containing the container is resized." Guess they're right ;-) Anyone know how to get around this problem?

  • Report Painter Execution Problem

    Hi,
    I am working on Report Painter in which i am facing a problem that when i execute the Tcode GR55 and fill the Group Name in it ,if there is only 1 report in it ,it gets executed but when there are more than 1 report in it ,some times it gets executed ot sometimes it does not.
    I want to know how can i execute a selected indiviual report when there are about number of reports present in the library assigned to that group.
    Please provide me guidelines for solving this  problem.
    Edited by: ricx .s on Jul 24, 2009 10:10 AM

    Hi,
    The reports in a report group are executed at the same time, so that in the report display you can switch between the individual reports.
    Thanks.

  • JPanel problem

    I have two JPanels in an applet window. I have attached a mouse event handler to the second JPanel, such that it repaints itself when clicked, or when the mouse moves within it. Trouble is, the contents of the first JPanel(a bunch of JCheckboxes) get painted to the second Panel, before the results of paint() are drawn on top. Why does it do this?

    if(evt.getSouce() == Button2) {
    remove(myCheckBox);
    - and doOtherThings
    Checkboxes and textFields have a higher order priority

  • Screen Painter PM01 problem

    Hello,
    when I create new Infotype in PM01 and generate ALL everything is ok. In PA30 I can use this IT. But...
    there is a problem when I try to change Layout in a Screen Painter. When I click Layout all fields dissapears (there are only description).
    Edited by: OsTrY on Sep 15, 2010 12:22 PM

    Hi,
    I haven't encountered this problem before even though I have worked with PM01 quite a bit over the years. Can you desrcibe a a bit more about your proplem please? Especially whether your screen element list looks OK and whether the problem exists regardless of old or new screen painter for layouting.
    Cheers,
    Philipp

  • Printing jpanel problem

    So I am trying to print a JPanel. When I print to a pdf after bringing up a page setup dialog and a print dialog, either one of two things is happening.
    1) all drawn lines are shifted down and to the right.
    or
    2) all text is shifted up and to the left.
    Everything on the screen of the program looks great. I think it might have something to do with the fact that I am deriving fonts by scaling them. This would not be a problem if everything was shifting. It is clear that when rendered to a pdf it is handling the text of the fonts that I am using somehow differently than all the lines I am drawing. I do not understand why this is happening. Everything looks so good on the screen.
    If anybody knows what this problem is, your help would be much appreciated.
    Thanks in advance!

    Oh... it's just a mistake because of copy and paste.
    I did also have these code (without if (pageIndex > 0) {
    return(NO_SUCH_PAGE); ) but with these
    /* calculate the no. of pages to print */
    int totalNumPages = (int)Math.ceil((panelHeight) /
    height );
    if (pageIndex >= totalNumPages) return NO_SUCH_PAGE;
    and when I use :
    System.out.println("totalNumPages: " + String.valueOf(totalNumPages));
    I can see at there are two pages. But when it prints it can only print one. So...

  • 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....
    :)

  • 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.

Maybe you are looking for