package com.example; import java.awt.*; // Using AWT's containers and components import java.awt.event.*; // Using AWT's event classes and listener interfaces // An AWT GUI program inherits the top-level container java.awt.Frame public class AWTCounter extends Frame implements ActionListener { privaRead more
package com.example;
import java.awt.*; // Using AWT's containers and components
import java.awt.event.*; // Using AWT's event classes and listener interfaces
// An AWT GUI program inherits the top-level container java.awt.Frame
public class AWTCounter extends Frame implements ActionListener {
private Label lblCount; // Declare component Label
private TextField tfCount; // Declare component TextField
private Button btnCount; // Declare component Button
private int count = 0; // counter's value
// Constructor to setup UI components and event handlers
public AWTCounter () {
setLayout(new FlowLayout());
// "super" Frame sets layout to FlowLayout, which arranges
// Components from left-to-right, then top-to-bottom.
lblCount = new Label("Counter"); // Construct component Label
add(lblCount); // "super" Frame adds Label
tfCount = new TextField(count + "", 10); // Construct component TextField
tfCount.setEditable(false); // read-only
add(tfCount); // "super" Frame adds TextField
btnCount = new Button("Count"); // Construct component Button
add(btnCount); // "super" Frame adds Button
btnCount.addActionListener(this);
// btnCount is the source object that fires ActionEvent when clicked.
// The source add "this" instance as an ActionEvent listener, which provides
// an ActionEvent handler called actionPerformed().
// Clicking btnCount invokes actionPerformed().
setSize(250, 100); // "super" Frame sets initial size
setTitle("AWT Counter"); // "super" Frame sets title
setVisible(true); // show "super" Frame
}
// ActionEvent handler - Called back when the button is clicked.
@Override
public void actionPerformed(ActionEvent evt) {
++count; // Incrase the counter value
tfCount.setText(count + ""); // Display on the TextField
// setText() takes a String
}
// The entry main() method
public static void main(String[] args) {
// Invoke the constructor by allocating an anonymous instance
new AWTCounter();
}
}
Write a java program that establishes a connection to oracle database successfully. If the connection is successful, it should display a message “Connection Established successfully”. ANSWER:
Write a java program that establishes a connection to oracle database successfully. If the connection is successful, it should display a message “Connection Established successfully”.
Consider following NLPP Min Z=2x₂²-24x₁+2x₂²-8x₂+2×3²-12×3+200 By separating this function show that it is convex
https://sikshapath.in/question/consider-following-nlpp-min-z2x12-24x12x2%c2%b2-8x22x32-12x3200-by-separating-this-function-show-that-it-is-convex/
Write a program to read and write data to a file.
https://sikshapath.in/question/how-do-you-read-write-a-text-file-in-java/
Write an AWT GUI application (called AWTCounter). Each time the “Count” button is clicked, the counter value shall increase by 1. …
package com.example; import java.awt.*; // Using AWT's containers and components import java.awt.event.*; // Using AWT's event classes and listener interfaces // An AWT GUI program inherits the top-level container java.awt.Frame public class AWTCounter extends Frame implements ActionListener { privaRead more
Briefly explain java.awt.BorderLayout with Example.
Briefly explain java.awt.BorderLayout with Example. ANSWER:
Briefly explain java.awt.BorderLayout with Example.
ANSWER:
See lessWrite a java program that connects to oracle database, queries the inbuilt table “emp” and displays the first two columns …
try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "JAMES", "local"); } catch (Exception e) { System.out.println("Connection could not be established"); if (conn != null) conn.close(); } ANSWER :
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”);
conn = DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:XE”, “JAMES”, “local”);
} catch (Exception e) {
System.out.println(“Connection could not be established”);
if (conn != null) conn.close();
}
ANSWER :
See lessWrite a java program that establishes a connection to oracle database successfully. If the connection is successful, it should display …
Write a java program that establishes a connection to oracle database successfully. If the connection is successful, it should display a message “Connection Established successfully”. ANSWER:
Write a java program that establishes a connection to oracle database successfully. If the connection is successful, it should display a message “Connection Established successfully”.
ANSWER:
See less