JApplet Nesnelerini Form Üzerinde Hizalamak
import javax.swing.*;
public class NoLayoutExample extends JApplet {
public void init() {
JTextField newItemField;
JList itemsList;
JButton addButton;
JButton removeButton;
getContentPane().setLayout(null);
//Metin Kutusu
newItemField = new JTextField();
newItemField.setLocation(12, 12);
newItemField.setSize(150, 30);
getContentPane().add(newItemField);
//Ekle Dugmesi
addButton = new JButton("Ekle");
addButton.setMnemonic('E');
addButton.setLocation(174, 12);
addButton.setSize(100, 30);
getContentPane().add(addButton);
//Liste Kutusu
itemsList = new JList();
JScrollPane scrollPane = new JScrollPane(itemsList,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setLocation(12, 45);
scrollPane.setSize(150, 150);
getContentPane().add(scrollPane);
//Çıkar Dugmesi
removeButton = new JButton("Çıkar");
removeButton.setMnemonic('C');
removeButton.setLocation(174, 45);
removeButton.setSize(100, 30);
getContentPane().add(removeButton);
}
}
public class NoLayoutExample extends JApplet {
public void init() {
JTextField newItemField;
JList itemsList;
JButton addButton;
JButton removeButton;
getContentPane().setLayout(null);
//Metin Kutusu
newItemField = new JTextField();
newItemField.setLocation(12, 12);
newItemField.setSize(150, 30);
getContentPane().add(newItemField);
//Ekle Dugmesi
addButton = new JButton("Ekle");
addButton.setMnemonic('E');
addButton.setLocation(174, 12);
addButton.setSize(100, 30);
getContentPane().add(addButton);
//Liste Kutusu
itemsList = new JList();
JScrollPane scrollPane = new JScrollPane(itemsList,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setLocation(12, 45);
scrollPane.setSize(150, 150);
getContentPane().add(scrollPane);
//Çıkar Dugmesi
removeButton = new JButton("Çıkar");
removeButton.setMnemonic('C');
removeButton.setLocation(174, 45);
removeButton.setSize(100, 30);
getContentPane().add(removeButton);
}
}
Yorumunuzu Ekleyin