🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #141767

JTextField i migajacy kursor

#141767
From: wybierzdomene
Date: Sat, 18 Oct 2008 21:39
54 lines
2713 bytes
Witam. Wpisuje jakies zdanie w JTextField nastepnie klikam submit. Jak
to zrobic by po wykonaniu actionPerformed pojawil sie znowu migajacy
kursor w polu JTextField ??
Dziekuje



*************************************************************************************
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;

class Ramka extends JFrame implements KeyListener, ActionListener {
    JTextField jtf;
    JButton submit;

    Ramka() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(400,70);
        setLocation(300,80);

        Container cont = getContentPane();
        jtf = new JTextField("");
        jtf.addKeyListener(this);

        submit = new JButton("submit");
        submit.addActionListener(this);
        cont.add(submit, BorderLayout.SOUTH);
        cont.add(jtf, BorderLayout.NORTH);
    }
    public void keyPressed(KeyEvent event) {}
    public void keyReleased(KeyEvent event) {}
    public void keyTyped(KeyEvent event) {
        event.getKeyChar();
    }
    public void actionPerformed(ActionEvent event) {
        if (event.getSource() == submit) {
            System.out.println(jtf.getText());
            jtf.setText("");
        }
    }
}

public class CosTam {
    public static void main(String[] args) {
        (new Ramka()).setVisible(true);
    }
}
Technical Details
Message-ID: <efcced18-31b4-4db2-b182-bb8b0e6f9873@u75g2000hsf.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!news.nask.pl!news.nask.org.pl!news.germany.com!postnews.google.com!u75g2000hsf.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!news.nask.pl!news.nask.org.pl!news.germany.com!postnews.google.com!u75g2000hsf.googlegroups.com!not-for-mail
From: wybierzdomene <wybierzdomene@gmail.com>
Newsgroups: pl.comp.lang.java
Subject: JTextField i migajacy kursor
Date: Sat, 18 Oct 2008 14:39:37 -0700 (PDT)
Organization: http://groups.google.com
Lines: 54
Message-ID: <efcced18-31b4-4db2-b182-bb8b0e6f9873@u75g2000hsf.googlegroups.com>
NNTP-Posting-Host: 199.243.239.9
Mime-Version: 1.0
X-Trace: posting.google.com 1224365977 7221 127.0.0.1 (18 Oct 2008 21:39:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 18 Oct 2008 21:39:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: u75g2000hsf.googlegroups.com; posting-host=199.243.239.9;  posting-account=FbL4eAoAAABOMabO3z2jLE-f75sWS_PZ
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.16)  Gecko/20080702 Firefox/2.0.0.16,gzip(gfe),gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit