Revision as of 14:36, 12 December 2011 by Jhavlin (Talk | contribs)

This is an example on how to get inout from the Output Window. Just change what's done on the read method (listener implementation) to customize the behavior. Things that come to mind: chat client, text based games, etc...

 * Enable/create the tabs we need for the component
package sample.component;

import com.dreamer.outputhandler.InputMonitor;
import com.dreamer.outputhandler.OutputHandler;
import org.jivesoftware.smack.util.ReaderListener;
import org.openide.modules.ModuleInstall;

 * Manages a module's lifecycle. Remember that an installer is optional and
 * often not needed at all.
public class Installer extends ModuleInstall implements ReaderListener {

    private final String normal = "Output";

    public void restored() {
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {

            public void run() {
                OutputHandler.output(normal, "Welcome! Type something below.");
                //Create a monitor for the tab. This enables input in the tab as well.
                InputMonitor monitor = OutputHandler.createMonitor(normal);
                //Add a listener to be notified.

    public void read(String read) {
        OutputHandler.output(normal, "You typed: " + read);

Note: This is feature is available on the Output Handler plugin version 1.2.

Example of using input reader in output window

package org.netbeans.jhavlin.faqreview;

import java.awt.EventQueue;
import org.openide.modules.ModuleInstall;

public class Installer extends ModuleInstall {

    public void requestAnswerExample() throws IOException {
        assert !EventQueue.isDispatchThread();
        InputOutput io = IOProvider.getDefault().getIO("ioName", true);;
        io.getOut().println("How are you?");
        BufferedReader br = new BufferedReader(io.getIn());
        String answer = br.readLine();
        io.getOut().println("You are " + answer + " today");
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo