Home Answers Viewqa Java-Beginners illeagal character error....

 
 


Pradyumna Sahoo
illeagal character error....
1 Answer(s)      a year and 6 months ago
Posted in : Java Beginners

Here is my code:

import java.io.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import javax.swing.filechooser.*;
import javax.imageio.*;
import java.awt.image.*;


                class MainScreen{
                        JFrame screen;
                        JButton select;
                        JScroolPane jsp;
                        JLabel filename;
                        JPanel frontpanel;
                        ImagePanel impanel;
`                       Container container;
                        File imagefiel;
                        MainScreen(){
                                screen= new JFrame("Image viewer by P Sahoo");
                                select= new Button("Select a File");
                                select.addActionListener(new SelectHandler());
                                filename=JLabel("File :");
                                container=screen.getContentPane();
                                container.add(select,BorderLayout.NORTH);
                                container.add(filename,BorderLayout.SOUTH);
                                screen.setDefaultClosdeOperation(JFrame.EXIT_ON_CLOSE);
                                screen.setSize(400,400);
                                screen.setVisible(true);
                                    }

                    class SelectHandler implements ActionListener{

                        public void actionPerformed(ActionEvent e){
                            JFileChooser chooser=new JFileChooser();
                            FileNameExtensionFilter filter=new FileNameExtensionFilter("JPG & Images","jpg","gif");
                            chooser.setFileFilter(filter);
                            int returnvalue=chooser.showOpenDialog(screen);
                            if(returnvalue==JFileChooser.APPROVE_OPTION)
                                imagefile=chooser.getSelectFile();
                            filename.setText("File :" +imagefile.getAbsolutePath());

                                try{
                                    BufferedImage image=ImageIO.read(imagefile);
                                    ImagePanel ip=new ImagePanel(image);
                                        if(jsp!=null){
                                        container.remove(jsp);
                                        container.validate();

                                        }

                            int VSB=ScrollPaneConstants.VERTICAL_SCROOLBAR_AS_NEEDED;

                            int HSB=ScroolPaneConstants.HORIZONTAL_SCROOLBAR_AS_NEEDED;
                                jsp=new JScrollPane(ip,VSB,HSB);
                                container.add(jsp);
                                    } catch(IOException e1){
                                        System.out.println(e1);
                                        }
                                    System.out.println(chooser.getSelectedFile().getName());
                                    }                       
                                    }

                            public static void main(String args[]){

                            new MainScreen();
                                        }

                                            }
                                class ImagePanel extends Jpanel{

                                    BufferedImage image;
                                    ImagePanel(){
                                             }
                                    ImagePanel(BufferedImage image){
                                this.image=image;
                                setPreferredSize(new Dimension(image.getWidth(),image.getHeight()));
                                setBorder(new EtchedBorder());
                                            }
                                    public void paint(Graphics g){
                                        System.out.println("panel pained.."+image.getWidth());
                                        g.drawImage(image,0,0,image.getWidth(),image.getHeight(),null);

                                                    }
                                        }
error:
MainScreen.java:19: illegal character: \96
`                       Container container;
^
MainScreen.java:19: ';' expected
`                       Container container;
 ^
MainScreen.java:19: <identifier> expected
`                       Container container;
                                           ^
3 errors








##

  • List item

View Answers

November 7, 2011 at 11:33 AM


import java.io.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import javax.swing.filechooser.*;
import javax.imageio.*;
import java.awt.image.*;

class ImagePanel extends JPanel{

     BufferedImage image;
       ImagePanel(){
       }
     ImagePanel(BufferedImage image){
       this.image=image;
     setPreferredSize(new Dimension(image.getWidth(),image.getHeight()));
     setBorder(new EtchedBorder());
                                            }
    public void paint(Graphics g){
     System.out.println("panel pained.."+image.getWidth());
    g.drawImage(image,0,0,image.getWidth(),image.getHeight(),null);

                                                    }
                                        }
                class MainScreen{
                        JFrame screen;
                        JButton select;
                        JScrollPane jsp;
                        JLabel filename;
                        JPanel frontpanel ;

                        File imagefile ;
                        MainScreen(){
                                screen= new JFrame("Image viewer by P Sahoo");
                                select= new JButton("Select a File");
                                select.addActionListener(new SelectHandler());
                                filename=new JLabel("File :");
                                screen.add(select,BorderLayout.NORTH);
                                screen.add(filename,BorderLayout.SOUTH);
                                screen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                                screen.setSize(400,400);
                                screen.setVisible(true);
                                    }

                    class SelectHandler implements ActionListener{

                        public void actionPerformed(ActionEvent e){
                            JFileChooser chooser=new JFileChooser();
                            FileNameExtensionFilter filter=new FileNameExtensionFilter("JPG & Images","jpg","gif");
                            chooser.setFileFilter(filter);
                            int returnvalue=chooser.showOpenDialog(screen);
                            if(returnvalue==JFileChooser.APPROVE_OPTION)
                                imagefile=chooser.getSelectedFile();
                            filename.setText("File :" +imagefile.getAbsolutePath());

                                try{
                                    BufferedImage image=ImageIO.read(imagefile);
                                    ImagePanel ip=new ImagePanel(image);
                                        if(jsp!=null){
                                        screen.remove(jsp);
                                        screen.validate();

                                        }

                            int VSB=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;

                            int HSB=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                jsp=new JScrollPane(ip,VSB,HSB);
                                screen.add(jsp);
                                    } catch(IOException e1){
                                        System.out.println(e1);
                                        }
                                    System.out.println(chooser.getSelectedFile().getName());
                                    }                       
                                    }

                            public static void main(String args[]){

                            new MainScreen();
                                        }

                                            }









Related Pages:
illeagal character error....
illeagal character error....   Here is my code: import java.io....); } } error: MainScreen.java:19: illegal character: \96 ` Container container
character literal in octal format
;>> EscapeSequence1.java:6: error: unclosed character literal char... ^ EscapeSequence1.java:6: error: unclosed character literal char ch2...character literal in octal format  class EscapeSequence1 { public
Unknown Character set: 'utf8mb4'.
Unknown Character set: 'utf8mb4'.  While working on eclipse on an application that uses MySQL as the back end for the database, I was having error..., it generates an error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorEx ception
word and character counting - Java Beginners
word and character counting  here is the java code i made but i have to add something where it will read the inFile and display the number of words...) { JOptionPane.showMessageDialog(null, "Error:" + x1); System.exit(0
Adding slash "\" character before quote "'" in a query
Adding slash "\" character before quote "'"...; Adding slash "\" character before quote "'"... the phrases like "What's your name?", database gives the error due
Character Class
Character Class  Character defines the forDigit();,digit()methods..how can these b used and wht is radix point signifies here...in the arguments of these two???..pls answer a code on this with radix .. are these methods also
underscore as character
underscore as character  how can i consider _ as a character instead of wildcard character? my problem is like this i have 20 records as follows manohar 1234455 manohar 453635 manohar 345454 manohar_1234455 now when i am
Character class
Character class   Character defines the forDigit();,digit()methods..how can these b used and wht does radix point signify here.i want to knw what basically radix is??here in the arguments of these two???because i tried runnin
SQL Error - SQL
SQL Error  Invalid character value for cast specification on column number 5 (Designation) Whats this error about this if the field i specified in programming error. ie DB fields in above question
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
How to convert entity character to html character
How to convert entity character to html character  Please help me to "convert entity character to html character" in java. If possible please provide source code which take String as input and return as String
Summary - Character
Java: Summary - Character Character class static methods In this section we will see the static methods of Character class. Character class of Java API... for manipulating the strings. Most important use of Character class is to convert the data
replace character in php
replace character in php  PHP script that replace character
SQL QUERY ERROR
THE FORM IS THROWING THE ERROR OF INVALID CHARACTER BUT THE SAME QUERY IS RUNNING...SQL QUERY ERROR  Im writing a query which shows error of INVALID CHARACTER The Query is Insert into PMST_EMP_MST(PMSNUM_EMP_ID,PMSSTR_EMP
readline Error - Java Beginners
not work. The readLine () method seems to loose the first character of the string... abcd, the firt time it prints it correctly, every other time the first character...; Hi Friend, Your code works fine here. Thanks  The error
ERROR - Java Beginners
ERROR  Hello Sir i am getting error to this code 1.write... character of each string then next characterof each so on? this is urgent send... am getting an error that is StringProgram.java:6: cannot resolve symbol
please fix the error
to compile class for JSP: An error occurred at line: 14 in the jsp file: /doctor.jsp Invalid character constant 11: Connection con...: { ///////////@@@@the above mentioneed is error and code is as follows
Compile error - Java Beginners
Compile error  I get this error when compiling my program: java:167... to be thrown tc.countLines(inFile); ^ 1 error... on a space character if (splitStr.length > 0
Character Wrapper Class.
Character Wrapper Class.  what are Mirrored Unicode Characters?? and whats the use of "isMirrored(ch);method ??.where ch is any character argument.... There are special characters in UNICODE to achieve the RTL. Such character is the Mirroring
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
password validation with special character
password validation with special character  how to validate password with special character using java script
error
error  while iam compiling iam getting expected error
JavaScript regex validate Character
Character.   <html> <head> <title>Character validation... Character value : "+name); return true; } alert("It is not valid character !"); return false; } </script> <
JavaScript regex validate Character
Character   <html> <head> <title>Character validation... Character value : "+name); return true; } alert("It is not valid character !"); return false; } </script> <
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
What is Character Functions
What is Character Functions  What is Character Functions   Hi, Here is the answer, Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST. Group Functions
Character Directions in java
Character Directions in java  java 2,version 1.4 adds a method "getDirectionality();" , what is the use of this method ?   This method returns the Unicode directionality property for the given character. Character
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
Wrapper Character class.
Wrapper Character class.  How do the methods 'isIndentifierIgnorable(ch)' and 'isISOControl(ch)' work?? while workin with 'Character' wrapper class...: This method returns true if the character may be part of a Unicode identifier; false
Programming error - Java Beginners
.") return false } //get the zero-based index of the "@" character
Replace Character in String
Replace Character in String        This example replaces a character with a specified character in a given string. To replace a character with the given character in sting first
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
Alphabet Character Case-Converter
Alphabet Character Case-Converter   ... a character (uppercase) into a lowercase character. The java.lang package provides the functionality to convert the uppercase character into a lowercase character
J2ME count character into string
J2ME count character into string  i am new in J2ME, my problem is how to count character into number, i had been research google for almost 2 days... form which allow user to input character user input helloworld then press
Determining the type of Character
Determining the type of Character In this section, you will learn how to determine the type of a character. You can use the methods of Character class to determine the properties of a character. This class provides several methods
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version. This type error also comes when java file
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
Count the character in java
Count the character in java  Write a java program to count the character ââ?¬Ë?aââ?¬â?¢ typed by the user in a paragraph by implementing thread.   Count characters by implementing thread import java.util.*; class
Character count by while loop
Character count by while loop  Write the program to count the number of characters entered until a full stop (.)is keyed-in. Anyone there pls help...]) flag=true; } if(!flag){ System.out.println("Character :"+ch+" occurs "+count
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.