Code Sketch


Bixuu hanumanansh
By: Mhalsakant School
Category: Programming
import javax.swing._
import javax.swing.border.EmptyBorder
import javax.swing.event.ListSelectionEvent
import javax.swing.event.ListSelectionListener
import java.awt._
import java.awt.event._

object BixuuPowerCardBattle {

  private val BG = new Color(7, 12, 24)
  private val PANEL = new Color(17, 26, 45)
  private val PANEL2 = new Color(25, 38, 62)
  private val GOLD = new Color(255, 198, 72)
  private val WHITE = new Color(242, 246, 255)
  private val MUTED = new Color(174, 188, 211)
  private val CYAN = new Color(82, 211, 230)
  private val GREEN = new Color(83, 207, 139)

  private case class Chapter(
    title: String,
    subtitle: String,
    hinglish: String,
    english: String
  )

  private val chapters: Vector[Chapter] = Vector(
    Chapter(
      "01  -  Lakshminarayan: Ek Nayi Talaash",
      "The beginning of a spiritual journey",
      """Kahani ka central character ek young ladka hai - Lakshminarayan. Maa ke bichhadne ke baad uske mann mein bahut dukh aur sawal hain. Woh zindagi, maut aur Bhagwan ke baare mein jawab dhoondhna chahta hai.

Usse lagta hai ki agar woh Bhagwan ko sachche mann se dhoondhega, toh use apne dard ka matlab samajh aayega. Isliye uski journey sirf ghar se door jaane ki nahi, balki apne mann ke andar sachchai aur shanti dhoondhne ki bhi hai.

Is first chapter ka main idea hai: kabhi-kabhi ek bada sawal hi insaan ko ek nayi spiritual direction de deta hai.""",
      """The story follows a young seeker named Lakshminarayan. After losing his mother, he is filled with grief and questions about life, death and God. He begins searching for answers and meaning.

His journey is not only about travelling away from home. It is also an inward search for truth, peace and understanding. This opening chapter introduces the emotional reason behind his spiritual path."""
    ),
    Chapter(
      "02  -  Shri Ram Ki Khoj, Hanuman Ji Par Vishwas",
      "Faith becomes the guide",
      """Lakshminarayan ke dil mein Shri Ram ke darshan karne ki ichchha gehri hoti jaati hai. Hanuman ji ki bhakti uske liye ek important raasta ban jaati hai. Woh vishwas karta hai ki sachchi shraddha, himmat aur samarpan se insaan apne andar ke sawalon ka jawab paa sakta hai.

Safar mein mandir, sant aur alag-alag log milte hain. Har mulaqat uske sochne ka tareeka badalti hai. Woh sirf kisi se ready-made answer nahi chahta; woh khud samajhna chahta hai ki bhakti ka asli matlab kya hai.

Yahan se uski talaash aur gehri hoti hai - faith uska sahara hai, aur seva uski journey ka ek important lesson banne wali hai.""",
      """Lakshminarayan's wish to find Lord Ram becomes central to his journey. Devotion to Hanuman gives him faith and direction. He believes that sincerity, courage and surrender can help a person understand life's deeper questions.

As he travels, he meets temples, saints and ordinary people. Each encounter adds something to his understanding. He is not simply looking for easy answers; he wants to discover what true devotion means."""
    ),
    Chapter(
      "03  -  Safar, Sanyam Aur Antar Ki Shanti",
      "Learning through the journey",
      """Apni talaash mein Lakshminarayan alag-alag jagahon se guzarta hai - gaon, mandir, nadiyon ke kinare aur prakriti ke beech. Kabhi safar mushkil hota hai, kabhi use shanti milti hai. Har din usse patience aur discipline ka naya lesson deta hai.

Dheere-dheere usse samajh aane lagta hai ki spirituality sirf chamatkar dekhne ka naam nahi. Apne mann ko shaant rakhna, ahankaar kam karna, sach bolna aur doosron ki takleef samajhna bhi utna hi zaroori hai.

Is chapter mein journey bahar bhi chalti hai aur andar bhi. Lakshminarayan apne sawalon ke saath jeena aur unhe samajhna seekhta hai.""",
      """During his search, Lakshminarayan travels through villages, temples, riverbanks and natural surroundings. Some days are difficult, while others bring quiet moments of peace. The journey teaches him patience and discipline.

He gradually learns that spirituality is not only about extraordinary events. It is also about calming the mind, reducing ego, living truthfully and understanding the suffering of others. His outer journey and inner growth continue together."""
    ),
    Chapter(
      "04  -  Rail Yatra Aur Samman Ka Sandesh",
      "A remembered railway episode",
      """Film ke public plot summaries mein ek yaadgaar rail-yatra ka prasang bataya gaya hai. Ek British railway officer Lakshman Das ke saath apmaan janak vyavahar karta hai aur use train se neeche utarne ko kehta hai. Uske baad train aage nahi badhti aur railway staff pareshaan ho jaata hai.

Is ghatna ka spiritual message sirf ek adbhut prasang tak simit nahi hai. Kahani samman, insaaf aur har insaan ke saath izzat se pesh aane ki baat bhi karti hai. Ek sant ki pehchaan uske kapdon ya ticket se nahi, balki uske jeevan aur vyavahar se hoti hai.

Yeh chapter film ke safar ka ek important turning point samjhane ke liye hai. Isme movie ke original dialogues reproduce nahi kiye gaye hain.""",
      """Public plot summaries describe a memorable railway journey. A British railway officer treats Lakshman Das disrespectfully and orders him off the train. After he is made to leave, the train does not move, leaving the railway staff confused.

The episode carries a message beyond the extraordinary event: respect and fairness matter. A person's worth should not be judged by clothing or a ticket. This chapter is an original summary of the publicly described episode, not a reproduction of the film's dialogue."""
    ),
    Chapter(
      "05  -  Kainchi Ki Pahadiyan Aur Seva",
      "Compassion becomes a way of life",
      """Safar aage badhta hai aur Neeb Karori aur Kainchi ke pahadi ilaake uski spiritual pehchaan se judte hain. Yahan kahani ka focus dheere-dheere sirf uski apni talaash se badhkar doosron ki madad par aa jaata hai.

Bhookhe ko bhojan dena, pareshaan insaan ko sahara dena, kisi ki baat dhairya se sunna aur bina kisi reward ki umeed ke madad karna - yahi seva ka simple meaning hai. Bhakti ka asar tab dikhta hai jab hum apne aas-paas ke logon ke saath daya aur prem se pesh aate hain.

Is chapter ka lesson hai: seva koi show nahi; chhote, sachche aur bina swarth ke kiye gaye achhe kaam bhi bahut maayne rakhte hain.""",
      """As the journey continues, the areas around Neeb Karori and Kainchi become connected with his spiritual identity. The focus gradually expands from his personal search to helping other people.

Offering food to someone who is hungry, supporting a person in difficulty, listening patiently and helping without expecting a reward are simple forms of service. Devotion becomes meaningful when it is expressed through kindness and care for others."""
    ),
    Chapter(
      "06  -  Neem Karoli Baba: Prem, Bhakti Aur Seva",
      "The message of the story",
      """Lakshminarayan ki spiritual journey aage chal kar Neem Karoli Baba ki pehchaan se judti hai. Unki kahani ka sabse bada message prem, daya, vinamrata aur seva hai. Bhagwan ko yaad karna important hai, lekin har insaan ko izzat dena aur zarooratmand ki madad karna bhi bhakti ka hissa hai.

Hanuman ji ki bhakti se prerit yeh kahani humein yaad dilati hai ki asli strength sirf power mein nahi hoti. Asli strength apne ego ko chhota rakhne, doosron ke dard ko samajhne aur bina bhed-bhav ke prem baantne mein bhi hoti hai.

Reader takeaway: Sita Ram ka naam lo, sabke saath daya se pesh aao, aur jahan mumkin ho wahan seva karo. Yahi is story guide ka central message hai.""",
      """Lakshminarayan's spiritual journey becomes connected with the identity of Neem Karoli Baba. The central message of the story is love, compassion, humility and service. Remembering God matters, and so does treating every person with respect and helping those in need.

Inspired by devotion to Hanuman, the story reminds readers that true strength is not only power. It can also mean keeping ego small, understanding another person's pain and sharing kindness without discrimination.

Reader takeaway: Remember Sita Ram, treat people with compassion and serve wherever you can. That is the central message of this reading guide."""
    )
  )

