D.Tech Academic
Deep Singh
Pages
Core Java
Web App
Spring
Hibernate
Kotlin
Android
Python
Flutter
Spring Boot
Java Swing Form Design Example
Java swing form design code example
import java.awt.TextArea; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRadioButton; import javax.swing.JTextArea; import javax.swing.JTextField; public class MyFrame2 { public MyFrame2() { initComponents(); } JTextField tfname, tlname, temail, tmobile; JTextArea taddress; JRadioButton rmale, rfemale; JComboBox ccity; String city[] = {"select city","A","B","C","D"}; JButton button; private void initComponents() { JFrame f = new JFrame("My First Example"); f.setSize(500, 500); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(null); // f.setResizable(false); JLabel lfname = new JLabel("First Name"); JLabel llname = new JLabel("Last Name"); JLabel lemail = new JLabel("Email "); JLabel lmobile = new JLabel("Mobile"); JLabel lgender = new JLabel("Select Gender"); tfname = new JTextField(); tlname = new JTextField(); temail = new JTextField(); tmobile = new JTextField(); taddress = new JTextArea(); rmale = new JRadioButton("Male"); rfemale = new JRadioButton("Female"); ccity = new JComboBox(city); button=new JButton("Submit Here"); ButtonGroup bg = new ButtonGroup(); bg.add(rmale); bg.add(rfemale); lfname.setBounds(100, 40, 100, 30); tfname.setBounds(100, 70, 100, 30); llname.setBounds(280, 40, 100, 30); tlname.setBounds(280, 70, 100, 30); lemail.setBounds(100, 110, 280, 30); temail.setBounds(100, 140, 280, 30); lmobile.setBounds(100, 170, 280, 30); tmobile.setBounds(100, 200, 280, 30); lgender.setBounds(100, 230, 100, 30); rmale.setBounds(100, 260, 140, 30); rfemale.setBounds(280, 260, 140, 30); ccity.setBounds(100,300,280,30); button.setBounds(100,350,280,30); f.add(llname); f.add(lfname); f.add(tfname); f.add(tlname); f.add(lemail); f.add(temail); f.add(lmobile); f.add(tmobile); f.add(lgender); f.add(rmale); f.add(rfemale); f.add(ccity); f.add(button); f.setVisible(true); } public static void main(String[] args) { new MyFrame2(); } }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment