Beruflich Dokumente
Kultur Dokumente
import javax.swing.JFrame;
}
Creating Panel using JPanel Sample Code
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
}
Setting Layout using Flow Layout Sample Code
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
frame.setSize(300, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Setting Layout using Border Layout Sample Code
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
frame.setSize(300, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) {
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
frame.setSize(300, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) {
}
}
Creating Button using JButton Sample Code
import javax.swing.JButton;
import javax.swing.JFrame;
frame.setSize(300,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating Label using JLabel Sample Code
package gui;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Icon;
frame.setLayout(new GridLayout(4,1));
frame.setSize(300,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating Text Field using JTextField Sample Code
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
frame.setLayout(new FlowLayout());
frame.setSize(300,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating Text Area using JTextArea Sample Code
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
frame.setLayout(new FlowLayout());
frame.setSize(500,150);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
}
Creating List Box using JList Sample Code
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
frame.setLayout(new FlowLayout());
frame.setSize(300,150);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating Combo Box using JComboBox Sample Code
import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
JComboBox<String> cmbTransport =
new JComboBox<String>(transport);
frame.setLayout(new FlowLayout());
frame.setSize(300,150);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating Check Box using JCheckBox Sample Code
import java.awt.FlowLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
frame.setLayout(new FlowLayout());
frame.setSize(300,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating Radio Button using JRadioButton Sample Code
import java.awt.FlowLayout;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
frame.setLayout(new FlowLayout());
frame.setSize(300,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) {
}
Creating Menu Bar using JMenuBar Sample Code
import javax.swing.JFrame;
import javax.swing.JMenuBar;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,100);
frame.setVisible(true);
}
}
Creating Menu using JMenu Sample Code
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,100);
frame.setVisible(true);
}
/* Main entry point of program. This will launch the GUI */
public static void main(String[] args) {
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,100);
frame.setVisible(true);
}