Code Sketch


yoiiiii this is information secret
By: Mhalsakant School
Category: Programming
import javax.swing._
import java.awt._
import java.awt.datatransfer.StringSelection
import java.awt.event._

val secret = Array(121,97,100,110,101,115,104,50,48,49,51).map(_.toChar).mkString

def makeButton(text: String): JButton = {
  val b = new JButton(text)
  b.setFont(new Font("SansSerif", Font.BOLD, 14))
  b
}

def makeArea(text: String): JTextArea = {
  val a = new JTextArea()
  a.setText(text)
  a.setEditable(false)
  a.setLineWrap(true)
  a.setWrapStyleWord(true)
  a.setFont(new Font("SansSerif", Font.PLAIN, 15))
  a.setBorder(BorderFactory.createEmptyBorder(12,12,12,12))
  a
}

def copyToClipboard(text: String): Unit = {
  val selection = new StringSelection(text)
  Toolkit.getDefaultToolkit.getSystemClipboard.setContents(selection, selection)
  JOptionPane.showMessageDialog(null, "Prompt copied!")
}

def openMainLab(): Unit = {

  val win = new JFrame("Scala Swing AI Coding Lab")
  win.setSize(1250,800)
  win.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
  win.setLocationRelativeTo(null)

  val root = new JPanel(new BorderLayout())
  root.setBackground(Color.WHITE)

  val header = new JPanel(new BorderLayout())
  header.setBackground(new Color(25,25,35))
  header.setBorder(BorderFactory.createEmptyBorder(15,15,15,15))

  val title = new JLabel(
    "SCALA SWING AI CODING LAB",
    SwingConstants.CENTER
  )
  title.setForeground(Color.WHITE)
  title.setFont(new Font("SansSerif",Font.BOLD,30))

  val subtitle = new JLabel(
    "Build  ?  Learn  ?  Debug  ?  Upgrade  ?  Create",
    SwingConstants.CENTER
  )
  subtitle.setForeground(Color.LIGHT_GRAY)
  subtitle.setFont(new Font("SansSerif",Font.PLAIN,15))

  header.add(title,BorderLayout.NORTH)
  header.add(subtitle,BorderLayout.SOUTH)

  root.add(header,BorderLayout.NORTH)

  val tabs = new JTabbedPane()
  tabs.setFont(new Font("SansSerif",Font.BOLD,14))

  def addTab(name:String, component:Component):Unit = {
    tabs.addTab(name,new JScrollPane(component))
  }

  val home = new JPanel()
  home.setLayout(new BoxLayout(home,BoxLayout.Y_AXIS))
  home.setBorder(BorderFactory.createEmptyBorder(20,30,20,30))
  home.setBackground(Color.WHITE)

  val welcome = new JLabel(
    "WELCOME TO YOUR PRIVATE CODING LAB",
    SwingConstants.CENTER
  )
  welcome.setFont(new Font("SansSerif",Font.BOLD,24))
  welcome.setAlignmentX(Component.CENTER_ALIGNMENT)

  val welcomeText = new JLabel(
    "<html><center>" +
    "Yethe Scala Swing + ChatGPT coding cha complete learning system aahe.<br>" +
    "Ideas pasun working projects paryant step-by-step ??????????." +
    "</center></html>",
    SwingConstants.CENTER
  )
  welcomeText.setFont(new Font("SansSerif",Font.PLAIN,17))
  welcomeText.setAlignmentX(Component.CENTER_ALIGNMENT)

  home.add(welcome)
  home.add(Box.createVerticalStrut(15))
  home.add(welcomeText)
  home.add(Box.createVerticalStrut(25))

  val featurePanel = new JPanel(new GridLayout(2,4,12,12))
  featurePanel.setBackground(Color.WHITE)

  val features = Array(
    "PROMPT BUILDER",
    "ERROR FIX LAB",
    "GAME LAB",
    "PROJECT IDEAS",
    "SWING SKILLS",
    "DEBUG CENTER",
    "LEVEL ROADMAP",
    "SECRET LAB"
  )

  for (f <- features) {
    val b = makeButton(f)
    featurePanel.add(b)
  }

  home.add(featurePanel)
  home.add(Box.createVerticalStrut(25))

  val workflow = new JTextArea()
  workflow.setEditable(false)
  workflow.setLineWrap(true)
  workflow.setWrapStyleWord(true)
  workflow.setFont(new Font("Monospaced",Font.BOLD,15))
  workflow.setText(
    "YOUR CODING WORKFLOW\n\n" +
    "IDEA\n" +
    "  ?\n" +
    "PROMPT\n" +
    "  ?\n" +
    "CHATGPT CODE\n" +
    "  ?\n" +
    "RUN\n" +
    "  ?\n" +
    "TEST\n" +
    "  ?\n" +
    "ERROR\n" +
    "  ?\n" +
    "ERROR FIX LAB\n" +
    "  ?\n" +
    "COMPLETE CORRECTED CODE\n" +
    "  ?\n" +
    "UPGRADE\n" +
    "  ?\n" +
    "ULTRA PROJECT"
  )

  home.add(workflow)

  addTab("HOME",home)

  val promptPanel = new JPanel(new BorderLayout())
  promptPanel.setBorder(BorderFactory.createEmptyBorder(15,15,15,15))
  promptPanel.setBackground(Color.WHITE)

  val promptTop = new JPanel(new FlowLayout(FlowLayout.LEFT))
  promptTop.setBackground(Color.WHITE)

  val gameBtn = makeButton("GAME PROMPT")
  val guiBtn = makeButton("GUI PROMPT")
  val errorBtn = makeButton("ERROR PROMPT")
  val upgradeBtn = makeButton("UPGRADE PROMPT")
  val customBtn = makeButton("CUSTOM PROMPT")

  promptTop.add(gameBtn)
  promptTop.add(guiBtn)
  promptTop.add(errorBtn)
  promptTop.add(upgradeBtn)
  promptTop.add(customBtn)

  val promptArea = makeArea(
    "Prompt Builder\n\n" +
    " ???? button select kara."
  )

  val copyPrompt = makeButton("COPY PROMPT")

  val promptBottom = new JPanel(new FlowLayout(FlowLayout.RIGHT))
  promptBottom.setBackground(Color.WHITE)
  promptBottom.add(copyPrompt)

  promptPanel.add(promptTop,BorderLayout.NORTH)
  promptPanel.add(new JScrollPane(promptArea),BorderLayout.CENTER)
  promptPanel.add(promptBottom,BorderLayout.SOUTH)

  def setPrompt(text:String):Unit = {
    promptArea.setText(text)
  }

  gameBtn.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      setPrompt(
        "Tu maza expert Scala Swing game developer ahes.\n\n" +
        "Mala complete 2D game banvun de.\n\n" +
        "Game idea:\n" +
        "[GAME IDEA]\n\n" +
        "Player:\n" +
        "[PLAYER]\n\n" +
        "Controls:\n" +
        "[CONTROLS]\n\n" +
        "Features:\n" +
        "Score\nLevels\nCollision\nRestart\nGame Over\nWin Screen\n\n" +
        "Graphics clean ani smooth theva.\n" +
        "Complete imports dya.\n" +
        "No undefined variables.\n" +
        "No missing methods.\n" +
        "No placeholders.\n" +
        "No broken braces.\n" +
        "Single complete source file dya.\n" +
        "WindowConstants.EXIT_ON_CLOSE vapra.\n" +
        "Run kelyavar GUI actually visible pahije.\n\n" +
        "Return complete final replacement code."
      )
    }
  })

  guiBtn.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      setPrompt(
        "Tu maza expert Scala Swing GUI developer ahes.\n\n" +
        "Mala professional desktop application banvun de.\n\n" +
        "Screens:\n" +
        "[SCREENS]\n\n" +
        "Buttons:\n" +
        "[BUTTONS]\n\n" +
        "Inputs:\n" +
        "[INPUTS]\n\n" +
        "UI clean, readable ani organized theva.\n" +
        "Complete imports dya.\n" +
        "All events working theva.\n" +
        "No missing methods.\n" +
        "No undefined variables.\n" +
        "Complete single-file runnable code dya."
      )
    }
  })

  errorBtn.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      setPrompt(
        "Ha maza complete Scala error aahe:\n\n" +
        "[PASTE COMPLETE ERROR]\n\n" +
        "Ha maza current code aahe:\n\n" +
        "[PASTE COMPLETE CODE]\n\n" +
        "Expected behavior:\n" +
        "[EXPECTED RESULT]\n\n" +
        "Problem completely diagnose kara.\n" +
        "Fakta ek line fix karu naka.\n" +
        "Complete corrected replacement code dya.\n" +
        "Existing functionality remove karu naka.\n" +
        "All imports, variables, methods, braces,\n" +
        "parentheses, strings and startup verify kara."
      )
    }
  })

  upgradeBtn.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      setPrompt(
        "Ha existing Scala Swing project aahe.\n\n" +
        "Existing functionality remove karu naka.\n\n" +
        "Current features:\n" +
        "[CURRENT FEATURES]\n\n" +
        "New feature:\n" +
        "[NEW FEATURE]\n\n" +
        "Existing controls preserve kara.\n" +
        "Existing screens preserve kara.\n" +
        "New feature properly integrate kara.\n" +
        "Complete updated replacement code dya."
      )
    }
  })

  customBtn.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      setPrompt(
        "Tu maza expert Scala Swing developer ahes.\n\n" +
        "PROJECT:\n[PROJECT]\n\n" +
        "GOAL:\n[GOAL]\n\n" +
        "FEATURES:\n[FEATURES]\n\n" +
        "CONTROLS:\n[CONTROLS]\n\n" +
        "UI:\n[UI]\n\n" +
        "GRAPHICS:\n[GRAPHICS]\n\n" +
        "ENVIRONMENT:\n[ENVIRONMENT]\n\n" +
        "Complete runnable code dya.\n" +
        "Single file.\n" +
        "Complete imports.\n" +
        "No placeholders.\n" +
        "No missing methods.\n" +
        "No undefined variables."
      )
    }
  })

  copyPrompt.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      copyToClipboard(promptArea.getText)
    }
  })

  addTab("PROMPT BUILDER",promptPanel)

  val errorPanel = new JPanel(new BorderLayout())
  errorPanel.setBorder(BorderFactory.createEmptyBorder(15,15,15,15))
  errorPanel.setBackground(Color.WHITE)

  val errorArea = makeArea(
    "ERROR FIX LAB\n\n" +
    "Common errors:\n\n" +
    "1. illegal start of declaration\n" +
    "2. unclosed string literal\n" +
    "3. Missing closing brace\n" +
    "4. not found: value\n" +
    "5. not enough arguments\n" +
    "6. forward reference\n" +
    "7. JFrame.EXIT_ON_CLOSE problem\n" +
    "8. GUI visible hot nahi\n\n" +
    "Best method:\n" +
    "Complete error + complete code + expected behavior\n" +
    "ChatGPT la dya.\n\n" +
    "Command:\n" +
    "Complete corrected replacement code dya."
  )

  addTab("ERROR FIX LAB",errorArea)

  val skillsArea = makeArea(
    "SCALA SWING SKILL LIBRARY\n\n" +
    "LEVEL 1 - FOUNDATION\n\n" +
    "JFrame\n" +
    "JPanel\n" +
    "JLabel\n" +
    "JButton\n" +
    "JTextField\n" +
    "JTextArea\n" +
    "JScrollPane\n" +
    "JTabbedPane\n\n" +
    "LEVEL 2 - EVENTS\n\n" +
    "ActionListener\n" +
    "MouseListener\n" +
    "MouseMotionListener\n" +
    "KeyListener\n    " +
    "Timer\n\n" +
    "LEVEL 3 - GRAPHICS\n\n" +
    "paintComponent\n" +
    "fillRect\n" +
    "fillOval\n" +
    "drawLine\n" +
    "drawString\n" +
    "Color\n" +
    "Font\n\n" +
    "LEVEL 4 - GAMES\n\n" +
    "Player movement\n" +
    "Collision\n" +
    "Score\n" +
    "Levels\n" +
    "Pause\n" +
    "Restart\n" +
    "Win\n" +
    "Game Over\n\n" +
    "LEVEL 5 - ADVANCED\n\n" +
    "Save/Load\n" +
    "Settings\n" +
    "High Score\n" +
    "Difficulty\n" +
    "Animation\n" +
    "Debug Mode\n" +
    "Performance"
  )

  addTab("SKILL LIBRARY",skillsArea)

  val gameArea = makeArea(
    "GAME LAB\n\n" +
    "GAME 01\n" +
    "Snake\n\n" +
    "GAME 02\n" +
    "Memory Game\n\n" +
    "GAME 03\n" +
    "Maze Game\n\n" +
    "GAME 04\n" +
    "Brick Breaker\n\n" +
    "GAME 05\n" +
    "Car Racing\n\n" +
    "GAME 06\n" +
    "Platform Game\n\n" +
    "GAME 07\n" +
    "Puzzle Adventure\n\n" +
    "GAME 08\n" +
    "Reaction Game\n\n" +
    "GAME 09\n" +
    "Typing Game\n\n" +
    "GAME 10\n" +
    "Level Based Challenge\n\n" +
    "Every game sathi ChatGPT la:\n" +
    "Goal + Controls + Objects + Rules + Score + Levels + Screens\n" +
    "clear sangaa."
  )

  addTab("GAME LAB",gameArea)

  val ideasArea = makeArea(
    "PROJECT IDEA GENERATOR\n\n" +
    "BEGINNER:\n" +
    "Calculator\n" +
    "Clock\n" +
    "Stopwatch\n" +
    "Quiz\n" +
    "To Do App\n" +
    "Drawing App\n\n" +
    "INTERMEDIATE:\n" +
    "Snake\n" +
    "Memory\n" +
    "Maze\n" +
    "Puzzle\n" +
    "Racing\n" +
    "Typing Game\n\n" +
    "ADVANCED:\n" +
    "Game Center\n" +
    "Learning Center\n" +
    "Mini IDE\n" +
    "Project Builder\n" +
    "Level Based Game\n" +
    "Simulation\n\n" +
    "ULTRA:\n" +
    "Create a multi-screen Scala Swing hub\n" +
    "with games, tools, settings, score,\n" +
    "profile, tutorial and project launcher."
  )

  addTab("IDEA VAULT",ideasArea)

  val roadmapArea = makeArea(
    "LEVEL ROADMAP\n\n" +
    "LEVEL 1\n" +
    "GUI Basics\n" +
    "?\n" +
    "LEVEL 2\n" +
    "Buttons + Events\n" +
    "?\n" +
    "LEVEL 3\n" +
    "Drawing\n" +
    "?\n" +
    "LEVEL 4\n" +
    "Animation + Timer\n" +
    "?\n" +
    "LEVEL 5\n" +
    "Game Logic\n" +
    "?\n" +
    "LEVEL 6\n" +
    "Collision + Score\n" +
    "?\n" +
    "LEVEL 7\n" +
    "Levels + Screens\n" +
    "?\n" +
    "LEVEL 8\n" +
    "Save + Settings\n" +
    "?\n" +
    "LEVEL 9\n" +
    "Optimization\n" +
    "?\n" +
    "LEVEL 10\n" +
    "ULTRA PROJECT\n\n" +
    "Goal:\n" +
    "Idea swataha design kara,\n" +
    "ChatGPT kadun code ghya,\n" +
    "run kara,\n" +
    "debug kara,\n" +
    "ani continuously upgrade kara."
  )

  addTab("ROADMAP",roadmapArea)

  val debugPanel = new JPanel(new BorderLayout())
  debugPanel.setBorder(BorderFactory.createEmptyBorder(15,15,15,15))
  debugPanel.setBackground(Color.WHITE)

  val debugArea = makeArea(
    "DEBUG CENTER\n\n" +
    "QUESTION 1:\n" +
    "Run hot aahe ka?\n\n" +
    "QUESTION 2:\n" +
    "Window diste ka?\n\n" +
    "QUESTION 3:\n" +
    "Button work karto ka?\n\n" +
    "QUESTION 4:\n" +
    "Keyboard work karto ka?\n\n" +
    "QUESTION 5:\n" +
    "Mouse work karto ka?\n\n" +
    "QUESTION 6:\n" +
    "Timer work karto ka?\n\n" +
    "QUESTION 7:\n" +
    "Score update hoto ka?\n\n" +
    "QUESTION 8:\n" +
    "Collision work hote ka?\n\n" +
    "QUESTION 9:\n" +
    "Restart properly reset karto ka?\n\n" +
    "QUESTION 10:\n" +
    "Win/Game Over state correct aahe ka?"
  )

  val debugCopy = makeButton("COPY DEBUG PROMPT")

  debugCopy.addActionListener(new ActionListener {
    override def actionPerformed(e:ActionEvent):Unit = {
      copyToClipboard(
        "Ha maza Scala Swing program aahe.\n\n" +
        "Problem:\n[WRITE PROBLEM]\n\n" +
        "Complete error:\n[PASTE ERROR]\n\n" +
        "Expected behavior:\n[EXPECTED]\n\n" +
        "Complete corrected replacement code dya."
      )
    }
  })

  debugPanel.add(debugArea,BorderLayout.CENTER)
  debugPanel.add(debugCopy,BorderLayout.SOUTH)

  addTab("DEBUG CENTER",debugPanel)

  val secretArea = new JPanel()
  secretArea.setLayout(new BoxLayout(secretArea,BoxLayout.Y_AXIS))
  secretArea.setBorder(BorderFactory.createEmptyBorder(25,30,25,30))
  secretArea.setBackground(Color.WHITE)

  val secretTitle = new JLabel(
    "SECRET CREATOR MODE",
    SwingConstants.CENTER
  )
  secretTitle.setFont(new Font("SansSerif",Font.BOLD,26))
  secretTitle.setAlignmentX(Component.CENTER_ALIGNMENT)

  val secretInfo = makeArea(
    "PRIVATE CREATOR NOTES\n\n" +
    "Ithe tu swatacha project planning system tayar karu shakto.\n\n" +
    "MASTER IDEA:\n" +
    "Ek project choose kara.\n" +
    "Tyache features ????.\n" +
    "ChatGPT la structured prompt dya.\n" +
    "Complete code ghya.\n" +
    "Run kara.\n" +
    "Errors fix kara.\n" +
    "Feature by feature upgrade kara.\n\n" +
    "ULTRA PROJECT FORMULA:\n\n" +
    "BASE\n" +
    "+ UI\n" +
    "+ CONTROLS\n" +
    "+ GAME LOGIC\n" +
    "+ ANIMATION\n" +
    "+ SCORE\n" +
    "+ LEVELS\n" +
    "+ SETTINGS\n" +
    "+ SAVE\n" +
    "+ DEBUG\n" +
    "+ POLISH\n" +
    "= COMPLETE PROJECT\n\n" +
    "Important:\n" +
    "Password based access ?? actual security system ????.\n" +
    "Source code access asel tar secret discover hou shakto."
  )

  secretArea.add(secretTitle)
  secretArea.add(Box.createVerticalStrut(15))
  secretArea.add(secretInfo)

  addTab("SECRET LAB",secretArea)

  root.add(tabs,BorderLayout.CENTER)

  val footer = new JLabel(
    "Private Scala Swing Creator Lab",
    SwingConstants.CENTER
  )
  footer.setFont(new Font("SansSerif",Font.BOLD,14))
  footer.setBorder(BorderFactory.createEmptyBorder(10,5,10,5))

  root.add(footer,BorderLayout.SOUTH)

  win.setContentPane(root)
  win.setVisible(true)
}

