Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java GUI > somebody, pleas...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 9680 of 10019
Post > Topic >>

somebody, please help me make this program of mine work

by sundar.b.mani@[EMAIL PROTECTED] May 1, 2008 at 03:55 AM

it is supposed to draw an origin point and a line on a JInternalframe

it ain't doing that.

please spare your precious time and help me debug it.

knid regards, Sundar


package testapp;

im****t javax.swing.*;
im****t java.awt.Rectangle;
im****t java.awt.geom.Point2D;
im****t java.awt.geom.Point2D.Double;
im****t java.awt.Graphics;
im****t java.awt.Color;
im****t java.awt.Font;
im****t java.lang.*;
im****t java.lang.Integer;




public class TestApp extends javax.swing.JFrame
{

   /** Creates new form TestApp */
   public TestApp()
   {
       initComponents();
   }

   private void initComponents()//GEN-BEGIN:initComponents
   {
       //cenPanel = new javax.swing.JPanel();
       //cenPanel.setLayout(new java.awt.BorderLayout());
       //getContentPane().add(cenPanel, java.awt.BorderLayout.CENTER);
       desktop = new JDesktopPane();
       desktop.setLayout(new java.awt.BorderLayout());
       getContentPane().add(desktop, java.awt.BorderLayout.CENTER);
       jMenuBar1 = new javax.swing.JMenuBar();
       fileMenu = new javax.swing.JMenu();
       newFile = new javax.swing.JMenuItem();

       DrawMenu = new javax.swing.JMenu();
       Line = new javax.swing.JMenuItem();

 
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
       addWindowListener(new java.awt.event.WindowAdapter()
       {
           public void windowClosing(java.awt.event.WindowEvent evt)
           {
               exitForm(evt);
           }
       });

       fileMenu.setText("File");
       DrawMenu.setText("Draw");
       newFile.setText("New");
       newFile.addActionListener(new java.awt.event.ActionListener()
       {
           public void actionPerformed(java.awt.event.ActionEvent evt)
           {
               newFileActionPerformed(evt);
           }
       });
       jMenuBar1.add(fileMenu);
       jMenuBar1.add(DrawMenu);
       setJMenuBar(jMenuBar1);

       fileMenu.add(newFile);
       DrawMenu.add(Line);




       java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
       setBounds((screenSize.width-400)/2, (screenSize.height-300)/2,
400, 300);
   }

   private void newFileActionPerformed(java.awt.event.ActionEvent evt)
   {

           iframe = new JInternalFrame("Image Animator", true, true,
true, true);
           desktop.add(iframe, java.awt.BorderLayout.CENTER);
           //cenPanel.add(iframe, java.awt.BorderLayout.CENTER);
           Rectangle Rect = new Rectangle();

           Rect = iframe.getNormalBounds();
           int X_ULC = Rect.x;
           int Y_ULC = Rect.y;
           int Y_LLC = Y_ULC - Rect.height;

           Point2D.Double Origin = new Point2D.Double(X_ULC +
0.05*Rect.width, Y_LLC + 0.05*Rect.height);

           String OrigintoString = Origin.toString();
           Graphics Gr = iframe.getGraphics();
           Color C = new Color(255,255,255);
           Gr.setColor(C);
           int FrameWidth = Rect.width;
           int FrameHeight = iframe.getHeight();
           Integer intFW = new Integer(FrameWidth);
           Integer intFH = new Integer(FrameHeight);
           String widthinString = intFW.toString(FrameWidth);
           String heightinString = intFH.toString(FrameHeight);
           Gr.drawString(widthinString,X_ULC,Y_ULC);
           Gr.drawString(OrigintoString, (int)Origin.getX(),
(int)Origin.getY());
           Gr.drawLine(X_ULC,Y_ULC,X_ULC+Rect.width,Y_ULC-
Rect.height);
           iframe.setVisible(true);
   }

   private void exitForm(java.awt.event.WindowEvent evt)
   {
       System.exit(0);
   }

   public static void main(String args[])
   {
       TestApp TA = new TestApp();
       TA.setVisible(true);
   }

   private JInternalFrame iframe ;
   //private javax.swing.JPanel cenPanel;
   private javax.swing.JMenuBar jMenuBar1;
   private JDesktopPane desktop;
   private javax.swing.JMenu fileMenu;
   private javax.swing.JMenuItem newFile;
   private javax.swing.JMenu DrawMenu;
   private javax.swing.JMenuItem Line;

}
 




 5 Posts in Topic:
somebody, please help me make this program of mine work
sundar.b.mani@[EMAIL PROT  2008-05-01 03:55:54 
Re: somebody, please help me make this program of mine work
Roedy Green <see_websi  2008-05-01 11:12:13 
Re: somebody, please help me make this program of mine work
Roedy Green <see_websi  2008-05-01 11:15:28 
Re: somebody, please help me make this program of mine work
Roedy Green <see_websi  2008-05-01 11:17:47 
Re: somebody, please help me make this program of mine work
Roedy Green <see_websi  2008-05-01 11:19:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 21:21:14 CST 2008.