• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Errors when compiling this code

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am only a learner coder. I am having trouble with this code here. I am hoping someone can give me a few hinters with what i need to do. I keep getting the error

import java.lang.Object.*;
> import java.awt.*;
> import javax.swing.*;
>
> public class JDisplay
> {
> private Maximum in;
> private JWindow win;
> private int maxValue;
> private JTextArea text;
> private int[] values;
> private int counter;
>
> public JDisplay()
> {
> in = new Maximum();
> maxValue = in.getMax();
> win = new JWindow(0, 0, 300, 300);
> text = new JTextArea(0,0,300,300);
>>>>>>>>>>>>>>>>>>>>>>>> Error here saying cant find Symbol -
constructor

JWindow(int,int,int,int)
> text.setBackground(Color.yellow);
> text.setFontSize(20);
> values = in.getValues();
> for (int i = 0; i < maxValue; i++){
> text.appendln("Frog");
>
> }
> for (int j = 0; j < in.getCounter();j++){
> text.append(values[j]+ " ");
> }
> text.place(win);
> win.repaint();
> }
>
>
> }
>
> Maximum Class
> import java.util.*;
>
> public class Maximum{
> private int max;
> private int[] values;
> private int counter;
>
> public Maximum(){
> Scanner input = new Scanner(System.in);
> values = new int[30];
> int num = 0;
> int i = 0;
> System.out.println("Enter an integer");
> while(input.hasNext()){
> if (input.hasNextInt()){
> num = input.nextInt();
> values[counter++] = num;
> if (num > max) max = num;
> }
> else{
> if (input.findInLine("exit") != null) break;
> }
> }
> System.out.println("The max is " + max);
> }
>
> public int getMax(){
> return max;
> }
> public int[] getValues(){
> return values;
> }
> public int getCounter(){
> return counter;
> }
> }
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could see the following problems

You do not need to import java.lang.* package.

The following line is wrong:
import java.lang.Object.*;
there is no java.lang.Object package.

There is no constructor in JTextArea object which accepts 4 integer values. So the following line is wrong:
text = new JTextArea(0,0,300,300);

Not sure if there are more problems in your code.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What error is it you're getting? Post the full stack trace.
 
Sam Coote
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the error is cant find Symbol -
constructor JWindow(int,int,int,int)

do you have any coding suggestions i could use
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sam Coote:
the error is cant find Symbol -
constructor JWindow(int,int,int,int)

do you have any coding suggestions i could use



Look at the following Java api for valid constructors for JTextArea:
JTextArea

As Ulf suggested if you tell what errors you are getting or post full stack trace it is easier to guide you.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the error is cant find Symbol - constructor JWindow(int,int,int,int)

do you have any coding suggestions i could use



Yes - use a constructor that actually exists JWindow does not have a constructor that takes 4 ints, just like the error message suggests.
 
Everybody! Do the Funky Monkey! Like this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic