473,441 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Help me in using mouselistener

the follwing is the program I wrote to create a NOTEPAD.... After writing this code I get 3 error all at the 85th line....

Layout.java:85: illegal start of expression
void mouseClicked(MouseEvent e)
^
Layout.java:85: ';' expected
void mouseClicked(MouseEvent e)
^
Layout.java:85: ';' expected
void mouseClicked(MouseEvent e)


plz help me I m a newbie... The code is still not complete... Actually I had jst created my frame and had started working on the events.....


Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import javax.swing.*;
  3.  
  4. public class Layout extends JFrame
  5. {
  6.     static void createLayout()
  7.     {
  8.  
  9.         ////////////////////////////////////////////////////////////////////////////////////////////
  10.         //                   CREATING MENUBAR AND TEXT AREA         //
  11.         ///////////////////////////////////////////////////////////////////////////////////////////
  12.  
  13.         JMenuBar mb = new JMenuBar();
  14.         JMenu file = new JMenu("File");
  15.         JMenu edit = new JMenu("Edit");
  16.         JMenu format = new JMenu("Format");
  17.         JMenu view = new JMenu("View");
  18.         JMenu help =new JMenu("Help");
  19.         JTextArea tx1 = new JTextArea();
  20.  
  21.         ////////////////////////////////////////////////////////////////////////////////////////////
  22.         //            CREATING MENU ITEMS FOR FILE            //
  23.         ///////////////////////////////////////////////////////////////////////////////////////////
  24.  
  25.         JMenuItem New = new JMenu("New");
  26.         JMenuItem Open = new JMenu("Open");
  27.         JMenuItem Save = new JMenu("Save");
  28.         JMenuItem SaveAs = new JMenu("Save As");
  29.         JMenuItem Exit = new JMenu("Exit");
  30.  
  31.         ////////////////////////////////////////////////////////////////////////////////////////////
  32.         //            CREATING MENU ITEMS FOR EDIT            //
  33.         ///////////////////////////////////////////////////////////////////////////////////////////
  34.  
  35.         JMenuItem Undo = new JMenu("Undo");
  36.         JMenuItem Cut = new JMenu("Cut");
  37.         JMenuItem Copy = new JMenu("Copy");
  38.         JMenuItem Paste = new JMenu("Paste");
  39.         JMenuItem Search = new JMenu("Search");
  40.  
  41.         ////////////////////////////////////////////////////////////////////////////////////////////
  42.         //         ADDING MENU ITEMS IN FILE OPTION        //
  43.         ///////////////////////////////////////////////////////////////////////////////////////////
  44.  
  45.         file.add(New);
  46.         file.add(Open);
  47.         file.add(Save);
  48.         file.add(SaveAs);
  49.         file.add(Exit);
  50.  
  51.         ////////////////////////////////////////////////////////////////////////////////////////////
  52.         //         ADDING MENU ITEMS IN EDIT OPTION        //
  53.         ///////////////////////////////////////////////////////////////////////////////////////////
  54.  
  55.         edit.add(Undo);
  56.         edit.add(Cut);
  57.         edit.add(Copy);
  58.         edit.add(Paste);
  59.         edit.add(Search);
  60.  
  61.         ////////////////////////////////////////////////////////////////////////////////////////////
  62.         //                 ADDING MENUBAR TO FRAME                //
  63.         ///////////////////////////////////////////////////////////////////////////////////////////
  64.  
  65.         mb.add(file);
  66.         mb.add(edit);
  67.         mb.add(format);
  68.         mb.add(view);
  69.         mb.add(help);
  70.  
  71.         ////////////////////////////////////////////////////////////////////////////////////////////
  72.         //             CREATING THE FRAME            //
  73.         ///////////////////////////////////////////////////////////////////////////////////////////
  74.  
  75.         JFrame f = new JFrame();
  76.         f.setSize(800,500);
  77.         f.setTitle("Notepad");
  78.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  79.         f.setVisible(true);
  80.         f.setJMenuBar(mb);
  81.         f.getContentPane().add(tx1);
  82.  
  83.         New.addMouseListener(this);
  84.  
  85.         public void mouseClicked(MouseEvent e)
  86.         {
  87.             tx1.setText("It Works!!");
  88.         }
  89.     }    
  90. }
  91.  
  92. class Npad extends Layout
  93. {
  94.     public static void main(String...args)
  95.     {
  96.         createLayout();
  97.     }
  98. }
  99.  
Jul 30 '10 #1
0 1080

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mattigiat | last post by:
Sorry for being such a newbie in this respect, but here's my question: I have Visual Studio, with VB6 ent., with msdn help installed. Is there any way to downgrade to just using the VB5 help, on...
1
by: Minti | last post by:
Hi there all, I am having a weird problem in the following Applet code, <begin code> public class MouseInputTester extends java.applet.Applet { private String msg = ""; private int mouseX ;...
2
by: Tony Teoh | last post by:
All, Current Im develop a program that using web page to connect to Oracle. My difficulties was: 1) How to retrieve the information in tnsnames.ora and put into all connection string into a...
1
by: Christopher Reeve | last post by:
Hi, I wonder if anyone could help me. I am moving accross from C to C++ and am writing a program that reads and writes data into a file. I am aware of the old C ways of doing it but am trying to...
9
by: J. Campbell | last post by:
I'm comfortable with arrays from previous programming, and understand the advantages of c++ vectors...I just don't understand how to use them :~( Can you help me to use a vector<string> in the...
3
by: rjaw | last post by:
Hi there, using the udb-type2-driver on z/OS DB version 7, we have a problem getting the connection to the database. The small program we use looks like this: ...
4
by: Sai | last post by:
Hi, I am using VSTO 2005 Beta for building an excel application. I added application configuration file to the project (app.config) and it has the following section in it. <configuration>...
1
by: tezza98 | last post by:
I need some help. Im using a dtsrun command to import 9 tables into an Access database, most of the tables have about 1000 rows, but one has 20000+ rows and grows everyday. Im Using Access 2003...
2
by: coaxfiber | last post by:
Hi, I'm working with my script like this. First file -> help.sh - Below the text contained in the file: -------------------------------------------------------------------------------- #!/bin/ksh...
5
by: =?Utf-8?B?U2llZ2ZyaWVkIEhlaW50emU=?= | last post by:
Can someone help me convert this to the latest C# syntax using predicate/delegate? You can see my attempt in the comments. Also: how would I set a new font for q_ul? q_ul is a WPF TextBlock and I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.