  private def makeLabel(text: String, size: Int, color: Color, bold: Boolean): JLabel = {
    val label = new JLabel(text)
    val style = if (bold) Font.BOLD else Font.PLAIN
    label.setFont(new Font("SansSerif", style, size))
    label.setForeground(color)
    label
  }

  private def styleButton(button: JButton, background: Color): Unit = {
    button.setFont(new Font("SansSerif", Font.BOLD, 14))
    button.setForeground(WHITE)
    button.setBackground(background)
    button.setFocusPainted(false)
    button.setOpaque(true)
    button.setBorder(new EmptyBorder(11, 18, 11, 18))
    button.setCursor(new Cursor(Cursor.HAND_CURSOR))
  }

  def main(args: Array[String]): Unit = {
    SwingUtilities.invokeLater(new Runnable {
      override def run(): Unit = openLogin()
    })
  }

  private def openLogin(): Unit = {
    val frame = new JFrame("BIXUU HANUMAN STORY READING")
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setSize(570, 500)
    frame.setMinimumSize(new Dimension(520, 460))
    frame.setLocationRelativeTo(null)

    val root = new JPanel(new BorderLayout(16, 16))
    root.setBackground(BG)
    root.setBorder(new EmptyBorder(26, 30, 26, 30))

    val heading = new JPanel(new GridLayout(2, 1, 5, 5))
    heading.setBackground(BG)
    heading.add(makeLabel("BIXUU HANUMAN STORY READING", 25, GOLD, true))
    heading.add(makeLabel("HANUMAN ANSH  |  HINGLISH STORY GUIDE", 14, CYAN, true))
    root.add(heading, BorderLayout.NORTH)

    val card = new JPanel(new GridLayout(6, 1, 9, 9))
    card.setBackground(PANEL)
    card.setBorder(new EmptyBorder(24, 26, 24, 26))
    card.add(makeLabel("WELCOME, READER", 20, WHITE, true))
    card.add(makeLabel("Reader Name", 14, MUTED, true))

    val nameField = new JTextField()
    nameField.setFont(new Font("SansSerif", Font.PLAIN, 17))
    nameField.setBackground(new Color(9, 16, 29))
    nameField.setForeground(WHITE)
    nameField.setCaretColor(WHITE)
    nameField.setBorder(new EmptyBorder(9, 12, 9, 12))
    card.add(nameField)

    card.add(makeLabel("Password", 14, MUTED, true))
    val passwordField = new JPasswordField()
    passwordField.setFont(new Font("SansSerif", Font.PLAIN, 17))
    passwordField.setBackground(new Color(9, 16, 29))
    passwordField.setForeground(WHITE)
    passwordField.setCaretColor(WHITE)
    passwordField.setBorder(new EmptyBorder(9, 12, 9, 12))
    card.add(passwordField)

    val loginButton = new JButton("LOGIN AND READ STORY")
    styleButton(loginButton, new Color(143, 91, 25))
    card.add(loginButton)
    root.add(card, BorderLayout.CENTER)

    val footer = makeLabel("Enter your name and the password: Sita Ram", 13, MUTED, false)
    root.add(footer, BorderLayout.SOUTH)

    def attemptLogin(): Unit = {
      val readerName = nameField.getText.trim
      val enteredPassword = new String(passwordField.getPassword).trim
      if (readerName.isEmpty) {
        JOptionPane.showMessageDialog(frame, "Please enter your Reader Name.", "NAME REQUIRED", JOptionPane.INFORMATION_MESSAGE)
      } else if (enteredPassword.equalsIgnoreCase("Sita Ram")) {
        frame.dispose()
        openReader(readerName)
      } else {
        JOptionPane.showMessageDialog(frame, "Wrong password. Please enter: Sita Ram", "LOGIN FAILED", JOptionPane.ERROR_MESSAGE)
        passwordField.setText("")
        passwordField.requestFocusInWindow()
      }
    }

    loginButton.addActionListener(new ActionListener {
      override def actionPerformed(event: ActionEvent): Unit = attemptLogin()
    })
    passwordField.addActionListener(new ActionListener {
      override def actionPerformed(event: ActionEvent): Unit = attemptLogin()
    })

    frame.setContentPane(root)
    frame.setVisible(true)
    nameField.requestFocusInWindow()
  }

