Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ImagePanel

Posted on 1998-07-18
3
179 Views
Last Modified: 2010-04-16
I want to create a graphic background Frame. So I derived a panel of my own from the Panel class, then
overrided the paint method to supply whatever the graphic is. There was 1 error in the following codes:  
Method drawimage(java.awt.Image, int, int, ImagePanel) not found in class java.awt.Graphics
                           g.drawimage(background,0,0,this);
Could you please tell me what the correct codes should be?
 
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;

public class Frame1 extends Frame
{
 public Frame1()
 {
  //{{INIT_CONTROLS
  setLayout(null);
  setVisible(false);
  setSize(650,450);

  imagePanel1 = new ImagePanel();
  imagePanel1.setLayout(null);
  imagePanel1.setBounds(0,0,650,450);
  add(imagePanel1);
 
  Button1 = new Button(" ");
  Button1.setBounds(288,168,29,21);
  imagePanel1.add(Button1);
 
  //{{REGISTER_LISTENERS
  this.addWindowListener(new WindowAdapter(){
                  public void windowClosing(WindowEvent e){
                    System.exit(0);}
                });
 
 }
 
 static public void main(String args[])
 {
       (new Frame1()).setVisible(true);
 }
 
 //{{DECLARE_CONTROLS
 ImagePanel imagePanel1;
 Button Button1;
 
 }
 
 
class ImagePanel extends Panel
{
       String name = "bgrun3.gif";
       Image background = Toolkit.getDefaultToolkit().getImage(name);

        public void paint(Graphics g)
        {
              g.drawimage(background,0,0,this);
              return;
         }
  }


One more favour, could you please tell me how I can make my system to work with ODBC MS Access database programming to work? When I open the "32bit ODBC" icon, I saw a tabbed dialog with a number of tabs, including "User DSN",  "System DSN", "File DSN", etc.  I alse found the MS Access 97 Database in "User DSN", What should I do the next?
0
Comment
Question by:AmyS
  • 2
3 Comments
 

Author Comment

by:AmyS
ID: 1227009
Adjusted points to 60
0
 
LVL 2

Accepted Solution

by:
aziz061097 earned 60 total points
ID: 1227010
Just make g.drawimage to g.drawImage  (note the uppercase "I")
0
 
LVL 2

Expert Comment

by:aziz061097
ID: 1227011
For the second part of your question :

if you open 32 bit odbc you will find several tabs

DSN means Data Source Name , The User DSN means these will be specific to the user who has logged in on that machine. System DSN means these will appear if any user is logged in , so it is better to create System DSNs .

For creating a MS Access DSN follow the following steps
1. Select System DSN tab
2. Click on the add button
3. You will find a list of ODBC drivers(if installed )
4. Select Microsoft Access and click Finish
5. You will get a dialog , in the "Data Source Name" enter the name you want to call it (this is the name you will have to specify in your java program while doing a JDBC connection)
6. Click the Select button and you will get a File Dialog , select the .mdb file which has your Database. If you do not find the .mdb file you can do a find on Explorer to find *.mdb file.
7. Your DSN is now set and you can use this to connect to Access from a Java program. (Northwind.mdb is a sample installed by MS Access of Office 97)
5.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
simple java question 3 59
tomcat administrtor 12 61
Glassfish admin console not working 1 33
restrict decimal places for double datatype 10 21
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question