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



Home Answers Viewqa Swing-AWT Java logical error
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shubham
Java logical error
1 Answer(s)      4 years and 3 months ago
Posted in : Swing AWT


Subject:Buttons not displaying over image
Dear Sir/Madam,
I am making a login page using java 1.6 Swings.
I have want to apply picture in the backgoud of the frame and want to place buttons on it.
But the buttons are not displaying properly.

So,I request your kind help.

I have uploaded my code at:
http://www.mediafire.com/file/41d7a852eupfi9t/LoginPage.zip

Thank you.

Advertisement
View Answers

July 19, 2010 at 1:45 PM


Hi Friend,

Try the following code:

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;

public class BackgroundImage{
private BufferedImage image;
private JPanel panel = new JPanel(new GridLayout(4,2)) {
protected void paintComponent(Graphics g){
super.paintComponent(g);
if (image != null){
g.drawImage(image, 0, 0, this);
}
}
};
public BackgroundImage(){
try {
File file=new File("C:\\rose.jpg");
image = ImageIO.read(file);
Dimension imageSize = new Dimension(image.getWidth(), image.getHeight());
panel.setPreferredSize(imageSize);
JLabel label1=new JLabel("Username: ");
JLabel label2=new JLabel("Password: ");
JTextField text1=new JTextField(10);
JTextField text2=new JTextField(10);
JLabel lab=new JLabel("");
JButton b1=new JButton("Login");
JButton b2=new JButton("Register");
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(b1);
panel.add(lab);
panel.add(b2);
}
catch (Exception e) {}
}
public JPanel getPanel() {
return panel;
}
public static void main(String[] args) {
JFrame frame = new JFrame("BackgroundImage ");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new BackgroundImage().getPanel());
frame.setSize(300,150);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}

Thanks


Related Tutorials/Questions & Answers:
Logical error - Java Magazine
Logical error  hi guys... I am facing some probleam in do-while loop so plz check out my code and inform me whats wrong with this code thanks..... import java.io.*; class searchex { String str=new String
Java logical error - Swing AWT
Java logical error  Subject:Buttons not displaying over image Dear Sir/Madam, I am making a login page using java 1.6 Swings. I have want to apply picture in the backgoud of the frame and want to place buttons
Advertisements
Logical Operators in java 7
In this tutorial, we are going to discuss about logical operator in java 7
Logical transformation
Logical transformation  hello, Trying to find a way to do this transformation in Java: N = same if number < 1000 N = 1000 if number = 0 N = number%1000 if number > 1000 I can't find an answer Please help
logical operators in objective c
logical operators in objective c  logical operators in objective c
Logical Operators
Logical Operators Operator is used to perform operation on variable and values. Logical operators perform logical operation which produce Boolean result i.e. True or False. Given below the some of the main operators of PHP
15 Php programs on logical operators
15 Php programs on logical operators  I need 15 example programs for logical operators. Please help me out
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
complier error - Java Beginners
error shows syntax errors like: required : int found : byte Runtime error shows logical errors like: int x=2/0; //this expression causes runtime error... errors like: required : int found : byte Runtime error shows logical
Java Error - Java Beginners
Java Error  Hello Sir ,How i Can solve Following Error Can not find Symbol - in.readLine(); Here Error Display at in  Hi Friend, It seems that you haven't defined the object 'in'.Anyways, Send your code so that we
runtime error in java
runtime error in java  What is Run time error in Java?   Run time error is a syntax error that during the execution of a program.It hash different types of a program like as Logic error,Fatal Errors,source code,wrong
PHP Logical Operator
Logical Operators: This logical operators  are used when we need to check more than one condition, like if more than one condition has to be true then we need to use and (&&) and suppose if any one condition could be true
java error - Java Beginners
java error  Hello sir, on compiling any program from command prompt.... But if I want to run that program the fetches me the following error. For example for file: Test.java C:\Program Files\Java\jdk1.6.0_17\bin>javac Test.java
java error - Java Beginners
java error  G:\threading>javac threadmethods.java Note: threadmethods.java uses or overrides a deprecated API. Note: Recompile with -Xlint... been obsoleted. To get the details of your error, compile your class with Xlint
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
java compilation error - Applet
java compilation error  I am getting compilation error in the following code.: public void paint(Graphics g) { switch(screen...; } } Error is: Illegal start of expression Plz. find why am I getting this error
Java Error - Java Beginners
Java Error  E:\SUSHANT\Core Java\FileHandling\Error>javac... ch= reader.read(); ^ 1 error import java.io....); //System.out.println("Enter characters, 'q' to quit."); try
Java Error - Java Beginners
Java Error  Here Error near Read Method import java.util.*; import java.io.*; public class inputdemo { public static void main(String[] args) throws IOException { String bookname,author; float price; System.out.println
JAVA Annotation Error
JAVA Annotation Error  while compiling simple java program i get annotation error i.e class will only be accepted if annotation processing is explicitly requested..how to solve
java runtime error - JDBC
java runtime error  when i m running my program by using jdk1.6.0 then it is giving the error of classunsupported major.minor version 50.0.to remove... version error 49.0.so, please suggest how will i compensate this problem
java error - Java Beginners
java error  Thanks for providing me the answer for the question... be dereferenced If Programme saved in SortFileData also shows some error Please rectify the errors and provide the coding that run properly Write a Java program
Java compilation error - Java Beginners
Java compilation error  Method overridden problems in compile time error
JAVA Error - Java Beginners
JAVA Error  i have made my own calculator GUI..and i want the text..."); btnBack.setForeground(red); it send me an error message that goes like this unknown...: http://www.roseindia.net/java/ Thanks.   Hello Just use
java runtime error - JDBC
java runtime error  when i m running my program using type1 driver it is showing a runtime error of SQLException of unable to create the connection object.please give the solution
error - Java Beginners
Java error handling  How to write a code to handle the errors in Java?  hi all,visit these site mentioned belowhttp://www.ugrad.cs.ubc.ca/~cs211/tutorials/Eclipse/Eclipse_Java_Windows_XP.htmlit will work
error message - Java Beginners
error message  sir, while i m trying to execute my first program(print my name)I get error message like" javac is not recognized as internal...;Hi friend, To compile and run a java program we need to install java
java compilation error - Applet
java compilation error  hi friends the following is the awt front design program error, give me the replay E:\ramesh>javac...://www.roseindia.net/java/example/java/awt/ Thanks
java error - Java Beginners
java error  Dear roseindiamembers, I have checked the registration form for new user to login roseindiamembers forum with different data.It's not working properly .when i am registering as new user in http
what is the error - Java Beginners
what is the error  What is the compile time error that i am getting... is creating the compile time error such as : - ? CANNOT FIND SYMBOL ? because you... this .correct code is this if you don?t want such type of error EG : - import java.lang.
Java Error - Java Beginners
Java Error  import java.io.*; import java.lang.*; public class Wrapperdemo { float prin; float rate; int no; float interest; Wrapperdemo() { try{ BufferedReader br = new BufferedReader(new InputStreamReader
Advertisements
 

 

 

DMCA.com