Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #408

help with GUI....

From rupeshgade@googlemail.com.remove-dii-this
Subject help with GUI....
Message-ID <1166337217.867800.212680@f1g2000cwa.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:27 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hi All/all,

I am new to java and just started GUI..I am having some problems with
GUI .I want to draw 2 rectangles in a GUI which are white
bordered...one below the other.I am not able to do so..I have written
the following code but it is not working i guess....

/*
 * HydrophobicityViewer.java
 *
 * Created on December 16, 2006, 10:05 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package myapplics;
import javax.swing.*;
import biomolecule.*;

/**
 *
 * @author rupesh
 */
public class HydrophobicityViewer {

    /** Creates a new instance of HydrophobicityViewer */
    public HydrophobicityViewer() {
    }
    public static void main(String []args)
    {
        JFrame frame=new JFrame();
        final int FRAME_WIDTH =400;
        final int FRAME_HEIGHT =500;
        frame.setSize(FRAME_WIDTH,FRAME_HEIGHT);

        RectangleComponent component = new RectangleComponent();
        frame.add(component);
        frame.setTitle("Hydrophobicity viewer");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }


}




/*
 * RectangleComponent.java
 *
 * Created on December 16, 2006, 10:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package biomolecule;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.Rectangle;
import javax.swing.JPanel;
import javax.swing.JComponent;

/**
 *
 * @author rupesh
 */
public class RectangleComponent extends JComponent{

    /** Creates a new instance of RectangleComponent */
    public RectangleComponent() {
    }
    public void paintComponent(Graphics g)
    {
        Graphics2D g2=(Graphics2D)g;
        Rectangle box=new Rectangle(100,100,120,20);
        g2.draw(box);
        g2.setColor(Color.WHITE);
        g2.draw(box);

        Rectangle box1=new Rectangle(100,120,120,20);
        g2.draw(box1);
        g2.setColor(Color.WHITE);
        g2.draw(box1);
    }


}


is there sny problem with my code??i am getting the frame window.The
problem is that of not getting the rectangles in them.....

Thnx for the help.

Rupesh.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

help with GUI.... rupeshgade@googlemail.com.remove-dii-this - 2011-04-27 15:27 +0000
  Re: help with GUI.... rupeshgade@googlemail.com.remove-dii-this - 2011-04-27 15:27 +0000

csiph-web