RayGun
asked on
Pretty easy for you, very annoying for me. Some help please
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.lightG ray);
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,3 0);
p.add(btText);
btText.setBounds(50,380,10 0,30);
p.add(btSource);
btSource.setBounds(50,610, 100,30);
//tekstfelt
p.add(tfHeadline);
tfHeadline.setBounds(250,5 0,200,30);
tfHeadline.setFont(fontHea dLine);
p.add(taPictureText);
taPictureText.setBounds(25 0,150,200, 200);
taPictureText.setFont(font PictureTex t);
p.add(taText);
taText.setBounds(250,380,2 00,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,1 00,30);
p.add(tfFilename);
tfFilename.setBounds(750,3 00,200,30) ;
p.add(btDate);
btDate.setBounds(600,360,1 00,30);
//Checkboxer
p.add(chkPri);
chkPri.setBounds(600,420,1 00,30);
//plasserer panelet i framen uten layout
add(p);
p.setLayout(null);
p.setBounds(0,0,1024,768);
//initialiserer listener
btHeadline.addActionListen er(this);
btPictureText.addActionLis tener(this );
btText.addActionListener(t his);
btShow.addActionListener(t his);
btDate.addActionListener(t his);
tfFilename.addActionListen er(this);
chkPri.addItemListener(thi s);
}
//ActionEvent handler
public void actionPerformed(ActionEven t e)
{
String actionCommand = e.getActionCommand();
if ((e.getSource() instanceof Button) || (e.getSource() instanceof TextField))
{
if (actionCommand.equals("Skr iv Overskrift"))
{
Headline = tfHeadline.getText();
System.out.println(Headlin e);
}
else if (actionCommand.equals("Skr iv Bildetekst"))
{
//setter fonter,linjeskift,størrels e
PictureText = taPictureText.getText();
}
else if (actionCommand.equals("Skr iv Artikkel"))
{
//setter fonter,linjeskift,størrels e
Text = taText.getText();
}
else if (actionCommand.equals("Set t Dato"))
{
//set date
Date currentDate = new Date();
DateFormat fmt = getDateInstance(Locale.SHO RT);
//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.Item Event) 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.SHO RT);
String formatert = fmt.format(currentDate);
Please help.
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.lightG
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.
taText = new TextArea("",5,10,TextArea.
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
p.add(btPictureText);
btPictureText.setBounds(50
p.add(btText);
btText.setBounds(50,380,10
p.add(btSource);
btSource.setBounds(50,610,
//tekstfelt
p.add(tfHeadline);
tfHeadline.setBounds(250,5
tfHeadline.setFont(fontHea
p.add(taPictureText);
taPictureText.setBounds(25
taPictureText.setFont(font
p.add(taText);
taText.setBounds(250,380,2
p.add(tfSource);
tfSource.setBounds(250,610
//Bildedel
p.add(c);
c.setBackground(Color.gray
c.setBounds(600,50,180,200
p.add(btShow);
btShow.setBounds(600,300,1
p.add(tfFilename);
tfFilename.setBounds(750,3
p.add(btDate);
btDate.setBounds(600,360,1
//Checkboxer
p.add(chkPri);
chkPri.setBounds(600,420,1
//plasserer panelet i framen uten layout
add(p);
p.setLayout(null);
p.setBounds(0,0,1024,768);
//initialiserer listener
btHeadline.addActionListen
btPictureText.addActionLis
btText.addActionListener(t
btShow.addActionListener(t
btDate.addActionListener(t
tfFilename.addActionListen
chkPri.addItemListener(thi
}
//ActionEvent handler
public void actionPerformed(ActionEven
{
String actionCommand = e.getActionCommand();
if ((e.getSource() instanceof Button) || (e.getSource() instanceof TextField))
{
if (actionCommand.equals("Skr
{
Headline = tfHeadline.getText();
System.out.println(Headlin
}
else if (actionCommand.equals("Skr
{
//setter fonter,linjeskift,størrels
PictureText = taPictureText.getText();
}
else if (actionCommand.equals("Skr
{
//setter fonter,linjeskift,størrels
Text = taText.getText();
}
else if (actionCommand.equals("Set
{
//set date
Date currentDate = new Date();
DateFormat fmt = getDateInstance(Locale.SHO
//ERROR!!!!!
String formatert = fmt.format(currentDate);
}
else if (actionCommand.equals("Vis
{
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.
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.SHO
String formatert = fmt.format(currentDate);
Please help.
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();
java.util.Date
and
java.sql.Date
you must specify which one you want:
java.util.Date currentDate = new java.util.Date();
You had implemented the method but missed out 'd' in itemStateChanged(ItemEvent e).
> You had implemented the method but missed out 'd' in itemStateChanged(ItemEvent e).
So he didn't implement the method after all :-)
So he didn't implement the method after all :-)
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.lightG ray);
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,3 0);
p.add(btText);
btText.setBounds(50,380,10 0,30);
p.add(btSource);
btSource.setBounds(50,610, 100,30);
//tekstfelt
p.add(tfHeadline);
tfHeadline.setBounds(250,5 0,200,30);
tfHeadline.setFont(fontHea dLine);
p.add(taPictureText);
taPictureText.setBounds(25 0,150,200, 200);
taPictureText.setFont(font PictureTex t);
p.add(taText);
taText.setBounds(250,380,2 00,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,1 00,30);
p.add(tfFilename);
tfFilename.setBounds(750,3 00,200,30) ;
p.add(btDate);
btDate.setBounds(600,360,1 00,30);
//Checkboxer
p.add(chkPri);
chkPri.setBounds(600,420,1 00,30);
//plasserer panelet i framen uten layout
add(p);
p.setLayout(null);
p.setBounds(0,0,1024,768);
//initialiserer listener
btHeadline.addActionListen er(this);
btPictureText.addActionLis tener(this );
btText.addActionListener(t his);
btShow.addActionListener(t his);
btDate.addActionListener(t his);
tfFilename.addActionListen er(this);
chkPri.addItemListener(thi s);
}
//ActionEvent handler
public void actionPerformed(ActionEven t e)
{
String actionCommand = e.getActionCommand();
if ((e.getSource() instanceof Button) || (e.getSource() instanceof TextField))
{
if (actionCommand.equals("Skr iv Overskrift"))
{
Headline = tfHeadline.getText();
System.out.println(Headlin e);
}
else if (actionCommand.equals("Skr iv Bildetekst"))
{
//setter fonter,linjeskift,stxrrels e
PictureText = taPictureText.getText();
}
else if (actionCommand.equals("Skr iv Artikkel"))
{
//setter fonter,linjeskift,stxrrels e
Text = taText.getText();
}
else if (actionCommand.equals("Set t Dato"))
{
//set date
java.util.Date currentDate = new java.util.Date();
//DateFormat fmt = getDateInstance(Locale.US) ;
//ERROR!!!!!
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy yy");
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
--------------------------
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.lightG
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.
taText = new TextArea("",5,10,TextArea.
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
p.add(btPictureText);
btPictureText.setBounds(50
p.add(btText);
btText.setBounds(50,380,10
p.add(btSource);
btSource.setBounds(50,610,
//tekstfelt
p.add(tfHeadline);
tfHeadline.setBounds(250,5
tfHeadline.setFont(fontHea
p.add(taPictureText);
taPictureText.setBounds(25
taPictureText.setFont(font
p.add(taText);
taText.setBounds(250,380,2
p.add(tfSource);
tfSource.setBounds(250,610
//Bildedel
p.add(c);
c.setBackground(Color.gray
c.setBounds(600,50,180,200
p.add(btShow);
btShow.setBounds(600,300,1
p.add(tfFilename);
tfFilename.setBounds(750,3
p.add(btDate);
btDate.setBounds(600,360,1
//Checkboxer
p.add(chkPri);
chkPri.setBounds(600,420,1
//plasserer panelet i framen uten layout
add(p);
p.setLayout(null);
p.setBounds(0,0,1024,768);
//initialiserer listener
btHeadline.addActionListen
btPictureText.addActionLis
btText.addActionListener(t
btShow.addActionListener(t
btDate.addActionListener(t
tfFilename.addActionListen
chkPri.addItemListener(thi
}
//ActionEvent handler
public void actionPerformed(ActionEven
{
String actionCommand = e.getActionCommand();
if ((e.getSource() instanceof Button) || (e.getSource() instanceof TextField))
{
if (actionCommand.equals("Skr
{
Headline = tfHeadline.getText();
System.out.println(Headlin
}
else if (actionCommand.equals("Skr
{
//setter fonter,linjeskift,stxrrels
PictureText = taPictureText.getText();
}
else if (actionCommand.equals("Skr
{
//setter fonter,linjeskift,stxrrels
Text = taText.getText();
}
else if (actionCommand.equals("Set
{
//set date
java.util.Date currentDate = new java.util.Date();
//DateFormat fmt = getDateInstance(Locale.US)
//ERROR!!!!!
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy
String formatert = fmt.format(currentDate);
}
else if (actionCommand.equals("Vis
{
displayImage();
}
}
}
public void itemStateChanged(ItemEvent
{
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
ASKER
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.
You were right about the 'd', but adding it did not solve the problem.
Please say whether you still need help
Oh, and please get CS to delete the duplicates.
ASKER
Yes I do. Still getting the same error:
ArticleInterface should be declared abstract; it does not define itemStateChanged(java.awt. event.Item Event) in ArticleInterface
ArticleInterface should be declared abstract; it does not define itemStateChanged(java.awt.
... and please also state the exact error message you are getting.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RayGun did you try my suggestion?
... 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.
ASKER
Well you'll have to substitute the capital 'I' to 'i' in itemStateChanged...
Thnx, god damn I need a break. :)
Thnx, god damn I need a break. :)
Hmm I do not see why my *solution* wouldn't satisfy you.
I think that qirionis have already suggested this.
At least his problem is solved. :-)
ASKER
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.
Please clean up the question mess with CS now RayGun.
Now I feel like a point thief :-( I'll hand the points over to girionis asap :-)
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.
RayGun you're welcome. I am glad we all helped you.
Too late... already posted the question... So go pick those points up... or else... ;-)
ArticleInterface should be declared abstract; it does not define itemStateChanged(java.awt.
Since you implement interfaces you need to implement all of their methdos. Just add the following in your code:
public void itemStateChanged(java.awt.
> 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;