how to create frame in swings

how to create frame in swings

how to create frame in swings

View Answers

August 23, 2011 at 5:09 PM

Simple Example

import javax.swing.*;

public class FrameExample{
  public static void main(String[] args){
  JFrame frame = new JFrame("Frame in Java Swing");
  frame.setSize(400, 400);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

Another Example

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");

            JTextField text1=new JTextField(20);
            JTextField text2=new JTextField(20);

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

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

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

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

For more information, visit the following link:

Swing Tutorials









Related Tutorials/Questions & Answers:
how to create frame in swings
how to create frame in swings  how to create frame in swings
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
Advertisements
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task is to go from one frame to another.......... let us think that iam having two buttons on a frame........button names are ok and next........ when iam clicking
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
How to create XML from Swings
How to create XML from Swings  How to create XML using Swings. I have a Swing GUI and capturing all data from it.When i click on submit, an xml...[]){ CreateXML frame=new CreateXML(); frame.setSize(300,300); frame.setVisible(true
how can i close particular frame in swings - Java Beginners
how can i close particular frame in swings  Hi, I want to know, how can we close a particular frame when mulitple frames are appearing as output... on second frame close button, it should only get close....iam trying this in swings
How to Create Button on Frame
How to Create Button on Frame       In this section, you will learn how to create Button on  frame the topic of Java AWT package. In the section, from the generated output
How to create CheckBox On frame
How to create CheckBox On frame     ... will learn how to create CheckBox on the frame. In the Java AWT, top-level windows... can learn in very efficient manner. In this section, you will see how to create
Create a Frame in Java
Create a Frame in Java       Introduction This program shows you how to create a frame...: ADS_TO_REPLACE_5 In this tutorial you learned to create simple Frame and Label
How To Create Internal Frames In Java
a simple example which will demonstrate you how to create frames within a frame...How To Create Internal Frames In Java In this tutorial we will learn about how to create a frame within a frame. Some times you will need to display a frame
To Create a Frame with Preferences
To Create a Frame with Preferences       In this section you will learn how to use the preferences in frame... with frame window. the required package to use the preferences with frame window
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
Create multiple pie chart in single frame using JFreeChart
you how to create a multiple pie charts in a single frame in jsp page using... Create multiple pie chart in single frame using JFreeChart.... In the code given below we have extended class ApplicationFrame to create a frame
how can we store the encrypted passwaord in swings?
how can we store the encrypted passwaord in swings?   how can we store the encrypted passwaord in swings
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
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
How to center a frame
How to center a frame In this tutorial, you will learn how to center a frame on screen. A Frame is a top-level window having a title and a border and its... and minimize also. Here we are going to center the frame on the screen
how to add panel inside frame?
how to add panel inside frame?  I prepared a Frame with two labels and text fields and one button.when ever user clicks on the button two text fields should be appear(those text fields should be added to the panel) .I want
how to print JInternal frame component ?
how to print JInternal frame component ?  hello sir, i devalop a swing application .but problem is that how display report & print it. some data prefech from database & keep to jtable but how it is print with table
how to set a image in frame? - Swing AWT
how to set a image in frame?  how to set a image in frame using swing
frame
frame  how to creat a frame in java   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void
Java Swing Create XML file
Java Swing Create XML file In this tutorial, you will learn how to create XML file using swings. Here is a code that accepts the data from the user through... on frame to accept the data from the user. A button is there to perform an action
How to Synchronize the Entire collection Frame Work?
How to Synchronize the Entire collection Frame Work?  How to Synchronize the Entire collection Frame Work?   I Think We must implement the Through Sub Interfaces of Collection Frame work
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
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which... of that frame ,frame is displaying but no other content. that frame contains
how to add audio clip in swings with event handling
how to add audio clip in swings with event handling  hello dear, i wanna to play audio clip in java program in JFrame in swings by event handling... how it can be done...... thanks alot
how to connect swings with jdbc... - Java Beginners
how to connect swings with jdbc...  Hi friends, Is it possible, to connect swings with data base like oracle....i want to store data into database... by using servlets and jsp but is it possible by using swings........ for data base
how can i close a frame. - Java Beginners
how can i close a frame.  Hi, My question is how can we close a frame when an action is taken......For example let us think that we have a frame and in that table is displayed and one button is added to that frame
swings
,how to know which one is selected in this...  Hi Friend, Try...","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; for(i = 0...(String[]args){ ActionOnLabel frame=new ActionOnLabel(); } } Thanks
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
How to make non resizable frame in Swing?
How to make non resizable frame in Swing?  I want code for making JFrame no re-sizable in the Swing based desktop application. Share me the code for this purpose. Thanks   Hi, Please check the tutorial Making a Frame
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually... different buttons below this displayed table using swings.....please can any... static void main(String arg[]) { try { Form frame=new Form
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
how display jsp frame - Java Beginners
how display jsp frame  Hi all, I am creating two jsp in frame... Create User Manage User... in another frame,you have to use target attribute of tag in your footer.jsp.
swings
swings  how to disable the labels.i am using the setenable(false) method to disable the label, but still mouse events(mouse clicked) are working on that label, how can i deactivate the mouse events also on the label
swings
swings  My program contains more one JComboBoxes how can i selectitems in my program. Please answer me my id [email protected]
swings
swings  Thank you deepak it is fine.... I think you have gone through mine sent code in that i am not able add that Textfield dynamically. Can youhelp me how can i add textfields dynamically in my code lookin forward to hear
JSP & Swings
JSP & Swings  How to integrate jsp and swings
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table  Java program to create a frame with 4 fields;name,street,city,pin;with suitable table. Also add a button "OK". whe it is clicked
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually i want to display a table during runtime and at the same time i also want to add different buttons below this displayed table using swings.....please can any
how can i print the selected content of a frame
how can i print the selected content of a frame  hello sir, I am designing a bill calculate program. I want to print the bill in crystal form. I want to skip all the text fields shapes and all the button from the frame.. but all
swings question
swings question  how to change the background color with the help of color values by using swings
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which... of that frame ,frame is displaying but no other content. that frame contains
To write a Java program To create a frame with 4 fields;name,street,city,pin;with suitable table
To write a Java program To create a frame with 4 fields;name,street,city,pin;with suitable table  I want to write a Java program To create a frame with 4 fields;name,street,city,pin;with suitable table
how to enter matrix data into a table of swings - Java Beginners
how to enter matrix data into a table of swings   Hi frends, I... input is 3*3 matrix and he got the matrix then it should create 3*3 table and insert the data into that table using swings...........matrix can be anything
How to set the Gradient Color as a background color for Java Frame?
How to set the Gradient Color as a background color for Java Frame?  How to set the Gradient Color as a background color for Java Frame
how to display duplicate elements with out using collection Frame work?
how to display duplicate elements with out using collection Frame work?  how to display duplicate elements with out using collection Frame work
How to make frame in java
How to make frame in java We are going to discus about frame in java. In this example We have make frame in java Swing. We have created JFrame class... of the window or frame. We have used setVisible(true) function. The setVisible

Ads