val login = new JFrame("Private Access")
login.setSize(450,280)
login.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
login.setLocationRelativeTo(null)

val loginPanel = new JPanel(new GridBagLayout())
loginPanel.setBackground(Color.WHITE)

val lgb = new GridBagConstraints()
lgb.insets = new Insets(10,10,10,10)
lgb.fill = GridBagConstraints.HORIZONTAL

val privateTitle = new JLabel(
  "PRIVATE ACCESS",
  SwingConstants.CENTER
)
privateTitle.setFont(new Font("SansSerif",Font.BOLD,27))

val privateSub = new JLabel(
  "Enter access code",
  SwingConstants.CENTER
)

val passField = new JPasswordField()
passField.setPreferredSize(new Dimension(270,36))

val enterButton = makeButton("UNLOCK")

val loginStatus = new JLabel(
  " ",
  SwingConstants.CENTER
)

lgb.gridx = 0
lgb.gridy = 0
lgb.gridwidth = 2
loginPanel.add(privateTitle,lgb)

lgb.gridy = 1
loginPanel.add(privateSub,lgb)

lgb.gridy = 2
loginPanel.add(passField,lgb)

lgb.gridy = 3
lgb.gridwidth = 1
lgb.gridx = 0
loginPanel.add(enterButton,lgb)

lgb.gridx = 1
loginPanel.add(loginStatus,lgb)

login.setContentPane(loginPanel)

def unlock():Unit = {

  val typed = new String(passField.getPassword)

  if (typed == secret) {
    login.dispose()
    openMainLab()
  } else {
    loginStatus.setText("ACCESS DENIED")
    passField.setText("")
  }
}

enterButton.addActionListener(new ActionListener {
  override def actionPerformed(e:ActionEvent):Unit = {
    unlock()
  }
})

passField.addActionListener(new ActionListener {
  override def actionPerformed(e:ActionEvent):Unit = {
    unlock()
  }
})

login.setVisible(true)
passField.requestFocusInWindow()