Java Queries

Java Queries

How to use setBounds() method in Java GUI application??

View Answers

July 24, 2012 at 10:51 AM

The setBounds() method sets the position of swing components on the container i.e. on JFrame. Here is a simple login form code that sets the textfields, button and labels on the frame using setBounds() method.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class LoginDemo extends JFrame{
 JButton SUBMIT;
 JLabel label1,label2,lab;
 final JTextField  text1,text2;
  LoginDemo(){

    setTitle("Login Form");
    setLayout(null);
    label1 = new JLabel();
    label1.setText("Username:");
    text1 = new JTextField(15);

    label2 = new JLabel();
    label2.setText("Password:");
    text2 = new JPasswordField(15);

    SUBMIT=new JButton("SUBMIT");
    label1.setBounds(350,100,100,20);
    text1.setBounds(450,100,200,20);
    label2.setBounds(350,130,100,20);
    text2.setBounds(450,130,200,20);
    SUBMIT.setBounds(450,160,100,20);
    add(label1);
    add(text1);
    add(label2);
    add(text2);
    add(SUBMIT);

   setVisible(true);
   setSize(1024,768);

 SUBMIT.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent ae){
    String value1=text1.getText();
    String value2=text2.getText();

      JOptionPane.showMessageDialog(null,"Hello "+value1);
  }
 });
  }

  public static void main(String arg[]){
  new LoginDemo();
}
}









