Académique Documents
Professionnel Documents
Culture Documents
import java.awt.*;
class AWTMenu extends Frame
{
MenuBar mbar;
Menu menu,submenu;
MenuItem m1,m2,m3,m4,m5;
public AWTMenu()
{
// Set frame properties
setTitle("AWT Menu"); // Set the title
setSize(400,400); // Set size to the frame
setLayout(new FlowLayout()); // Set the layout
setVisible(true); // Make the frame visible
setLocationRelativeTo(null); // Center the frame
// Create MenuItems
m1=new MenuItem("File);
m2=new MenuItem("Edit");
m3=new MenuItem("Menu Item 3");
import java.awt.*;
import java.awt.geom.*;
class AWTDialog extends Frame
{
Dialog d1,d2;
public AWTDialog()
{
createAndShowGUI();
}
d1.setSize(400,400);
// Set opacity
d1.setOpacity(0.4f);
// Set size
d2.setSize(150,150);
// Set layout
d2.setLayout(new FlowLayout());
AWT FileDialog
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class FileDialogExample extends JFrame
{
JFramethisFrame;
JComboBoxjb;
JButton b;
public FileDialogExample()
{
// Store current object in thisFrame
thisFrame=this;
createAndShowGUI();
}
// Create JComboBox
jb=new JComboBox();
b=new JButton("Fire!");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEventae)
{
// Create a FileDialog whose parent is this frame and with title
selected in JComboBox
FileDialogfd=newFileDialog(thisFrame,(String)jb.getSelectedItem());
// Set a dir
fd.setDirectory("E:\\java");
// Make it visible
fd.setVisible(true);
}
});
// Add JComboBox
add(jb);
// Add button
add(b);
}
}
public static void main(String args[])
{
new AWTPanel();
}
}