hi friends i'm not able to debug this code please tell me wht is wrong here... - import java.awt.*;
-
import java.awt.event.*;
-
import java.swing.*;
-
class test extends JFrame implements ActionListener
-
{
-
-
JButton b1;
-
JTextField Tf1;
-
public test()
-
{
-
b1=new JButton("1");
-
Tf1=new TextField(10);
-
-
setLayout(new Frlowlayout());
-
-
add(b1);
-
add(Tf1);
-
-
addActionListener(this);
-
-
setSize(200,200);
-
setVisible(true);
-
-
}
-
public void actionPerformed(ActionEvent e)
-
if (e.getSource() == b1)
-
{
-
Tf1.setText("1");
-
}
-
public static void main(String args[])
-
{
-
test t=new test();
-
}
-
}
14 1440 Nepomuk 3,112
Recognized Expert Specialist -
import java.awt.*;
-
import java.awt.event.*;
-
import javax.swing.*; // Correction 1
-
class test extends JFrame implements ActionListener
-
{
-
-
JButton b1;
-
JTextField Tf1;
-
public test()
-
{
-
b1=new JButton("1");
-
Tf1=new JTextField(10); // Correction 2
-
-
setLayout(new Frlowlayout()); // What should that be?
-
-
add(b1);
-
add(Tf1);
-
-
addActionListener(this); // This IS an ActionListener - why do you want to add one?
-
-
setSize(200,200);
-
setVisible(true);
-
-
}
-
public void actionPerformed(ActionEvent e) // Correction 3
-
{
-
if (e.getSource() == b1)
-
{
-
Tf1.setText("1");
-
}
-
}
-
public static void main(String args[])
-
{
-
test t=new test();
-
}
-
}
-
hi friends i'm not able to debug this code please tell me wht is wrong here... - import java.awt.*;
-
import java.awt.event.*;
-
import java.swing.*;
-
class test extends JFrame implements ActionListener
-
{
-
-
JButton b1;
-
JTextField Tf1;
-
public test()
-
{
-
b1=new JButton("1");
-
Tf1=new TextField(10);
-
-
setLayout(new Frlowlayout());
-
-
add(b1);
-
add(Tf1);
-
-
addActionListener(this);
-
-
setSize(200,200);
-
setVisible(true);
-
-
}
-
public void actionPerformed(ActionEvent e)
-
if (e.getSource() == b1)
-
{
-
Tf1.setText("1");
-
}
-
public static void main(String args[])
-
{
-
test t=new test();
-
}
-
}
Frlowlayout should have been FloorLayout?
Nepomuk 3,112
Recognized Expert Specialist
Frlowlayout should have been FloorLayout?
Probably FlowLayout. ^^
Hi
Line setLayout(new Frlowlayout());
is wrong It should be written as
setLayout(new Flowlayout());
Rest is o.k.
Frlowlayout should have been FloorLayout?
Oh yeah, thanks.
JosAH 11,448
Recognized Expert MVP
Do not add JComponents to a JFrame directly. Get the JFrame's content pane
(see the API docs) and add your components to that pane instead.
kind regards,
Jos
[PHP]import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
class test extends JFrame implements ActionListener
{
JButton b1;
JTextField Tf1;
public test()
{
b1=new JButton("1");
Tf1=new JTextField(10);
setLayout(new Flowlayout());
add(b1);
add(Tf1);
addActionListen er(this);
setSize(200,200 );
setVisible(true );
}
public void actionPerformed (ActionEvent e)
if (e.getSource() == b1)
{
Tf1.setText("1" );
}
public static void main(String args[])
{
test t=new test();
}
}[/PHP]
after compiling geting this error... - C:\test.java:26: ';' expected
-
if (e.getSource() == b1)
JosAH 11,448
Recognized Expert MVP
[PHP]import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
class test extends JFrame implements ActionListener
{
JButton b1;
JTextField Tf1;
public test()
{
b1=new JButton("1");
Tf1=new JTextField(10);
setLayout(new Flowlayout());
add(b1);
add(Tf1);
addActionListen er(this);
setSize(200,200 );
setVisible(true );
}
public void actionPerformed (ActionEvent e)
if (e.getSource() == b1)
{
Tf1.setText("1" );
}
public static void main(String args[])
{
test t=new test();
}
}[/PHP]
after compiling geting this error... - C:\test.java:26: ';' expected
-
if (e.getSource() == b1)
See how you defined your, eg, main method; spot the diferences from your
actionPerformed method (don't mention 'static').
kind regards,
Jos
See how you defined your, eg, main method; spot the diferences from your
actionPerformed method (don't mention 'static').
kind regards,
Jos
Not geting wht u want to say i'm novice in java....
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joseph |
last post by:
hi
1) i plan on having an awt canvas component (to draw graphs) on a JFrame
with other swing components..will this be okay? i've read that swing and
awt aren't compatible..
2)Also, if i have a function which simply loops infinately that is part of a
form, what happens when a form event (eg button click) occurs? will the
event handler be executed simulatanesouly with the loop? or does the event
excecute first and then the loop is...
|
by: Ted Byers |
last post by:
This is quite frustrating! In the documents, and in the newsgroups, I see
simple instructions like the following:
===============================================
==========Beginning of Ray's example=================
===============================================
Suppose you want to run class com.xyz.Main. Then create a manifest file
like this:
======== main.mf starts on the next line ====
|
by: stu7 |
last post by:
+ I have some problems with QT. I know that it is supposed
to be useful for compiling cross-platform versions of a program,
and that it has something to do with C++ ...not a problem so far.
But - if QT compilies a program for Linux (my interest)... why
do I have to install QT (again) to use it ? It seems it hasn't
compiled -FOR- Linux at all, but is only using the Linux framework
to run itself on_ acting more like a virus than a...
|
by: Rob Heersma |
last post by:
Hello,
A couple of days I am trying to install Protege on my computer
together with the owl plugin. But perpetually I receive the same
understanding attached problem. I have installed Protege 2.0 beta
build 119 as well as build 121. For the Java virual machine I used
j2sdk1.4.2_03. Do You have any notice of what the problem could me?
Kinds regards,
Rob Urlings
|
by: Suzie |
last post by:
Hello,
I'm only new at this so please bear with me! I am creating an ontology
for a color game and i am using the pizza tutorial as a basis for it.
I did everything and when I went to save the file I get a message saying
save project errors with these error messages:
java.lang.RuntimeException: horrible http://www.owl-ontologies.com/unnamed.owl#0000
at
com.hp.hpl.jena.shared.impl.PrefixMappingImpl.checkProper
| |
by: Erik |
last post by:
Hi Everyone,
I'm having real problems compiling some source for eVC4++. The errors
I am getting are below:
It all seems to be centred around winsock. If I move the afsock.h
reference to before my other includes then I get lots of errors like
C2011: 'fd_set' : 'struct' type redefinition
warning C4005: 'FD_CLR' : macro redefinition
which I understand are due to the fact that windows.h is being
included in another header file as well as...
|
by: matvdl |
last post by:
I have a system that was originally developed in asp - the pages are saved in
SQL (there are over 10,000 pages) and saved to a temp directory in the server
when requested by a client.
I have updated this system and changed the pages that are saved to the
server as aspx - everything works fine and pages can be served - but
Its not impossible for a single client to request 100 plus pages in one
session - as each page is requested it is...
|
by: carlos123 |
last post by:
hello, i am making a hall pass program for my computer programming class. i am having issues with my jcheckboxes. first off. this file reads from a .txt that just has
greg
john
joe
54343
45777
33444
in it. after the user puts in a correct id number, it displays 4 checkboxes to where they want to go. bathroom, office, nurse, and other. once the user clicks one of the checkboxes, it will remove all the stuff from the panel, and add the...
|
by: risk32 |
last post by:
Hi all. I have a really confusing problem. I'm using Swing and I'm trying to do a confirmation box :
int reply;
String message = "Do you want to input another number?";
String title = "Input Another Number?";
reply = (JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.NO_OPTION) {
System.exit(0); }
This part works great, now down to business:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |