S
Skonrox
Gast
Der Quellcode ist wie folgt:
Anmerkungen oder Fehler sind keine da, nur wenn ich es ausführe und etwas eingebe kommt folgende Meldung:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at main.maini.schreib(maini.java:137)
at main.maini$1.actionPerformed(maini.java:72)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Wäre dankbar wenn mir jemand helfen könnte!
Mfg,
Skonrox!
Java:
package main;
import javax.swing.SwingUtilities;
import java.awt.AWTException;
import javax.swing.JPanel;
import java.awt.*;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
public class maini extends JFrame
{
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JButton jButton = null;
public char rueckwaerts;
public String rueck;
public String ausg;
public String ausg2;
public int j = 0;
public String ms = "";
public int i = 0;
private JLabel jLabel1 = null;
private JTextField jTextField1 = null;
private JLabel jLabel2 = null;
public maini() throws HeadlessException
{
super();
initialize();
}
public maini(GraphicsConfiguration arg0)
{
super(arg0);
initialize();
}
public maini(String arg0) throws HeadlessException
{
super(arg0);
initialize();
}
public maini(String arg0, GraphicsConfiguration arg1)
{
super(arg0, arg1);
initialize();
}
private JTextField getJTextField()
{
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(15, 76, 256, 30));
}
return jTextField;
}
private JButton getJButton()
{
if (jButton == null)
{
jButton = new JButton();
jButton.setBounds(new Rectangle(195, 121, 76, 30));
jButton.setText("Make");
jButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
try
{
schreib();
} catch (AWTException e1)
{
e1.printStackTrace();
} catch (IOException e1)
{
e1.printStackTrace();
}
}
});
}
return jButton;
}
private JTextField getJTextField1() {
if (jTextField1 == null) {
jTextField1 = new JTextField();
jTextField1.setBounds(new Rectangle(15, 129, 48, 23));
}
return jTextField1;
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run() {
maini thisClass = new maini();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
public void schreib() throws AWTException,IOException
{
rueck = jTextField.getText();
i = rueck.length();
while (j < i)
{
if(rueck.contains("ä"))
{
ausg = rueck.replace( "ä", "ae" );
}
if(rueck.contains("Ä"))
{
ausg = rueck.replace( "Ä", "Ae" );
}
if(rueck.contains("ö"))
{
ausg = rueck.replace( "ö", "oe" );
}
if(rueck.contains("Ö"))
{
ausg = rueck.replace( "Ö", "Oe" );
}
if(rueck.contains("ü"))
{
ausg = rueck.replace( "ü", "ue" );
}
if(rueck.contains("Ü"))
{
ausg = rueck.replace( "Ü", "Ue" );
}
if(rueck.contains("ß"))
{
ausg = rueck.replace( "ß", "ss" );
}
rueckwaerts = ausg.charAt(j);
ausg2 = "" + rueckwaerts;
System.out.println("KeyEvent.VK_"+ausg2+",");
if(jTextField1.getText() != "")
{
ms = jTextField1.getText();
System.out.println("robot.delay("+ms+");");
}
j++;
}
}
private void initialize()
{
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("KeyEventWriter");
}
private JPanel getJContentPane()
{
if (jContentPane == null)
{
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(15, 111, 124, 18));
jLabel2.setText("Verzögerung (in ms):");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(16, 57, 51, 21));
jLabel1.setText("Text:");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(45, 9, 195, 30));
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
jLabel.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel.setFont(new Font("Dotum", Font.BOLD | Font.ITALIC, 24));
jLabel.setText("KeyEvent writer");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(getJTextField1(), null);
jContentPane.add(jLabel2, null);
}
return jContentPane;
}
}
Anmerkungen oder Fehler sind keine da, nur wenn ich es ausführe und etwas eingebe kommt folgende Meldung:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at main.maini.schreib(maini.java:137)
at main.maini$1.actionPerformed(maini.java:72)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Wäre dankbar wenn mir jemand helfen könnte!
Mfg,
Skonrox!