  private def openReader(readerName: String): Unit = {
    val frame = new JFrame("BIXUU HANUMAN STORY READING - HANUMAN ANSH")
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setSize(1220, 800)
    frame.setMinimumSize(new Dimension(950, 650))
    frame.setLocationRelativeTo(null)

    val root = new JPanel(new BorderLayout(12, 12))
    root.setBackground(BG)
    root.setBorder(new EmptyBorder(16, 18, 14, 18))

    val header = new JPanel(new BorderLayout(12, 8))
    header.setBackground(PANEL)
    header.setBorder(new EmptyBorder(16, 18, 16, 18))

    val headerText = new JPanel(new GridLayout(2, 1, 4, 4))
    headerText.setBackground(PANEL)
    headerText.add(makeLabel("BIXUU HANUMAN STORY READING", 24, GOLD, true))
    headerText.add(makeLabel("HANUMAN ANSH  |  Welcome, " + readerName + "  |  6 READING CHAPTERS", 13, CYAN, true))
    header.add(headerText, BorderLayout.CENTER)

    val rightHeader = new JPanel(new GridLayout(2, 1, 5, 5))
    rightHeader.setBackground(PANEL)
    rightHeader.add(makeLabel("READING LANGUAGE", 12, MUTED, true))
    val languageBox = new JComboBox[String](Array[String]("HINGLISH (Tum / Hum)", "ENGLISH"))
    languageBox.setFont(new Font("SansSerif", Font.BOLD, 13))
    languageBox.setBackground(PANEL2)
    languageBox.setForeground(WHITE)
    rightHeader.add(languageBox)
    header.add(rightHeader, BorderLayout.EAST)
    root.add(header, BorderLayout.NORTH)

    val chapterModel = new DefaultListModel[String]()
    chapters.foreach(chapter => chapterModel.addElement(chapter.title))
    val chapterList = new JList[String](chapterModel)
    chapterList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
    chapterList.setFont(new Font("SansSerif", Font.BOLD, 13))
    chapterList.setBackground(PANEL)
    chapterList.setForeground(WHITE)
    chapterList.setSelectionBackground(new Color(77, 91, 125))
    chapterList.setSelectionForeground(WHITE)
    chapterList.setFixedCellHeight(58)
    chapterList.setBorder(new EmptyBorder(8, 8, 8, 8))

    val leftPanel = new JPanel(new BorderLayout(8, 8))
    leftPanel.setBackground(PANEL)
    leftPanel.setBorder(new EmptyBorder(12, 12, 12, 12))
    leftPanel.add(makeLabel("STORY CHAPTERS", 16, GOLD, true), BorderLayout.NORTH)
    leftPanel.add(new JScrollPane(chapterList), BorderLayout.CENTER)
    leftPanel.setPreferredSize(new Dimension(335, 600))

    val readingPanel = new JPanel(new BorderLayout(10, 10))
    readingPanel.setBackground(PANEL)
    readingPanel.setBorder(new EmptyBorder(20, 22, 16, 22))

    val readingTop = new JPanel(new GridLayout(2, 1, 6, 6))
    readingTop.setBackground(PANEL)
    val chapterTitle = makeLabel("Chapter 1", 23, GOLD, true)
    val chapterSubtitle = makeLabel("The beginning of a spiritual journey", 14, CYAN, false)
    readingTop.add(chapterTitle)
    readingTop.add(chapterSubtitle)
    readingPanel.add(readingTop, BorderLayout.NORTH)

    val storyArea = new JTextArea()
    storyArea.setEditable(false)
    storyArea.setLineWrap(true)
    storyArea.setWrapStyleWord(true)
    storyArea.setFont(new Font("SansSerif", Font.PLAIN, 18))
    storyArea.setForeground(WHITE)
    storyArea.setBackground(new Color(10, 17, 31))
    storyArea.setCaretColor(WHITE)
    storyArea.setBorder(new EmptyBorder(20, 22, 20, 22))
    storyArea.setText("Select a chapter from the list to start reading.")
    readingPanel.add(new JScrollPane(storyArea), BorderLayout.CENTER)

    val readingNote = makeLabel("Original reading guide based on public plot descriptions - not the film script.", 12, MUTED, false)
    readingPanel.add(readingNote, BorderLayout.SOUTH)

    val split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, readingPanel)
    split.setDividerLocation(345)
    split.setResizeWeight(0.0)
    split.setBorder(null)
    split.setBackground(BG)
    root.add(split, BorderLayout.CENTER)

