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 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
Maven dependency for org.apache.lucene - lucene-queries version 9.4.2 is released. Learn to use lucene-queries version 9.4.2 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.4.2 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 9.4.2 java library...-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... and includes  org.apache.lucene - lucene-queries version 6.6.1 java library...-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... and includes  org.apache.lucene - lucene-queries version 5.4.1 java library...-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... and includes  org.apache.lucene - lucene-queries version 9.1.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 9.0.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 4.9.1 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.11.0 java...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 9.4.0 is released. Learn to use lucene-queries version 9.4.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.4.0 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 9.4.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.10.1 java...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 9.4.1 is released. Learn to use lucene-queries version 9.4.1 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.4.1 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 9.4.1 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.10.0 java...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 8.11.2 is released. Learn to use lucene-queries version 8.11.2 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 8.11.2 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 8.11.2 java...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 9.3.0 is released. Learn to use lucene-queries version 9.3.0 in Maven based Java projects
; org.apache.lucene - lucene-queries version 9.3.0 in Java projects. Follow... and includes  org.apache.lucene - lucene-queries version 9.3.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.7.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.6.3 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.6.2 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.6.1 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.6.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.5.2 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.5.1 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.5.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 8.4.1 java library...-queries released The developers of   org.apache.lucene - lucene
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... and includes  org.apache.lucene - lucene-queries version 7.7.3 java library...-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...; com.eventsourcing - eventsourcing-queries version 0.4.2 java library in your project... of eventsourcing-queries released The developers of   com.eventsourcing
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... and includes  org.apache.lucene - lucene-queries version 5.3.0 java library...-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... and includes  org.apache.lucene - lucene-queries version 4.5.1 java library...-queries released The developers of   org.apache.lucene - lucene
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... and includes  org.apache.lucene - lucene-queries version 6.6.4 java library...-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...; com.eventsourcing - eventsourcing-queries version 0.4.3 java library in your project... of eventsourcing-queries released The developers of   com.eventsourcing
Maven dependency for org.apache.lucene - lucene-queries version 3.5.0 is released. Learn to use lucene-queries version 3.5.0 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 3.5.0 in Java projects...-queries version 3.5.0 java library in your project. ADS_TO_REPLACE_2 Now you can...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 7.4.0 is released. Learn to use lucene-queries version 7.4.0 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 7.4.0 in Java projects...-queries version 7.4.0 java library in your project. ADS_TO_REPLACE_2 Now you can...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 5.2.1 is released. Learn to use lucene-queries version 5.2.1 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 5.2.1 in Java projects...-queries version 5.2.1 java library in your project. ADS_TO_REPLACE_2 Now you can...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 6.2.1 is released. Learn to use lucene-queries version 6.2.1 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 6.2.1 in Java projects...-queries version 6.2.1 java library in your project. ADS_TO_REPLACE_2 Now you can...-queries released The developers of   org.apache.lucene - lucene
Maven dependency for org.apache.lucene - lucene-queries version 7.7.1 is released. Learn to use lucene-queries version 7.7.1 in Maven based Java projects
to use  org.apache.lucene - lucene-queries version 7.7.1 in Java projects...-queries version 7.7.1 java library in your project. ADS_TO_REPLACE_2 Now you can...-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
Hibernate named queries
Hibernate named queries  Hi, What is named queries in Hibernate? Thanks

Ads