Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] Stretch

I am using a JLabel with his picture and no caption.

Is it a bad way to do that ? why ?


see my code:

private void initialize() {
       
        this.setContentPane(getJContentPane());
        this.setSize(this.w,this.h);
        this.setTitle("Image View");

    }


private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            JLabel labelPic = new JLabel();
            GridLayout gridLayout = new GridLayout();
            gridLayout.setRows(1);
            jContentPane.setLayout(gridLayout);
            Icon theIcon = getIcon(HyperLinkCursorToolPlugIn.getPathToIcon());
            this.h = theIcon.getIconHeight();
            this.w = theIcon.getIconWidth();           
            labelPic.setIcon(theIcon);
            jContentPane.add(labelPic);
        }
        return jContentPane;
    }



Sincerely...
Ezequias


Joe Winchester wrote:

Hi Ezequias,

Try painting the image onto a JPanel and then stretching it in the paint(Graphics g) method.  For the following code I subclassed JFrame and then changed the content pane as follows.

private JPanel getJContentPane() {
                if (jContentPane == null) {
                        image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/foo/views/sample.gif"));                        
                        jContentPane = new JPanel(){
                                public void paint(Graphics g) {                                        
                                        super.paint(g);
                                        g.drawImage(image,0,0,jContentPane.getSize().width,jContentPane.getSize().height,this);
                                }
                        };
                        jContentPane.setLayout(new BorderLayout());
                }
                return jContentPane;
        }

Best regards,

Joe

Please respond to Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>

Sent by:        ve-dev-bounces@xxxxxxxxxxx

To:        Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>
cc:        
Subject:        [ve-dev] Stretch


    Hi list,

Could anybody tell me how to stretch an ImageIcon on a JFrame ?

I add a Jlabel to a GridLayout but it does not stretch correctly.

Best regards
Ezequias
_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


_______________________________________________ ve-dev mailing list ve-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/ve-dev

-- 
Ezequias Rodrigues da Rocha
http://ezequiasrocha.blogspot.com
msn:ezequias@xxxxxxxxxxx

Back to the top