Frame

Frame

Michael wants to create a Java application with the following requirements: 1.Two labels representing name and age. 2.Two textboxes accepting name and age. The textbox accepting age should accept maximum 2 values. 3.A listbox representing values male and female.

Write a code which will accomplish the above mentioned task.

View Answers

February 11, 2011 at 5:08 PM

Java create swing frame

import java.awt.*;
import javax.swing.*;
class FrameExample 
{
    public static void main(String[] args) 
    {
        JFrame f=new JFrame();
        f.setLayout(null);

        JLabel lab1=new JLabel("Name");
        JLabel lab2=new JLabel("Age");
        JLabel lab3=new JLabel("Select");

        JTextField text1=new JTextField(20);
        JTextField text2=new JTextField(20);
        JComboBox combo=new JComboBox();
        combo.addItem("Select");
        combo.addItem("Male");
        combo.addItem("Female");

        lab1.setBounds(10,10,100,20);
        text1.setBounds(120,10,100,20);

        lab2.setBounds(10,40,100,20);
        text2.setBounds(120,40,100,20);

        lab3.setBounds(10,70,100,20);
        combo.setBounds(120,70,100,20);

        f.add(lab1);
        f.add(text1);
        f.add(lab2);
        f.add(text2);
        f.add(lab3);
        f.add(combo);

        f.setVisible(true);
        f.setSize(300,150);

    }
}

Ads









Related Tutorials/Questions & Answers:
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
Advertisements
billing frame
billing frame  how to generate billing frame using swing which contain sr. no, name of product, quantity, price & total
Image on frame
Image on frame   Hi, This is my code. In this I am unable to load... java.awt.event.*; public class AwtImg extends Frame { Image img; public...(); } AwtImg() { super("Image Frame"); MediaTracker mt=new
Frame query
Frame query  Hi, I am working on Images in java. I have two JFrame displaying same image. We shall call it outerFrame and innerFrame.In innerFrame i am rotating the image.After all the rotations i need to display this image
frame generation
frame generation  Hi I wnat to genarate one frame with two tabs working ,production..and I want two radiobuttons sector ,others in the frames..based on the tab selection I want to clikc the radio button..when i ckick the radio
Frame
frame
how to create frame in swings
how to create frame in swings  how to create frame in swings
collection frame work
collection frame work  explain all the concept in collection frame work
collection frame work
collection frame work  explain the hierarchy of one dimensional collection frame work classes
collection frame work
collection frame work  could you please tell me detail the concept of collection frame work
ModuleNotFoundError: No module named 'frame'
ModuleNotFoundError: No module named 'frame'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'frame' How to remove the ModuleNotFoundError: No module named 'frame'
Creating a Frame
; Setting the Icon for a Frame    Showing a Dialog Box  ... an Icon to a JButton Component    Making a Frame Non-Resizable    Removing the Title Bar of a Frame   
single frame coding in java
single frame coding in java  sir, i am a beginner in java.i want to do a desktop application in java in which a single frame satisfies all needs.but i want changes in that frame only.how can i solve this?i think multiple frames
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
jumping frame jFrame to jInternalframe
jumping frame jFrame to jInternalframe  Afternoon sir, I want to ask something code like jumping frame. example this i have form Login , Menu...) , and in employee(jinternal Frame) have nik(jTexkfield1), name(jtextfield2
hibernat frame work
hibernat frame work  what is the deployment structure for 'hibernete.cfg.xml','contact.hbm.xml','Contact.java','FirstExample.java' programs into eclipse ide   Have a look at the following link: Hibernate Tutorial
zend2 frame work
zend2 frame work  Hi can you please detail about Zend framework 2 latest folder structure and related things in details . I already seen zend website am confused with two old and new folder structures which one has to use
How to make frame of the picture, make frame of the picture, frame of the picture
How to make frame of the picture       This is about a frame example that has been made by some steps, I have mention here all the steps to make this effect. Take picture: First
Creating a Frame
Creating a Frame : Swing Tutorials       This program shows you how to create a frame in Java Swing Application. The frame in java works like the main window where your components
ModuleNotFoundError: No module named 'ascii_frame'
ModuleNotFoundError: No module named 'ascii_frame'  Hi, My Python... 'ascii_frame' How to remove the ModuleNotFoundError: No module named 'ascii_frame' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ascii_frame'
ModuleNotFoundError: No module named 'ascii_frame'  Hi, My Python... 'ascii_frame' How to remove the ModuleNotFoundError: No module named 'ascii_frame' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'click-frame'
ModuleNotFoundError: No module named 'click-frame'  Hi, My Python... 'click-frame' How to remove the ModuleNotFoundError: No module named 'click-frame' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'dl-frame'
ModuleNotFoundError: No module named 'dl-frame'  Hi, My Python...-frame' How to remove the ModuleNotFoundError: No module named 'dl-frame... to install padas library. You can install dl-frame python with following
ModuleNotFoundError: No module named 'frame_logging'
ModuleNotFoundError: No module named 'frame_logging'  Hi, My... 'frame_logging' How to remove the ModuleNotFoundError: No module named 'frame_logging' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'frame-ilens'
ModuleNotFoundError: No module named 'frame-ilens'  Hi, My Python... 'frame-ilens' How to remove the ModuleNotFoundError: No module named 'frame-ilens' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'frame_logging'
ModuleNotFoundError: No module named 'frame_logging'  Hi, My... 'frame_logging' How to remove the ModuleNotFoundError: No module named 'frame_logging' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'gameai-frame'
ModuleNotFoundError: No module named 'gameai-frame'  Hi, My Python... 'gameai-frame' How to remove the ModuleNotFoundError: No module named 'gameai-frame' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'howfo-frame'
ModuleNotFoundError: No module named 'howfo-frame'  Hi, My Python... 'howfo-frame' How to remove the ModuleNotFoundError: No module named 'howfo-frame' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ilens-frame'
ModuleNotFoundError: No module named 'ilens-frame'  Hi, My Python... 'ilens-frame' How to remove the ModuleNotFoundError: No module named 'ilens-frame' error? Thanks   Hi, In your python environment

Ads