Results 1 to 2 of 2
  1. #1
    Yakkut is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Default Need help in Graphics2D

    Hi guys, its my first time here. I need help to solve a problem im having with my program.

    Its a simple program that draws some figures on the screen accordinly to the info the user provides.

    My problem is that, when the user clicks on the button "Draw", it is suposed to get the numbers in the textfield, convert them to double, then use these numbers to draw the pictures...

    When the button is clicked, it only shows a white dot on the center of the screen.

    Here is the code of the main Frame:


    public class Wallpaper extends JFrame {

    public Wallpaper() { //Frame
    setTitle("Wallpapers");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setResizable(false);
    setSize(1024, 700);
    Container tela = getContentPane();
    setLayout(null);
    setLocationRelativeTo(null);

    //Textfield
    //Retangulo
    colunaRetangulo = new JTextField("");
    colunaRetangulo.setBounds(300,90,50,20);
    colunaRetangulo.setVisible(true);

    //(the others textfields are exactly like this one above, only titles and positions differ)

    //Retangulo
    tela.add(colunaRetangulo);

    botao1.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    if (retangulo.isSelected() == true && elipse.isSelected() == true && linha.isSelected() == true){

    colunaRV = Double.parseDouble(colunaRetangulo.getText());
    linhaRV = Double.parseDouble(linhaRetangulo.getText());
    larguraRV = Double.parseDouble(larguraRetangulo.getText());
    comprimentoRV = Double.parseDouble(comprimentoRetangulo.getText()) ;

    RELJFrame jframeREL = new RELJFrame();
    jframeREL.setVisible(true);

    }


    When i click the button, it is supposed to show this panel:


    public class REL extends JPanel {
    Wallpaper jframeWallpaper = new Wallpaper();

    public Rectangle2D r(){
    return new Rectangle2D.Double(jframeWallpaper.colunaRV,jframe Wallpaper.linhaRV,jframeWallpaper.larguraRV,jframe Wallpaper.comprimentoRV);
    }



    This is the JFrame where the REL panel is:

    {code} public class REJFrame extends JFrame{

    public REJFrame(){
    add(new RE());
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setTitle("RE");
    setResizable(false);
    setVisible(true);
    setSize(800,600);
    setLocationRelativeTo(null);
    }
    public static void main (String [] args){
    new REJFrame();
    }
    }{code}

    No errors being returned. Whats wrong with it? Can someone explain to me?

    Thanks guys
    Last edited by Yakkut; 03-30-2011 at 07:53 PM. Reason: Correcting

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    First, code tags == readible code. (see Java Forums - BB Code List ). Second, I'd suggest posting an SSCCE - this doesn't look like full code, and where do you even do the drawing?

Similar Threads

  1. Java Graphics2D Problem
    By stevokk in forum Java 2D
    Replies: 9
    Last Post: 02-18-2011, 09:35 PM
  2. Graphics2D repaint bug
    By NextEpisode1 in forum Java 2D
    Replies: 10
    Last Post: 02-10-2011, 01:50 PM
  3. graphics to graphics2d casting
    By rocklikeits99 in forum New To Java
    Replies: 2
    Last Post: 09-22-2010, 04:12 AM
  4. Graphics2D setRenderingHint not working
    By Crazy Caveman in forum Java 2D
    Replies: 2
    Last Post: 08-27-2010, 07:47 PM
  5. Graphics2D: stack overflow error
    By rosh72851 in forum New To Java
    Replies: 11
    Last Post: 10-15-2008, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •