Shivaay Bhatnagar - Study24x7
Social learning Network
Shivaay Bhatnagar Cover image
Shivaay Bhatnagar
Shivaay Bhatnagar
Connections 15
Followers 15
Following 16
study24x7Shivaay Bhatnagar

Shivaay Bhatnagar

Studied Btech at Kakinada Institute of Engineering & Technology, Kiet, Korangi, Yanam Road, Kakinada.PIN-533461 (CC-B2) (Id: C-17992)
Live in Meerut,India, Uttar Pradesh
  • Profile
  • About
  • Connections
About

Here is an applet that displays just one small button on the page. When you clic...
See More

The window in this example belongs to a class named ShapeDrawFrame, which is defined as a subclass of Frame. The applet creates the window with the statementshapeDraw = new ShapeDrawFrame();The constructor sets up the structure of the window and makes the window appear on the screen. Once the window has been created, it runs independently of the applet and of any other windows. Of course, there can be some communication through shared variables, method calls, and events. In the sample applet above, for example, the name of the button changes from "Launch ShapeDraw" to "Close ShapeDraw" while the window is open. If the user clicks on the "Close ShapeDraw" button, the applet responds by closing the window. This is done by calling an appropriate method in the window object. On the other hand, if the user closes the window by clicking on its close box, an event is generated belonging to the class WindowEvent. The applet listens for such events so that it can change the name of the button back to "Launch ShapeDraw" when the window is closed. (You might be interested to see how all this is handled in the source code for the applet. You can find it in the file ShapeDrawLauncher.java.)Fortunately, you don't have to learn a lot of new material to use frames. There are a few specialized methods in the Frame class that you should know about. You'll want to know how to use pull-down menus and menu bars. And there are a few important events that are generated by windows. Aside from that, programming with frames is the same as programming with applets. Many of the new features show up in the constructor for the ShapeDrawFrame class, so let's take a look at that: public ShapeDrawFrame() { // Constructor. Create and open the window. The window // has a menu bar containing two menus, "Add Shape" and // "Color". The content of the window is a canvas belonging // to the class ShapeCanvas. setBackground(Color.white); /* Set window title by calling the superclass constructor. */ super("Shape Draw"); /* Create a canvas that fills the frame. */ canvas = new ShapeCanvas(); add(canvas, BorderLayout.CENTER); /* Create pull-down menus and a menu bar. The frame listens for ActionEvents from the menus. These are generated when the user selects commands from the menus. */ Menu colorMenu = new Menu("Color", true); // Color choice menu. colorMenu.add("Red"); colorMenu.add("Green"); colorMenu.add("Blue"); colorMenu.add("Cyan"); colorMenu.add("Magenta"); colorMenu.add("Yellow"); colorMenu.add("Black"); colorMenu.add("White"); colorMenu.addActionListener(this); Menu shapeMenu = new Menu("Add Shape", true); // Shape menu. shapeMenu.add("Rectangle"); shapeMenu.add("Oval"); shapeMenu.add("Round Rect"); shapeMenu.addActionListener(this); MenuBar mbar = new MenuBar(); // Create menu bar and add the menus. mbar.add(shapeMenu); mbar.add(colorMenu); setMenuBar(mbar); // Add the menu bar to the frame. /* Do the remaining setup and show the window. */ setBounds(30,50,380,280); // Set size and position of window. setResizable(false); // Make the window non-resizable. addWindowListener( new WindowAdapter() { // A listener that will close the window // when the user clicks its close box. public void windowClosing(WindowEvent evt) { ShapeDrawFrame.this.dispose(); } } ); // end addWindowListener statement show(); // Make the window visible. } // end constructor

11 Jan 2021 02:15 PM study24x7 study24x7

The window in this example belongs to a class named ShapeDrawFrame, which is defined as a subclass of Frame. The applet creates the window with the statementshapeDraw = new ShapeDrawFrame();The constructor sets up the structure of the window and makes the window appear ...

See more

study24x7
Write a comment

06 Mar 2021 11:58 AM study24x7 study24x7

Restaurant groups (ONLY USE IF APPLICABLE)We may share your information (such as meal or seating preferences and special occasions) with other restaurants in the same restaurant group. This is to enhance the hospitality experience that we (the restaurant group) provide you when y...

See more

study24x7
Write a comment
Shivaay Bhatnagar shared post from Class 12Th Guide

29 Dec 2020 01:27 PM study24x7 study24x7

What are the Tri- equilibrium factors of human geography?

study24x7
Write a comment

19 Oct 2020 12:41 PM study24x7 study24x7

Which testing is performed first

A

Smoke

B

Sanity

C

Depending upon one can selected first for execution

D

Simultaneously

study24x7
Write a comment
29 Dec 2020 03:24 PM study24x7 study24x7

Which of the following is not a Java features?

A

Dynamic

B

Architecture Neutral

C

Use of pointers

D

Object oriented

study24x7
Write a comment
28 Dec 2020 02:02 PM study24x7 study24x7

https://youtu.be/Y8ME2PKtit4This is current affairs note link

study24x7
Write a comment

20 Oct 2020 01:43 PM study24x7 study24x7

The year in which HTML was first proposed _______.

A

1990

B

1980

C

2000

D

1995

study24x7
Write a comment
20 Oct 2020 01:43 PM study24x7 study24x7

The year in which HTML was first proposed _______.

A

1990

B

1980

C

2000

D

1995

study24x7
Write a comment

20 Oct 2020 01:28 PM study24x7 study24x7

Fundamental HTML Block is known as HTML Tag

A

true

B

false

study24x7
Write a comment
20 Oct 2020 01:28 PM study24x7 study24x7

Fundamental HTML Block is known as HTML Tag

A

true

B

false

study24x7
Write a comment