Created
March 28, 2023 10:05
-
-
Save kishida/3c1b075cca033415b21118cf4a6fd769 to your computer and use it in GitHub Desktop.
Swing app generated by ChatRWKV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.util.*; | |
public class GenerateApp extends JFrame implements ActionListener { | |
int count; | |
private JTextField textField1; | |
private static final int SIZE = 20; | |
private JLabel label1; | |
private JTextField jTextField1; | |
private static final int SIZE2 = 20; | |
private JLabel label2; | |
private String nums[] = new String[SIZE2]; | |
public GenerateApp() { | |
//Adding a label and text field to the frame... | |
JPanel pnl = new JPanel(); | |
label1 = new JLabel("Enter the Numbers"); | |
pnl.add(label1); | |
textField1 = new JTextField(SIZE); | |
pnl.add(textField1); | |
//Creating a JPanel to hold a GridLayout, with the desired size | |
//for our number grid | |
jTextField1 = new JTextField(SIZE); | |
pnl.add(jTextField1); | |
JPanel jPanel2 = new JPanel(); | |
jPanel2.setLayout(new GridLayout(SIZE2, 1)); | |
for (int i = 0; i < SIZE2; i++) { | |
jPanel2.add(new JLabel(" ")); | |
} | |
JPanel jPanel3 = new JPanel(); | |
jPanel3.add(jPanel2); | |
//Adding our panel to the frame... | |
add(pnl, BorderLayout.NORTH); | |
add(jPanel3, BorderLayout.SOUTH); | |
//Listening for keystrokes from the user | |
addKeyListener(new KeyListener() { | |
public void keyPressed(KeyEvent evt) { | |
String text = textField1.getText(); | |
nums[count] = text; | |
textField1.setText(""); | |
count++; | |
if (text == null) { | |
text = ""; | |
} else if (text.equals("")) { | |
text = null; | |
} else { | |
text = text + nums[count]; | |
} | |
} | |
public void keyReleased(KeyEvent evt) { | |
} | |
public void keyTyped(KeyEvent evt) { | |
} | |
}); | |
} | |
public void actionPerformed(ActionEvent e) { | |
} | |
public static void main(String args[]) { | |
JFrame jFrame = new GenerateApp(); | |
jFrame.setSize(400, 300); | |
jFrame.setVisible(true); | |
} | |
} |
Author
kishida
commented
Mar 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment