Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Pradyumna Sahoo
illeagal character error....
1 Answer(s)      3 years and 2 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


Advertisement
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 Tutorials/Questions & Answers:
illeagal character error....
illeagal character error....   Here is my code: import java.io....); } } error: MainScreen.java:19: illegal character: \96 ` Container container
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
Advertisements
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
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 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
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
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
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
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
replace character in php
replace character in php  PHP script that replace character
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
How to display string or character
How to display string or character  how to print character or a word without using array concept
password validation with special character
password validation with special character  how to validate password with special character using java script
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
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
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> <
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
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
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
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
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  while iam compiling iam getting expected error
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
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
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
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
 

 

 

DMCA.com