?
Solved

Pretty easy for you, very annoying for me. Some help please

Posted on 2003-02-24
22
Medium Priority
?
239 Views
Last Modified: 2010-03-31
This is part of the code:

import java.applet.Applet;
import java.applet.*;
import javax.swing.*;
//import java.awt.Graphics;
//import java.awt.Color;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.text.*;
import java.util.*;


public class ArticleInterface extends Applet implements ActionListener, ItemListener
{
//globale variabler UI
private Button btHeadline;                   
private Button btPictureText;             
private Button btText;                   
private Button btSource;            
private Button btDate;                  
private TextField tfHeadline;             
private TextArea taPictureText;
private TextArea taText;                   
private TextField tfSource;                  
private String Headline;                  
private String PictureText;            
private String Text;                         
private Button btShow;                  
private TextField tfFilename;            
private ImageCanvas c;                        
private Checkbox chkPri;                  
//Globale variabler JDBC
String databaseURL, databaseName;
Connection con;
public static Statement stmt;
public static ResultSet rs;
public static ResultSetMetaData rsmd;

private String username;
private String password;

  public void init()
  {
      //setter farger og layout for applet
      setBackground(Color.lightGray);
      setLayout(null);

      //oppretter et grafikkpanel
      Panel p = new Panel();


//oppretter grafikkobjekter til panelet
//Tekstdel
btHeadline = new Button("Skriv Overskrift");
btPictureText = new Button("Skriv Intro");
btText = new Button("Skriv Brødtekst");
btSource = new Button("Kilde");
btDate = new Button("Sett dato");
tfHeadline = new TextField(20);
tfSource = new TextField(20);
taPictureText = new TextArea("",5,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
      taText = new TextArea("",5,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
      chkPri = new Checkbox("Prioritert");

//oppretter fonter
Font fontHeadLine = new Font("Areal", Font.BOLD, 20);
Font fontPictureText = new Font("Areal", Font.BOLD, 12);

//Bildedel
btShow = new Button("Vis Bilde");
tfFilename = new TextField(20);
c = new ImageCanvas();


//plasserer grafikkobjekter til panelet
//knapper
p.add(btHeadline);
btHeadline.setBounds(50,50,100,30);

p.add(btPictureText);
btPictureText.setBounds(50,150,100,30);

p.add(btText);
btText.setBounds(50,380,100,30);

p.add(btSource);
btSource.setBounds(50,610,100,30);

//tekstfelt
p.add(tfHeadline);
tfHeadline.setBounds(250,50,200,30);
tfHeadline.setFont(fontHeadLine);

p.add(taPictureText);
taPictureText.setBounds(250,150,200,200);
taPictureText.setFont(fontPictureText);

p.add(taText);
taText.setBounds(250,380,200,200);

p.add(tfSource);
tfSource.setBounds(250,610,200,30);
//Bildedel
p.add(c);
c.setBackground(Color.gray);
c.setBounds(600,50,180,200);

p.add(btShow);
btShow.setBounds(600,300,100,30);
p.add(tfFilename);
tfFilename.setBounds(750,300,200,30);

p.add(btDate);
btDate.setBounds(600,360,100,30);
//Checkboxer
p.add(chkPri);
chkPri.setBounds(600,420,100,30);



//plasserer panelet i framen uten layout
add(p);
p.setLayout(null);
p.setBounds(0,0,1024,768);



//initialiserer listener
btHeadline.addActionListener(this);
btPictureText.addActionListener(this);
btText.addActionListener(this);
btShow.addActionListener(this);
btDate.addActionListener(this);
tfFilename.addActionListener(this);
chkPri.addItemListener(this);
  }

//ActionEvent handler
public void actionPerformed(ActionEvent e)
{
String actionCommand = e.getActionCommand();
if ((e.getSource() instanceof Button) || (e.getSource() instanceof TextField))
{
if (actionCommand.equals("Skriv Overskrift"))
{
                  
      Headline = tfHeadline.getText();
      System.out.println(Headline);
}
else if (actionCommand.equals("Skriv Bildetekst"))
{
//setter fonter,linjeskift,størrelse
PictureText = taPictureText.getText();

}
else if (actionCommand.equals("Skriv Artikkel"))
            {
//setter fonter,linjeskift,størrelse
      Text = taText.getText();
            }
else if (actionCommand.equals("Sett Dato"))
            {
//set date
Date currentDate = new Date();
DateFormat fmt = getDateInstance(Locale.SHORT);
                                             //ERROR!!!!!
String formatert = fmt.format(currentDate);

            }

else if (actionCommand.equals("Vis Bilde") || (e.getSource() instanceof TextField))
            {
                  displayImage();
            }

        }

      }
public void ItemStateChange(ItemEvent e)
{
if (e.getSource() instanceof Checkbox)
{
boolean b = chkPri.getState();      //sjekker om sjekkboks er satt
if (b = true)
System.out.println("1");
else
System.out.println("0");
            }
      }

When i run this code i get two errors:
1.
ArticleInterface should be declared abstract; it does not define itemStateChanged(java.awt.event.ItemEvent) in ArticleInterface

2.
//The second error i get from this code snippet. It cannot resolve symbol Date in the first line....
Date currentDate = new Date();
DateFormat fmt = getDateInstance(Locale.SHORT);                                          
String formatert = fmt.format(currentDate);

Please help.


0
Comment
Question by:RayGun
[X]
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
  • 8
  • 4
  • 3
  • +4
22 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 8007627
>1.
ArticleInterface should be declared abstract; it does not define itemStateChanged(java.awt.event.ItemEvent) in ArticleInterface

  Since you implement interfaces you need to implement all of their methdos. Just add the following in your code:

public void itemStateChanged(java.awt.event.ItemEvent ie) {}

> 2.
//The second error i get from this code snippet. It cannot resolve symbol Date in the first line....

  Import it by using: import java.util.Date;
0
 
LVL 9

Expert Comment

by:Venci75
ID: 8007629
there are two Date classes:
java.util.Date
and
java.sql.Date

you must specify which one you want:
java.util.Date currentDate = new java.util.Date();
0
 
LVL 1

Expert Comment

by:membersh
ID: 8007666
You had implemented the method but missed out 'd' in itemStateChanged(ItemEvent e).
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:girionis
ID: 8007694
> You had implemented the method but missed out 'd' in itemStateChanged(ItemEvent e).

  So he didn't implement the method after all :-)

0
 
LVL 1

Expert Comment

by:umangjoshi
ID: 8007712
here i have solved above two errors:
-----------------------------------

import java.applet.Applet;
import java.applet.*;
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.text.*;
import java.util.*;


public class ArticleInterface extends Applet implements ActionListener, ItemListener
{
//globale variabler UI
private Button btHeadline;                
private Button btPictureText;          
private Button btText;                
private Button btSource;          
private Button btDate;              
private TextField tfHeadline;          
private TextArea taPictureText;
private TextArea taText;                
private TextField tfSource;              
private String Headline;              
private String PictureText;          
private String Text;                    
private Button btShow;              
private TextField tfFilename;          
private ImageCanvas c;                    
//private ImageCanvas c;                    
private Checkbox chkPri;              
//Globale variabler JDBC
String databaseURL, databaseName;
Connection con;
public static Statement stmt;
public static ResultSet rs;
public static ResultSetMetaData rsmd;

private String username;
private String password;

 public void init()
 {
     //setter farger og layout for applet
     setBackground(Color.lightGray);
     setLayout(null);

     //oppretter et grafikkpanel
     Panel p = new Panel();


//oppretter grafikkobjekter til panelet
//Tekstdel
btHeadline = new Button("Skriv Overskrift");
btPictureText = new Button("Skriv Intro");
btText = new Button("Skriv Brxdtekst");
btSource = new Button("Kilde");
btDate = new Button("Sett dato");
tfHeadline = new TextField(20);
tfSource = new TextField(20);
taPictureText = new TextArea("",5,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
     taText = new TextArea("",5,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
     chkPri = new Checkbox("Prioritert");

//oppretter fonter
Font fontHeadLine = new Font("Areal", Font.BOLD, 20);
Font fontPictureText = new Font("Areal", Font.BOLD, 12);

//Bildedel
btShow = new Button("Vis Bilde");
tfFilename = new TextField(20);
c = new ImageCanvas();


//plasserer grafikkobjekter til panelet
//knapper
p.add(btHeadline);
btHeadline.setBounds(50,50,100,30);

p.add(btPictureText);
btPictureText.setBounds(50,150,100,30);

p.add(btText);
btText.setBounds(50,380,100,30);

p.add(btSource);
btSource.setBounds(50,610,100,30);

//tekstfelt
p.add(tfHeadline);
tfHeadline.setBounds(250,50,200,30);
tfHeadline.setFont(fontHeadLine);

p.add(taPictureText);
taPictureText.setBounds(250,150,200,200);
taPictureText.setFont(fontPictureText);

p.add(taText);
taText.setBounds(250,380,200,200);

p.add(tfSource);
tfSource.setBounds(250,610,200,30);
//Bildedel
p.add(c);
c.setBackground(Color.gray);
c.setBounds(600,50,180,200);

p.add(btShow);
btShow.setBounds(600,300,100,30);
p.add(tfFilename);
tfFilename.setBounds(750,300,200,30);

p.add(btDate);
btDate.setBounds(600,360,100,30);
//Checkboxer
p.add(chkPri);
chkPri.setBounds(600,420,100,30);



//plasserer panelet i framen uten layout
add(p);
p.setLayout(null);
p.setBounds(0,0,1024,768);



//initialiserer listener
btHeadline.addActionListener(this);
btPictureText.addActionListener(this);
btText.addActionListener(this);
btShow.addActionListener(this);
btDate.addActionListener(this);
tfFilename.addActionListener(this);
chkPri.addItemListener(this);
 }

//ActionEvent handler
public void actionPerformed(ActionEvent e)
{
String actionCommand = e.getActionCommand();
if ((e.getSource() instanceof Button) || (e.getSource() instanceof TextField))
{
if (actionCommand.equals("Skriv Overskrift"))
{
               
     Headline = tfHeadline.getText();
     System.out.println(Headline);
}
else if (actionCommand.equals("Skriv Bildetekst"))
{
//setter fonter,linjeskift,stxrrelse
PictureText = taPictureText.getText();

}
else if (actionCommand.equals("Skriv Artikkel"))
          {
//setter fonter,linjeskift,stxrrelse
     Text = taText.getText();
          }
else if (actionCommand.equals("Sett Dato"))
          {
//set date
java.util.Date currentDate = new java.util.Date();
//DateFormat fmt = getDateInstance(Locale.US);
                                            //ERROR!!!!!
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy");                                            
String formatert = fmt.format(currentDate);

          }

else if (actionCommand.equals("Vis Bilde") || (e.getSource() instanceof TextField))
          {
               displayImage();
          }

       }

     }
public void itemStateChanged(ItemEvent e)
{
      if (e.getSource() instanceof Checkbox)
      {
            boolean b = chkPri.getState();     //sjekker om sjekkboks er satt
            if (b = true)
                  System.out.println("1");
            else
                  System.out.println("0");
  }
}

}//end of class


0
 

Author Comment

by:RayGun
ID: 8007850
You had implemented the method but missed out 'd' in itemStateChanged(ItemEvent e).

You were right about the 'd', but adding it did not solve the problem.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8007880
Please say whether you still need help
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8007883
Oh, and please get CS to delete the duplicates.
0
 

Author Comment

by:RayGun
ID: 8007884
Yes I do. Still getting the same error:
ArticleInterface should be declared abstract; it does not define itemStateChanged(java.awt.event.ItemEvent) in ArticleInterface
0
 
LVL 35

Expert Comment

by:girionis
ID: 8007887
 ... and please also state the exact error message you are getting.
0
 
LVL 3

Accepted Solution

by:
schybert earned 320 total points
ID: 8007890
Well you'll have to substitute the capital 'I' to 'i' in itemStateChanged...
0
 
LVL 35

Expert Comment

by:girionis
ID: 8007905
 RayGun did you try my suggestion?
0
 
LVL 35

Expert Comment

by:girionis
ID: 8007917
 ... and please stop hitting refresh all the time... You end up posting more questions. Instead click on the "Reload this question" link on the top-left of the page.
0
 

Author Comment

by:RayGun
ID: 8007929
Well you'll have to substitute the capital 'I' to 'i' in itemStateChanged...

Thnx, god damn I need a break. :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 8007954
 Hmm I do not see why my *solution* wouldn't satisfy you.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 8007965
I think that qirionis have already suggested this.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8007994
 At least his problem is solved. :-)
0
 

Author Comment

by:RayGun
ID: 8008005
I'm sorry girionis, I missed it. You were right all the time. I'll be more allert in the future and be on the lookout for your excellent advise. Thank you.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8008024
Please clean up the question mess with CS now RayGun.
0
 
LVL 3

Expert Comment

by:schybert
ID: 8008034
Now I feel like a point thief :-( I'll hand the points over to girionis asap :-)
0
 
LVL 35

Expert Comment

by:girionis
ID: 8008109
 schybert you don't have to do this, your help was valuable as well :-) It's just nice when people appreciate your help, that's all. It's not matter of points, a simple thank you is enough :-)

  RayGun you're welcome. I am glad we all helped you.
0
 
LVL 3

Expert Comment

by:schybert
ID: 8008163
Too late... already posted the question... So go pick those points up... or else... ;-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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