English 中文(简体)
我怎么能把我的法典产出作为关键影响?
原标题:How can I make I make my code output as keystrokes?

How can I make I make my code output as keystrokes? I know I have to use the Robot class, but how can I make it output for an object?

import java.util.HashSet;
import java.util.Set;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class MainClass {

public static Set<String> generatePowerSet(String inputString)
{
    Set<String> result = new HashSet<String>();
    result.add(""); // empty string is an element of the power set

    if (inputString != null && !inputString.isEmpty())
    {
        int n = 1 << inputString.length(); //2^n - the number of elements in the power set 
        StringBuilder sb = new StringBuilder();

        for (int i = 1; i < n; i++) // skip empty set, i = 0
        {
            int k = i; // current number to manipulate
            sb.delete(0, sb.length()); // clear the StringBuilder
            for (int index = 0; index < inputString.length() && k > 0; index++) // break early when k == 0
            {
                if ((k & 1) == 1) // include char at index if bit at that index is 1
                {
                    sb.append(inputString.charAt(index));
                }
                k >>= 1;
            }
            result.add(sb.toString());
        }
    }
    return result;
}

public static void permuteString(String bs, String end) {
    if (end.length() <= 1)
        System.out.println(bs + end);//I THINK I HAVE TO CHANGE SOMETHING OVER HERE
    else
        for (int i = 0; i < end.length(); i++) {
            try {
                String newString = end.substring(0, i) + end.substring(i + 1);

                permuteString(bs + end.charAt(i), newString);
            } catch (StringIndexOutOfBoundsException exception) {
                exception.printStackTrace();
            }
        }
}

public static void main(String args[])  {

    Set<String> powerSet = generatePowerSet("String");

    Set<String> allPossibilities = new HashSet<String>();

    for(String s : powerSet)
    {
        permuteString(" ", s );
    }
}
}
问题回答

https://stackoverflow.com/questions/3617326/marquee-effect-in-java-swing/3621417#3621417" http://www.ohchr.org。

增编:

我指的是如何在某个时候发出一种特性,而不要屈服。

<代码>Robot使用KeyEvent,没有简单的反向绘图。 相反,有100万办法使大赢家融为一体。

  1. 在使用<代码>javax.swing时,对案文作一改动。 见

  2. Scramble a “Wintus”,如here

  3. Fade the "Win>,如here

增编:

是否有办法把我所生产的所有东西都列入一个档案?

java -cp build/classes MainClass > somefile.txt




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签