    var currentIndex = 0
    val chapterCounter = makeLabel("CHAPTER 1 / " + chapters.length, 13, GREEN, true)
    val previousButton = new JButton("< PREVIOUS")
    val nextButton = new JButton("NEXT >")
    val logoutButton = new JButton("LOG OUT")
    styleButton(previousButton, new Color(49, 74, 111))
    styleButton(nextButton, new Color(35, 120, 104))
    styleButton(logoutButton, new Color(100, 52, 59))

    def showChapter(index: Int): Unit = {
      if (index >= 0 && index < chapters.length) {
        currentIndex = index
        val chapter = chapters(index)
        chapterTitle.setText(chapter.title)
        chapterSubtitle.setText(chapter.subtitle)
        if (languageBox.getSelectedIndex == 0) {
          storyArea.setText(chapter.hinglish)
        } else {
          storyArea.setText(chapter.english)
        }
        storyArea.setCaretPosition(0)
        chapterCounter.setText("CHAPTER " + (index + 1) + " / " + chapters.length)
        previousButton.setEnabled(index > 0)
        nextButton.setEnabled(index < chapters.length - 1)
      }
    }

    chapterList.addListSelectionListener(new ListSelectionListener {
      override def valueChanged(event: ListSelectionEvent): Unit = {
        if (!event.getValueIsAdjusting && chapterList.getSelectedIndex >= 0) {
          showChapter(chapterList.getSelectedIndex)
        }
      }
    })

