Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3658
| From | "Lew" <lew@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Returning a textliste |
| Message-ID | <Ro-dnTXr3NqG18XVnZ2dnUVZ_qydnZ2d@comcast.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <35cdaa95-e9e9-423c-ba6a-49e67b429cc2@q24g2000prf.googlegroups.co |
| Date | 2011-04-27 15:46 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Chris wrote:
> My problem is I have
> tried putting in a method that returns the text. However, both options
> (shown below) wont compile. I know I'm doing something wrong, but
> can't figure it out. Here is what I have:
Excessive blank lines elided:
> import javax.swing.*;
> import java.awt.*;
> import java.awt.event.*;
>
> import javax.swing.JFrame;
>
> public class InputListenerII extends JFrame
> {
>
> public static void main (String [] args)
> {
> new InputListenerII();
> }
>
> public InputListenerII ()
Geez, Louise! Lighten up on the wide indentation!
Two spaces is plenty for Usenet.
> {
> this.setSize(300,300);
> this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> this.setTitle("ALiiS");
>
> JPanel panel1 = new JPanel();
> Clisten atl = new Clisten();
> TextField t = new TextField();
> t.setSize(300, 300);
> t.addTextListener(atl);
>
> add ( t ) ;
> this.add(panel1);
> this.setVisible (true);
> //t.removeTextListener(atl);
> }
>
>
> public class Clisten implements TextListener
> {
> public void textValueChanged ( TextEvent e )
> {
> TextComponent tc = (TextComponent)e.getSource();
> String inputRules = tc.getText();
> System.out.println(inputRules);
>
> // I cant add the method here. Wont compile. public String
> wordsOut()
Of course not. You cannot declare a method inside another method!
> // {
> // return inputRules;
> // }
>
> }
> //And I cant add the method here b/c the String inputRules cannot be
> resolved public String wordsOut()
Because you don't define it in this method. You have to define it, as a
method argument, a class member, or something. As a method argument, you have
a way to declare it and get it into the method.
> // {
> // return inputRules;
> // }
OK, your whitespace is crazy. You have eight TABs (anathema on Usenet) and 30
spaces indentation on these lines. Come on, have a heart for the people from
whom you are requesting aid.
> }
>
> }
I recommend a thorough study of the tutorial:
<http://java.sun.com/docs/books/tutorial/java/index.html>
--
Lew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread
Re: Returning a textliste "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
csiph-web