Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Anirudha Samag
Java Queries
1 Answer(s)      2 years and 5 months ago
Posted in : Java Beginners


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


Advertisement
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
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
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
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
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
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... and the ways to replace cursors and looping actions with set-based queries Archive old
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
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
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
mysql run multiple queries at once
mysql run multiple queries at once  Running two MySQL queries at a time in PHP mysql_query
Hibernate Polymorphic Queries
Hibernate Polymorphic Queries In this tutorial you will learn about the HQL polymorphic queries. Hibernate supports the polymorphic queries. Polymorphic... ( RightClick -> RunAs -> Java Application ) you will get the output as : INFO
JPA Sub-Queries
JPA Sub-Queries       In this section, you will see how to use sub-queries in your JPA application. Sub-queries allows you for querying the vast number of data
two select queries shouldn't depend on each other
two select queries shouldn't depend on each other   i want to write two select queries such that both queries shouldn't depends on each other .or how can i re-write this query? can i write this without using where
update database using two queries at a time
update database using two queries at a time  String sql="insert into employee values(emp_seq.nextval,\'"+ename+"\',\'"+eadd+"\',\'"+ephone... can execute two queries with two different Statement object in the following way
JPA Named Queries
JPA Named Queries       In this section, you will know about the JPA Named Queries...;) }) For developing JPA Named Queries, you need the following files
SQL Aggregate Queries
SQL Aggregate Queries       SQL Aggregate Queries show you the list of Aggregate Function that include... The Tutorial illustrate an example from 'SQL Aggregate Queries'. To understand
Google Ranking Update for Spammy Queries
ranking update today for some spammy queries". This update was worldwide and many... in their ranking and disappeared from search results. This update targets spam queries... percent of English queries. It is a work in progress and will be completely
JPA-QL Queries
JPA-QL Queries       In this section, we will use the simple JPA-QL query in our JPA...(); entr.begin(); Query q = em.createQuery("SELECT st FROM Student st WHERE
batch in jdbc
JDBC BATCH PROCESSING    In Batch processing, many queries work together as batch. The following program include collective set of SQL queries... is used to run all queries altogether. sqlbatch.java import 
MySQL allowMultiQueries JSP Example
to run multiple sql queries in Java. This example is given here for demonstrating you about how to write multiple queries in a single query in Java. This example explains you all the steps for allowing multiple queries using MySQL
 

 

 

DMCA.com