import javax.swing.*; import java.awt.*; import java.awt.event.*; public class AnimeGirlGenerator extends JFrame { private JLabel hairLabel, eyeLabel, skinLabel, resultLabel; private JTextField hairField, eyeField, skinField; private JButton generateButton; private JPanel inputPanel, resultPanel; private String hairColor, eyeColor, skinTone; private JLabel imageLabel; private ImageIcon image; public AnimeGirlGenerator() { setTitle("Anime Girl Generator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new GridLayout(2, 1)); // Input panel inputPanel = new JPanel(); inputPanel.setLayout(new GridLayout(4, 2)); hairLabel = new JLabel("Hair Color: "); inputPanel.add(hairLabel); hairField = new JTextField(); inputPanel.add(hairField); eyeLabel = new JLabel("Eye Color: "); inputPanel.add(eyeLabel); eyeField = new JTextField(); inputPanel.add(eyeField); skinLabel = new JLabel("Skin Tone: "); inputPanel.add(skinLabel); skinField = new JTextField(); inputPanel.add(skinField); generateButton = new JButton("Generate"); generateButton.addActionListener(new ButtonListener()); inputPanel.add(generateButton); add(inputPanel); // Result panel resultPanel = new JPanel(); resultPanel.setLayout(new FlowLayout()); resultLabel = new JLabel("Enter specifications above and press 'Generate'"); resultPanel.add(resultLabel); imageLabel = new JLabel(); resultPanel.add(imageLabel); add(resultPanel); pack(); setVisible(true); } private class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { hairColor = hairField.getText(); eyeColor = eyeField.getText(); skinTone = skinField.getText(); if (hairColor.equals("black") && eyeColor.equals("brown") && skinTone.equals("light")) { image = new ImageIcon("blackHairBrownEyesLightSkin.jpg"); imageLabel.setIcon(image); } else if (hairColor.equals("brown") && eyeColor.equals("green") && skinTone.equals("medium")) { image = new ImageIcon("brownHairGreenEyesMediumSkin.jpg"); imageLabel.setIcon(image); } else { resultLabel.setText("No matching anime girl found."); } } } public static void main(String[] args) { new AnimeGirlGenerator(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)