Java unit 5
Java unit 5
Example:
```java
import java.applet.Applet;
import java.awt.Graphics;
Example:
```java
import java.applet.Applet;
import java.awt.Graphics;
Example:
```java
import java.applet.Applet;
import java.awt.Graphics;
Java:
```java
import java.applet.Applet;
import java.awt.Graphics;
Swing in Java
7. What is Swing?
Answer: Swing is a part of Java's standard library for creating graphical user interfaces (GUIs). It provides
a rich set of components and a more flexible architecture than AWT.
Example:
```java
import javax.swing.JApplet;
import javax.swing.JLabel;
Example:
```java
import javax.swing.JFrame;
import javax.swing.JLabel;
Example:
```java
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JFrame;
import javax.swing.JTextField;
public class TextFieldExample {
public static void main(String[] args) {
JFrame frame = new JFrame("Text Field Example");
frame.setSize(300, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JButton;
import javax.swing.JFrame;
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JCheckBox;
import javax.swing.JFrame;
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
frame.add(option1);
frame.add(option2);
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JComboBox;
import javax.swing.JFrame;
frame.add(comboBox);
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
frame.add(tabbedPane);
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
root.add(node1);
root.add(node2);
frame.setVisible(true);
}
}
```
Example:
```java
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
frame.setVisible(true);
}
}
```