Related Tutorials/Questions & Answers:
Java Queries
Java Queries  How to use setBounds() method in Java GUI application??   The setBounds() method sets the position of swing components on the container i.e. on JFrame. Here is a simple login form code that sets
3 queries on java class
3 queries on java class  Hey. I need to do 3 queries on same class ( JAVA) One is to populate the combobox, the another one to populate tje jlist and the last one to use on button to open a file from database (BLOB) Can some
Advertisements
to add on to my queries - Java Beginners
to add on to my queries   Dear Experts, Sorry but I am worried that I did not explain clearly so I am adding in the error message I get from Netbean IDE when I run that queries using the last solution provided. I'm puzzled
Does java supports queries with references/Table alias?
Does java supports queries with references/Table alias?  Hello, I have an Oracle query:SQL> select t.TopicName, p.NumberofPolls from EMSTopic t,EMSPoll p where t.TopicID = p.TopicID and t.TopicName= 'Sybase'; which
Execute SQL Queries with Java Application
Execute SQL Queries with Java Application       This is detailed java program to connect java application and execute queries like create table in mysql database, insert some
Maven dependency for org.apache.lucene - lucene-queries version 8.8.0 is released. Learn to use lucene-queries version 8.8.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.8.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.8.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.8.1 is released. Learn to use lucene-queries version 8.8.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.8.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.8.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.8.2 is released. Learn to use lucene-queries version 8.8.2 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.8.2 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.8.2 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.9.0 is released. Learn to use lucene-queries version 8.9.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.9.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.9.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for com.eventsourcing - eventsourcing-queries version 0.4.3 is released. Learn to use eventsourcing-queries version 0.4.3 in Maven based Java projects
- eventsourcing-queries version 0.4.3 ) in their Java project if it is based on Maven... - eventsourcing-queries version 0.4.3 java library in your project. Now you can... of eventsourcing-queries released The developers of   com.eventsourcing
Maven dependency for org.apache.lucene - lucene-queries version 6.6.4 is released. Learn to use lucene-queries version 6.6.4 in Maven based Java projects
; org.apache.lucene - lucene-queries version 6.6.4 in Java projects. Follow...; org.apache.lucene - lucene-queries version 6.6.4 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 4.5.1 is released. Learn to use lucene-queries version 4.5.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 4.5.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 4.5.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 5.3.0 is released. Learn to use lucene-queries version 5.3.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 5.3.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 5.3.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for com.eventsourcing - eventsourcing-queries version 0.4.2 is released. Learn to use eventsourcing-queries version 0.4.2 in Maven based Java projects
- eventsourcing-queries version 0.4.2 ) in their Java project if it is based on Maven... - eventsourcing-queries version 0.4.2 java library in your project. Now you can... of eventsourcing-queries released The developers of   com.eventsourcing
Maven dependency for org.apache.lucene - lucene-queries version 7.7.3 is released. Learn to use lucene-queries version 7.7.3 in Maven based Java projects
; org.apache.lucene - lucene-queries version 7.7.3 in Java projects. Follow...; org.apache.lucene - lucene-queries version 7.7.3 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.4.1 is released. Learn to use lucene-queries version 8.4.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.4.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.4.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.5.0 is released. Learn to use lucene-queries version 8.5.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.5.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.5.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.5.1 is released. Learn to use lucene-queries version 8.5.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.5.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.5.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.5.2 is released. Learn to use lucene-queries version 8.5.2 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.5.2 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.5.2 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.6.0 is released. Learn to use lucene-queries version 8.6.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.6.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.6.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.6.1 is released. Learn to use lucene-queries version 8.6.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.6.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.6.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.6.2 is released. Learn to use lucene-queries version 8.6.2 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.6.2 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.6.2 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.6.3 is released. Learn to use lucene-queries version 8.6.3 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.6.3 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.6.3 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.7.0 is released. Learn to use lucene-queries version 8.7.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 8.7.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.7.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.10.0 is released. Learn to use lucene-queries version 8.10.0 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 8.10.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.10.0 java library in your...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.10.1 is released. Learn to use lucene-queries version 8.10.1 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 8.10.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.10.1 java library in your...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.11.0 is released. Learn to use lucene-queries version 8.11.0 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 8.11.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 8.11.0 java library in your...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 4.9.1 is released. Learn to use lucene-queries version 4.9.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 4.9.1 in Java projects. Follow...; org.apache.lucene - lucene-queries version 4.9.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 9.0.0 is released. Learn to use lucene-queries version 9.0.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.0.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 9.0.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 9.1.0 is released. Learn to use lucene-queries version 9.1.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.1.0 in Java projects. Follow...; org.apache.lucene - lucene-queries version 9.1.0 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 6.6.1 is released. Learn to use lucene-queries version 6.6.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 6.6.1 in Java projects. Follow... - lucene-queries version 6.6.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 5.4.1 is released. Learn to use lucene-queries version 5.4.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 5.4.1 in Java projects. Follow... - lucene-queries version 5.4.1 java library in your project...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 9.2.0 is released. Learn to use lucene-queries version 9.2.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.2.0 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 9.2.0 java library...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.11.1 is released. Learn to use lucene-queries version 8.11.1 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 8.11.1 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 8.11.1 java...-queries released The developers of   org.apache.lucene - lucene
some queries pertaining to use of log4j for logging in a java application-
some queries pertaining to use of log4j for logging in a java application-  Please clarify the following for me- (1) I want to use a rollingfile... to use the same log file across different java classes? How do I invoke
queries
queries
datatypes queries
datatypes queries  Respected sir ,what is the reason behind that java compiler gives me an error when float datatype isused to store float value?why we prefered double datatype for this?   You can use Scanner class
ModuleNotFoundError: No module named 'queries'
ModuleNotFoundError: No module named 'queries'  Hi, My Python... 'queries' How to remove the ModuleNotFoundError: No module named 'queries... to install padas library. You can install queries python with following command
How sql Queries possible in DAO without creating Database connections - Java Beginners
How sql Queries possible in DAO without creating Database connections  In DAO we are writting sql queries , how it is possible without creating and closing database connections
Hibernate named queries
Hibernate named queries  Hi, What is named queries in Hibernate? Thanks
What are criteria Queries in Hibernate?
What are criteria Queries in Hibernate?  Just explain me what is Criteria Query in Hibernate with examples? Thanks   Criteria queries are very helpful in hibernate for queries based on certain criteria. Check
sql tips for optimizing queries
to optimize sql queries ?   Optimizing SQL Query Remove user-defined inline... actions with set-based queries Archive old data Avoid cursors   Optimizing... cursors and looping actions with set-based queries Archive old data Avoid cursors
doubts for sub queries in mysql
doubts for sub queries in mysql  how to display the details of one table by checking the conditions in the next table using some condition eg., mysql> select * from student where number=(select id from studentpersonal where
Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help
JPA Native Queries, JPA Native Queries Tutorials
JPA Native Queries       In this section, you will know about the jpa native queries and how to use native query in your JPA application.  JPA Native Queries: JPA native
mysql run multiple queries at once
mysql run multiple queries at once  Running two MySQL queries at a time in PHP mysql_query
SQL QUERIES GUIDANCE
SQL QUERIES GUIDANCE  I have a query which returns 10 rows and 10 columns. Person_Id is primary key. The result set may be like Person_id Name, City, Telephone 1 Siva Pondy 1123 For each person_id
ModuleNotFoundError: No module named 'django-queries'
ModuleNotFoundError: No module named 'django-queries'  Hi, My... named 'django-queries' How to remove the ModuleNotFoundError: No module named 'django-queries' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'hgnc-queries'
ModuleNotFoundError: No module named 'hgnc-queries'  Hi, My Python... 'hgnc-queries' How to remove the ModuleNotFoundError: No module named 'hgnc-queries' error? Thanks   Hi, In your python

Ads