    languageBox.addActionListener(new ActionListener {
      override def actionPerformed(event: ActionEvent): Unit = showChapter(currentIndex)
    })

    previousButton.addActionListener(new ActionListener {
      override def actionPerformed(event: ActionEvent): Unit = {
        if (currentIndex > 0) chapterList.setSelectedIndex(currentIndex - 1)
      }
    })

    nextButton.addActionListener(new ActionListener {
      override def actionPerformed(event: ActionEvent): Unit = {
        if (currentIndex < chapters.length - 1) chapterList.setSelectedIndex(currentIndex + 1)
      }
    })

    logoutButton.addActionListener(new ActionListener {
      override def actionPerformed(event: ActionEvent): Unit = {
        frame.dispose()
        openLogin()
      }
    })

    val controls = new JPanel(new BorderLayout(10, 8))
    controls.setBackground(BG)
    val leftControls = new JPanel(new FlowLayout(FlowLayout.LEFT, 8, 0))
    leftControls.setBackground(BG)
    leftControls.add(previousButton)
    leftControls.add(nextButton)
    controls.add(leftControls, BorderLayout.WEST)
    controls.add(chapterCounter, BorderLayout.CENTER)
    val rightControls = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 0))
    rightControls.setBackground(BG)
    rightControls.add(logoutButton)
    controls.add(rightControls, BorderLayout.EAST)
    root.add(controls, BorderLayout.SOUTH)

    frame.setContentPane(root)
    frame.setVisible(true)
    chapterList.setSelectedIndex(0)
    showChapter(0)
  }
}

BixuuPowerCardBattle.main(Array[String]())