Hi Experts,
I have question on the bellow program (runs perfectly),
1. As I have created an instance (object) of startup class and we dint called method paint from the main method using the object but still it is called (how?). But in case of Instantiable classes, we need to call any method explicitly using the created object.
2. Is there any standard sheet to do rough calculation of frame locations? It is bit confusing, because my window resolution is 1024*768 and my frame size is differs. Whatever location measurement we do with frames: Is it depends on Window resolution or Frame resolution?

Thanks in advance for any help!

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import java.io.File;
import java.util.Enumeration;
import java.util.Set;

public class TestSheet 
    public static void main(String args[]) throws Exception
        File f = new File("F://my study material//DemoFiles//DemoTXT.txt");
        FileOutputStream fout = new FileOutputStream("F://my study material//DemoFiles//DemoTXT2.txt", true);
        FileInputStream fis = new FileInputStream(f);
        Properties p = new Properties();
        Enumeration e = p.propertyNames();

            String key = (String)e.nextElement();
            System.out.println(key + " : \t" + p.getProperty(key));
        p.store(fout, "no comment");

        Set subject = p.keySet();

        for(Object name: subject)
            System.out.println(name+" : "+p.getProperty((String)name));

        String str = p.getProperty("Social Science", "No record");
        System.out.println("Marks obtain by social science: "+str);



Edited by peter_budo: Please DO NOT use Code Snippet for posting questions. Use FORUM THREAD!

6 Years
Discussion Span
Last Post by jiten_raulo

Extremely sorry, I have made a mistake. mistakenly posted the wrong code!
Here the correct code:

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Color;

public class DrawOnFrame extends Frame
        this.addWindowListener(new WindowAdapter()
            public void windowClosing(WindowEvent e)
    public void paint(Graphics g)
        //set blue color for drawing

        //displaya rectangle to contain drawing
        g.drawRect(40, 40, 200, 200);

        //draw face
        g.drawOval(90, 70, 80, 80);

        g.drawOval(110, 95, 5, 5);
        g.drawOval(145, 95, 5, 5);

        g.drawLine(130, 95, 130, 115);


    public static void main(String args[])
        //create the frame
        DrawOnFrame d = new DrawOnFrame();

        //set title, size and visibility
        d.setTitle("My Frame");
        d.setSize(400, 400);



The paint() method is called by setVisible(), and since you called setVisible(), paint was called indirectly. As far as your other question, you'll need to clarify what you mean: are you trying to figure out how large your monitor is and make the Frame cover the entire monitor?


mean, when we work on frame or applet we give locations(x and y coordinates, width, heigth etc.) for components, containers (buttons, checkboxes, radiobotton, text input area etc.. My questions is when when working with such things is that we have to imagine the location and assign or is there a standard sheet to do rough drawing ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.