Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2006

Tip: Looking for answers? Try searching our database.

help with GUI....

Thread view: 
rupeshgade@googlemail.com - 17 Dec 2006 06:33 GMT
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.
rupeshgade@googlemail.com - 17 Dec 2006 08:17 GMT
Hi All,
       Sorry for the trouble.i guess i got the answer for this one so
no need going through the code...now i have a different problem which i
will write as a new topic..

Thnx.

Rupesh.

> Hi All/all,
>
[quoted text clipped - 89 lines]
>
> Rupesh.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.