Question stringlengths 1 113 | Answer stringlengths 22 6.98k |
|---|---|
Can you provide the Java Transient Keyword? | If you don't want to serialize any data member of a class, you can mark it as transient.
Employee.java
class Employee implements Serializable{
transient int id;
String name;
public Student(int id, String name) {
this.id = id;
this.name = name;
}
}
Now, id will not be serialized, so when you d... |
Can you give me the SerialVersionUID? | The serialization process at runtime associates an id with each Serializable class which is known as SerialVersionUID. It is used to verify the sender and receiver of the serialized object. The sender and receiver must be the same. To verify it, SerialVersionUID is used. The sender and receiver must have the same Seria... |
What is Java transient Keyword? | In Java, Serialization is used to convert an object into a stream of the byte. The byte stream consists of the data of the instance as well as the type of data stored in that instance. Deserialization performs exactly opposite operation. It converts the byte sequence into original object data. During the serialization,... |
Why to use the transient keyword? | The transient keyword can be used with the data members of a class in order to avoid their serialization. For example, if a program accepts a user's login details and password. But we don't want to store the original password in the file. Here, we can use transient keyword and when JVM reads the transient keyword it ig... |
When to use the transient keyword? | 1)The transient modifier can be used where there are data members derived from the other data members within the same instance of the class.
2)This transient keyword can be used with the data members which do not depict the state of the object.
3)The data members of a non-serialized object or class can use a transient ... |
Can you provide an Example of Java Transient Keyword? | Let's take an example, we have declared a class as Student, it has three data members id, name and age. If you serialize the object, all the values will be serialized but we don't want to serialize one value, e.g. age then we can declare the age data member as transient.
In this example, we have created two classes St... |
What is Java Networking? | Java Networking is a concept of connecting two or more computing devices together so that we can share resources.
Java socket programming provides facility to share data between different computing devices.
|
What is the Advantage of Java Networking? | 1.Sharing resources
2.Centralize software management
The java.net package supports two protocols,
1.TCP: Transmission Control Protocol provides reliable communication between the sender and receiver. TCP is used along with the Internet Protocol referred as TCP/IP.
2.UDP: User Datagram Protocol provides a connection-l... |
What is Java Networking Terminology? | The widely used Java networking terminologies are given below:
1.IP Address
2.Protocol
3.Port Number
4.MAC Address
5.Connection-oriented and connection-less protocol
6.Socket
1) IP Address
IP address is a unique number assigned to a node of a network e.g. 192.168.0.1 . It is composed of octets that range from 0 to 25... |
What is java.net package? | The java.net package can be divided into two sections:
1. A Low-Level API: It deals with the abstractions of addresses i.e. networking identifiers, Sockets i.e. bidirectional data communication mechanism and Interfaces i.e. network interfaces.
2. A High Level API: It deals with the abstraction of URIs i.e. Universal R... |
What is Java Socket Programming? | Java Socket programming is used for communication between the applications running on different JRE.
Java Socket programming can be connection-oriented or connection-less.
Socket and ServerSocket classes are used for connection-oriented socket programming and DatagramSocket and DatagramPacket classes are used for con... |
What is Socket class? | A socket is simply an endpoint for communications between the machines. The Socket class can be used to create a socket.
Method: public InputStream getInputStream()
Description: returns the InputStream attached with this socket.
Method: public OutputStream getOutputStream()
Description: returns the OutputStream att... |
Can you provide the ServerSocket class? | The ServerSocket class can be used to create a server socket. This object is used to establish communication with the clients.
Method: public Socket accept()
Description: returns the socket and establish a connection between server and client.
Method: public synchronized void close()
Description: closes the server s... |
Can you provide an Example of Java Socket Programming? | Creating Server:
To create the server application, we need to create the instance of ServerSocket class. Here, we are using 6666 port number for the communication between the client and server. You may also choose any other port number. The accept() method waits for the client. If clients connects with the given port ... |
What is Java URL? | The Java URL class represents an URL. URL is an acronym for Uniform Resource Locator. It points to a resource on the World Wide Web.
A URL contains many information:
1.Protocol: In this case, http is the protocol.
2.Server name or IP Address: In this case, www.javatpoint.com is the server name.
3.Port Number: It is a... |
Can you give me the Constructors of Java URL class? | URL(String spec)
Creates an instance of a URL from the String representation.
URL(String protocol, String host, int port, String file)
Creates an instance of a URL from the given protocol, host, port number, and file.
URL(String protocol, String host, int port, String file, URLStreamHandler handler)
Creates an instan... |
Can you give me the Commonly used methods of Java URL class? | The java.net.URL class provides many methods. The important methods of URL class are given below.
Method: public String getProtocol()
Description: it returns the protocol of the URL.
Method:public String getHost()
Description: it returns the host name of the URL.
Method: public String getPort()
Description: it retur... |
Can you provide an Example of Java URL class? | //URLDemo.java
import java.net.*;
public class URLDemo{
public static void main(String[] args){
try{
URL url=new URL("http://www.javatpoint.com/java-tutorial");
System.out.println("Protocol: "+url.getProtocol());
System.out.println("Host Name: "+url.getHost());
System.out.println("Port Number: "+url... |
What is Java URLConnection Class? | The Java URLConnection class represents a communication link between the URL and the application. It can be used to read and write data to the specified resource referred by the URL.
|
What is the URL? | -URL is an abbreviation for Uniform Resource Locator. An URL is a form of string that helps to find a resource on the World Wide Web (WWW).
-URL has two components:
1.The protocol required to access the resource.
2.The location of the resource.
|
What are the Features of URLConnection class? | 1.URLConnection is an abstract class. The two subclasses HttpURLConnection and JarURLConnection makes the connetion between the client Java program and URL resource on the internet.
2.With the help of URLConnection class, a user can read and write to and from any resource referenced by an URL object.
3.Once a connectio... |
Can you give me the URLConnection Class Methods? | Method: void addRequestProperty(String key, String value)
Description: It adds a general request property specified by a key-value pair
Method: void connect()
Description: It opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
Method: boolean getA... |
How to get the object of URLConnection Class? | The openConnection() method of the URL class returns the object of URLConnection class.
Syntax:
public URLConnection openConnection()throws IOException{}
|
Can you give me the Displaying Source Code of a Webpage by URLConnecton Class? | The URLConnection class provides many methods. We can display all the data of a webpage by using the getInputStream() method. It returns all the data of the specified URL in the stream that can be read and displayed.
Example of Java URLConnection Class
import java.io.*;
import java.net.*;
public class URLConn... |
What is Java HttpURLConnection class? | The Java HttpURLConnection class is http specific URLConnection. It works for HTTP protocol only.
By the help of HttpURLConnection class, you can retrieve information of any HTTP URL such as header information, status code, response code etc.
The java.net.HttpURLConnection is subclass of URLConnection class.
|
Can you give me the HttpURLConnection Class Constructor? | Constructor: protected HttpURLConnection(URL u)
Description: It constructs the instance of HttpURLConnection class.
|
Can you give me the Java HttpURLConnection Methods? | Method: void disconnect()
Description: It shows that other requests from the server are unlikely in the near future.
Method: InputStream getErrorStream()
Description: It returns the error stream if the connection failed but the server sent useful data.
Method: Static boolean getFollowRedirects()
Description: It retur... |
How to get the object of HttpURLConnection class? | The openConnection() method of URL class returns the object of URLConnection class.
Syntax:
public URLConnection openConnection()throws IOException{}
You can typecast it to HttpURLConnection type as given below.
URL url=new URL("http://www.javatpoint.com/java-tutorial");
HttpURLConnection huc=(HttpURLConnecti... |
What is Java InetAddress class? | Java InetAddress class represents an IP address. The java.net.InetAddress class provides methods to get the IP of any host name for example www.javatpoint.com, www.google.com, www.facebook.com, etc.
An IP address is represented by 32-bit or 128-bit unsigned number. An instance of InetAddress represents the IP address ... |
Can you give me the Java InetAddress Class Methods? | Method: public static InetAddress getByName(String host) throws UnknownHostException
Description: It returns the instance of InetAddress containing LocalHost IP and name.
Method: public static InetAddress getLocalHost() throws UnknownHostException
Description: It returns the instance of InetAdddress containing local h... |
Can you provide an Example of Java InetAddress Class? | Let's see a simple example of InetAddress class to get ip address of www.javatpoint.com website.
InetDemo.java
import java.io.*;
import java.net.*;
public class InetDemo{
public static void main(String[] args){
try{
InetAddress ip=InetAddress.getByName("www.javatpoint.com");
System.out.println("Host Na... |
Can you give me the Program to demonstrate methods of InetAddress class? | InetDemo2.java
import java.net.Inet4Address;
import java.util.Arrays;
import java.net.InetAddress;
public class InetDemo2
{
public static void main(String[] arg) throws Exception
{
InetAddress ip = Inet4Address.getByName("www.javatpoint.com");
InetAddress ip1[] = InetAddress.getAllByName("www.javatpoi... |
What is Java DatagramSocket and DatagramPacket? | Java DatagramSocket and DatagramPacket classes are used for connection-less socket programming using the UDP instead of TCP.
Datagram
Datagrams are collection of information sent from one device to another device via the established network. When the datagram is sent to the targeted device, there is no assurance that... |
What is Java DatagramSocket class? | Java DatagramSocket class represents a connection-less socket for sending and receiving datagram packets. It is a mechanism used for transmitting datagram packets over network.`
A datagram is basically an information but there is no guarantee of its content, arrival or arrival time.
|
What is Commonly used Constructors of DatagramSocket class? | -DatagramSocket() throws SocketEeption: it creates a datagram socket and binds it with the available Port Number on the localhost machine.
-DatagramSocket(int port) throws SocketEeption: it creates a datagram socket and binds it with the given Port Number.
-DatagramSocket(int port, InetAddress address) throws SocketEep... |
Can you give me the Java DatagramSocket Class? | Method: void bind(SocketAddress addr)
Description: It binds the DatagramSocket to a specific address and port.
Method: void close()
Description: It closes the datagram socket.
Method: void connect(InetAddress address, int port)
Description:It connects the socket to a remote address for the socket.
Method: void di... |
What is Java DatagramPacket Class? | Java DatagramPacket is a message that can be sent or received. It is a data container. If you send multiple packet, it may arrive in any order. Additionally, packet delivery is not guaranteed.
|
What is Commonly used Constructors of DatagramPacket class? | -DatagramPacket(byte[] barr, int length): it creates a datagram packet. This constructor is used to receive the packets.
-DatagramPacket(byte[] barr, int length, InetAddress address, int port): it creates a datagram packet. This constructor is used to send the packets.
|
Can you give me the Java DatagramPacket Class Methods? | Method: InetAddress getAddress()
Description: It returns the IP address of the machine to which the datagram is being sent or from which the datagram was received.
Method: byte[] getData()
Description: It returns the data buffer.
Method: int getLength()
Description: It returns the length of the data to be sent or th... |
Can you provide an Example of Sending DatagramPacket by DatagramSocket? | //DSender.java
import java.net.*;
public class DSender{
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket();
String str = "Welcome java";
InetAddress ip = InetAddress.getByName("127.0.0.1");
DatagramPacket dp = new DatagramPacket(str.g... |
What is Java AWT Tutorial? | Java AWT (Abstract Window Toolkit) is an API to develop Graphical User Interface (GUI) or windows-based applications in Java.
Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavy weight i.e. its components are using the resources of underlying... |
Why AWT is platform independent? | Java AWT calls the native platform calls the native platform (operating systems) subroutine for creating API components like TextField, ChechBox, button, etc.
For example, an AWT GUI with components like TextField, label and button will have different look and feel for the different platforms like Windows, MAC OS, and... |
Can you give me the Useful Methods of Component Class? | Method: public void add(Component c)
Description: Inserts a component on this component.
Method: public void setSize(int width,int height)
Description: Sets the size (width and height) of the component.
Method:public void setLayout(LayoutManager m)
Description: Defines the layout manager for the component.
Metho... |
Can you provide the Java AWT Example? | To create simple AWT example, you need a frame. There are two ways to create a GUI using Frame in AWT.
1.By extending Frame class (inheritance)
2.By creating the object of Frame class (association)
|
Can you provide the AWT Example by Inheritance? | Let's see a simple example of AWT where we are inheriting Frame class. Here, we are showing Button component on the Frame.
AWTExample1.java
// importing Java AWT class
import java.awt.*;
// extending Frame class to our class AWTExample1
public class AWTExample1 extends Frame {
// initializing usi... |
What is Event and Listener (Java Event Handling)? | Changing the state of an object is known as an event. For example, click on button, dragging mouse etc. The java.awt.event package provides many event classes and Listener interfaces for event handling.
|
Can you give me the Java Event classes and Listener interfaces? | Event class: ActionEvent
Listener Interface: ActionListener
Event class: MouseEvent
Listener Interface: MouseListener and MouseMotionListener
Event class: MouseWheelEvent
Listener Interface: MouseWheelListener
Event class: KeyEvent
Listener Interface: KeyListener
Event class: ItemEvent
Listener Interface: Item... |
Can you give me the Registration Methods? | For registering the component with the Listener, many classes provide the registration methods. For example:
-Button
-public void addActionListener(ActionListener a){}
-MenuItem
-public void addActionListener(ActionListener a){}
-TextField
-public void addActionListener(ActionListener a){}
-public void addTextListen... |
How to use Java Event Handling Code? | We can put the event handling code into one of the following places:
1.Within class
2.Other class
3.Anonymous class
|
Can you give me the Java event handling by implementing ActionListener? | import java.awt.*;
import java.awt.event.*;
class AEvent extends Frame implements ActionListener{
TextField tf;
AEvent(){
//create components
tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(100,120,80,30);
//register listener
b.addActionListener(t... |
Can you provide the Java event handling by outer class? | import java.awt.*;
import java.awt.event.*;
class AEvent2 extends Frame{
TextField tf;
AEvent2(){
//create components
tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(100,120,80,30);
//register listener
Outer o=new Outer(this);
b.addActionListener(o);/... |
Can you give the Java event handling by anonymous class? | import java.awt.*;
import java.awt.event.*;
class AEvent3 extends Frame{
TextField tf;
AEvent3(){
tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(50,120,80,30);
b.addActionListener(new ActionListener(){
public void actionPerformed(){
tf.setText("hell... |
What is Java AWT Button? | A button is basically a control component with a label that generates an event when pushed. The Button class is used to create a labeled button that has platform independent implementation. The application result in some action when the button is pushed.
When we press a button and release it, AWT sends an instance of ... |
What is AWT Button Class Declaration? | public class Button extends Component implements Accessible
|
Can you give me the Button Class Constructors? | Following table shows the types of Button class constructors
Sr. no : 1
Constructor:Button( )
Description: It constructs a new button with an empty string i.e. it has no label.
Sr. no : 2
Constructor: Button (String text)
Description: It constructs a new button with given string as its label.
|
Can you give me the Button Class Methods? | Sr. no : 1
Method: void setText (String text)
Description: It sets the string message on the button
Sr. no : 2
Method: String getText()
Description:It fetches the String message on the button.
Sr. no : 3
Method: void setLabel (String label)
Description: It sets the label of button with the specified string.
S... |
Can you provide the Java AWT Button Example? | ButtonExample.java
import java.awt.*;
public class ButtonExample {
public static void main (String[] args) {
// create instance of frame with the label
Frame f = new Frame("Button Example");
// create instance of button with label
Button b = new Button("Click Here");
... |
What is Java AWT Label? | The object of the Label class is a component for placing text in a container. It is used to display a single line of read only text. The text can be changed by a programmer but a user cannot edit it directly.
It is called a passive control as it does not create any event when it is accessed. To create a label, we need... |
What is AWT Label Class Declaration? | public class Label extends Component implements Accessible
|
What is AWT Label Fields? | The java.awt.Component class has following fields:
1.static int LEFT: It specifies that the label should be left justified.
2.static int RIGHT: It specifies that the label should be right justified.
3.static int CENTER: It specifies that the label should be placed in center
|
Can you give me the Label class Constructors? | Sr. no :1
Constructor: Label()
Description: It constructs an empty label.
Sr. no :2
Constructor: Label(String text)
Description: It constructs a label with the given string (left justified by default).
Sr. no :3
Constructor: Label(String text, int alignement)
Description: It constructs a label with the specified str... |
Can you give me the Label Class Methods? | Specified
Sr. no :1
Method name: void setText(String text)
Description:It sets the texts for label with the specified text..
Sr. no :2
Method name: void setAlignment(int alignment)
Description:It sets the alignment for label with the specified alignment.
Sr. no :3
Method name: String getText()
Description:It gets ... |
Can you provide the Java AWT Label Example with ActionListener? | In the following example, we are creating the objects of TextField, Label and Button classes and adding them to the Frame. Using the actionPerformed() method an event is generated over the button. When we add the website in the text field and click on the button, we get the IP address of website.
LabelExample2.java
i... |
What is Java AWT TextField? | The object of a TextField class is a text component that allows a user to enter a single line text and edit it. It inherits TextComponent class, which further inherits Component class.
When we enter a key in the text field (like key pressed, key released or key typed), the event is sent to TextField. Then the KeyEvent... |
What is AWT TextField Class Declaration? | public class TextField extends TextComponent
|
Can you give me the TextField Class constructors? | Sr. no: 1
Constructor: TextField()
Description: It constructs a new text field component.
Sr. no:2
Constructor: TextField(String text)
Description: It constructs a new text field initialized with the given string text to be displayed.
Sr. no:3
Constructor: TextField(int columns)
Description: It constructs a new text... |
Can you give me the Method Inherited? | The AWT TextField class inherits the methods from below classes:
1.java.awt.TextComponent
2.java.awt.Component
3.java.lang.Object |
Can you provide the Java AWT TextField Example? | TextFieldExample1.java
// importing AWT class
import java.awt.*;
public class TextFieldExample1 {
// main method
public static void main(String args[]) {
// creating a frame
Frame f = new Frame("TextField Example");
// creating objects of textfield
TextField t1, t2;
... |
What is Java AWT TextArea? | The object of a TextArea class is a multiline region that displays text. It allows the editing of multiple line text. It inherits TextComponent class.
The text area allows us to type as much text as we want. When the text in the text area becomes larger than the viewable area, the scroll bar appears automatically whic... |
What is AWT TextArea Class Declaration? | public class TextArea extends TextComponent |
Can you provide the Fields of TextArea Class? | The fields of java.awt.TextArea class are as follows:
-static int SCROLLBARS_BOTH - It creates and displays both horizontal and vertical scrollbars.
-static int SCROLLBARS_HORIZONTAL_ONLY - It creates and displays only the horizontal scrollbar.
–static int SCROLLBARS_VERTICAL_ONLY - It creates and displays only the ve... |
Can you give me the Class constructors? | Sr. no: 1
Constructor: TextArea()
Description: It constructs a new and empty text area with no text in it.
Sr. no: 2
Constructor: TextArea (int row, int column)
Description: It constructs a new text area with specified number of rows and columns and empty string as text.
Sr. no: 3
Constructor: TextArea (String text)
... |
Can you give me the TetArea Class Methods?
| Sr. no:1
Method name: void addNotify()
Description:It creates a peer of text area.
Sr. no:2
Method name:void append(String str)
Description: It appends the specified text to the current text of text area.
Sr. no:3
Method name: AccessibleContext getAccessibleContext()
Description: It returns the accessible context re... |
Can you provide the Java AWT TextArea Example? | The below example illustrates the simple implementation of TextArea where we are creating a text area using the constructor TextArea(String text) and adding it to the frame.
TextAreaExample .java
//importing AWT class
import java.awt.*;
public class TextAreaExample
{
// constructor to initialize
... |
Can you give me the Java AWT TextArea Example with ActionListener? | The following example displays a text area in the frame where it extends the Frame class and implements ActionListener interface. Using ActionListener the event is generated on the button press, where we are counting the number of character and words entered in the text area.
TextAreaExample2.java
// importing necess... |
What is Java AWT Checkbox? | The Checkbox class is used to create a checkbox. It is used to turn an option on (true) or off (false). Clicking on a Checkbox changes its state from "on" to "off" or from "off" to "on". |
What is AWT Checkbox Class Declaration? | public class Checkbox extends Component implements ItemSelectable, Accessible |
Can you give me the Method inherited by Checkbox? | Sr. no:1
Constructor: Checkbox()
Description: It constructs a checkbox with no string as the label.
Sr. no:2
Constructor: Checkbox(String label)
Description: It constructs a checkbox with the given label.
Sr. no:3
Constructor: Checkbox(String label, boolean state)
Description: It constructs a checkbox with the given ... |
Can you give me the Checkbox Class Methods? | Sr. no: 1
Method name: void addItemListener(ItemListener IL)
Description: It adds the given item listener to get the item events from the checkbox.
Sr. no:2
Method name: AccessibleContext getAccessibleContext()
Description: It fetches the accessible context of checkbox.
Sr. no:3
Method name: void addNotify()
Descri... |
Can you provide the Java AWT Checkbox Example? | In the following example we are creating two checkboxes using the Checkbox(String label) constructo and adding them into the Frame using add() method.
CheckboxExample1.java
// importing AWT class
import java.awt.*;
public class CheckboxExample1
{
// constructor to initialize
CheckboxExample1() { ... |
Can you give me the Java AWT Checkbox Example with ItemListener? | In the following example, we have created two checkboxes and adding them into the Frame. Here, we are adding the ItemListener with the checkbox which displays the state of the checkbox (whether it is checked or unchecked) using the getStateChange() method.
CheckboxExample2.java
// importing necessary packages
impor... |
What is Java AWT CheckboxGroup? | The object of CheckboxGroup class is used to group together a set of Checkbox. At a time only one check box button is allowed to be in "on" state and remaining check box button in "off" state. It inherits the object class. |
What is AWT CheckboxGroup Class Declaration? | public class CheckboxGroup extends Object implements Serializable |
Can you provide the Java AWT CheckboxGroup Example? | import java.awt.*;
public class CheckboxGroupExample
{
CheckboxGroupExample(){
Frame f= new Frame("CheckboxGroup Example");
CheckboxGroup cbg = new CheckboxGroup();
Checkbox checkBox1 = new Checkbox("C++", cbg, false);
checkBox1.setBounds(100,100, 50,50); ... |
Can you give me the Java AWT CheckboxGroup Example with ItemListener? | import java.awt.*;
import java.awt.event.*;
public class CheckboxGroupExample
{
CheckboxGroupExample(){
Frame f= new Frame("CheckboxGroup Example");
final Label label = new Label();
label.setAlignment(Label.CENTER);
label.setSize(400,100);
Che... |
What is Java AWT Choice?
| The object of Choice class is used to show popup menu of choices. Choice selected by user is shown on the top of a menu. It inherits Component class. |
What is AWT Choice Class Declaration? | public class Choice extends Component implements ItemSelectable, Accessible |
Can you give me the Choice Class constructor? | Constructor: Choice()
Description: It constructs a new choice menu. |
Can you give me the Choice Class Methods? | Sr. no:1
Method name: void add(String item)
Description: It adds an item to the choice menu.
.
Sr. no:2
Method name: void addItemListener(ItemListener l)
Description: It adds the item listener that receives item events from the choice menu.
Sr. no:3
Method name: void addNotify()
Description: It creates the peer of cho... |
Can you provide the Java AWT Choice Example? | In the following example, we are creating a choice menu using Choice() constructor. Then we add 5 items to the menu using add() method and Then add the choice menu into the Frame.
ChoiceExample1.java
// importing awt class
import java.awt.*;
public class ChoiceExample1 {
// class constructor
... |
Can you give me the Java AWT Choice Example with ActionListener? | In the following example, we are creating a choice menu with 5 items. Along with that we are creating a button and a label. Here, we are adding an event to the button component using addActionListener(ActionListener a) method i.e. the selected item from the choice menu is displayed on the label when the button is click... |
What is Java AWT List? | The object of List class represents a list of text items. With the help of the List class, user can choose either one item or multiple items. It inherits the Component class. |
What is AWT List class Declaration? | public class List extends Component implements ItemSelectable, Accessible |
Can you give me the AWT List Class Constructors? | Sr. no:1
Constructor: List()
Description: It constructs a new scrolling list.
Sr. no:2
Constructor:List(int row_num)
Description:It constructs a new scrolling list initialized with the given number of rows visible.
Sr. no:3
Constructor: List(int row_num, Boolean multipleMode)
Description: It constructs a new scrolli... |
Can you give me the List Class Methods? | Sr. no:1
Method name: void add(String item)
Description: It adds the specified item into the end of scrolling list.
Sr. no:2
Method name: void add(String item, int index)
Description: It adds the specified item into list at the given index position.
Sr. no:3
Method name: void addActionListener(ActionListener l)
Des... |
Can you provide the Java AWT List Example? | In the following example, we are creating a List component with 5 rows and adding it into the Frame.
ListExample1.java
// importing awt class
import java.awt.*;
public class ListExample1
{
// class constructor
ListExample1() {
// creating the frame
Frame f = new Frame(); ... |
Can you give me the Java AWT List Example with ActionListene? | In the following example, we are creating two List components, a Button and a Label and adding them into the frame. Here, we are generating an event on the button using the addActionListener(ActionListener l) method. On clicking the button, it displays the selected programming language and the framework.
ListExample2.... |
What is Java AWT Canvas? | The Canvas class controls and represents a blank rectangular area where the application can draw or trap input events from the user. It inherits the Component class. |
What is AWT Canvas class Declaration? | public class Canvas extends Component implements Accessible |
What are the Constructors of the Canvas Class? | Constructors of Canvas Class
Constructor: Canvas()
Description: It constructs a new Canvas.
Constructor: Canvas(GraphicConfiguration config)
Description: It constructs a new Canvas with the given Graphic Configuration object. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.