Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Java Help urgent
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="thomian" data-source="post: 20904412" data-attributes="member: 357290"><p><span style="color: Purple"><strong><span style="font-size: 18px">Machan me java eke...me podi window ekaka open wena (receipt button click karana) output eka me main window eke black text area ekata ganne koamda ? <img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /><img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /><img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /><img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /></span></strong></span></p><p></p><p><img src="https://s17.postimg.org/iqhxppu7j/Capture.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p></p><p><span style="font-size: 18px"><span style="color: Red">Small window eke code eka</span></span></p><p></p><p>package com.perisic.peripherals;</p><p>import java.awt.Color;</p><p></p><p>import javax.swing.*;</p><p></p><p>import com.perisic.beds.PrinterInterface; </p><p>/* </p><p> * Displays text in a frame.</p><p> */</p><p>public class BlueDisplay extends JFrame implements PrinterInterface {</p><p> /**</p><p> * A serialVersionUID is required by the JFrame class. </p><p> */</p><p> private static final long serialVersionUID = -8505887234618184162L;</p><p> private JTextArea outputWindow; </p><p> </p><p> /*</p><p> * when constructed the display will be directly visible. </p><p> */ </p><p> public BlueDisplay() {</p><p> super();</p><p> setSize(200, 600);</p><p> setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); </p><p> outputWindow = new JTextArea();</p><p> outputWindow.setForeground(Color.BLUE);</p><p> outputWindow.setBackground(Color.YELLOW);</p><p> getContentPane().add(outputWindow);</p><p> setVisible(true); </p><p> }</p><p> /* </p><p> * Prints the text str to the screen. Any previous text will be overwritten. </p><p> * @see com.perisic.beds.PrinterInterface#print(java.lang.String)</p><p> */</p><p> public void print(String str) { </p><p> outputWindow.setText(str); </p><p> outputWindow.repaint();</p><p> }</p><p></p><p>}</p><p></p><p></p><p><span style="font-size: 15px"><span style="color: Red">Main window code</span></span></p><p></p><p>package com.perisic.peripherals;</p><p></p><p>import java.awt.event.ActionEvent;</p><p>import java.awt.event.ActionListener;</p><p>import javax.swing.*;</p><p></p><p>import com.perisic.beds.CustomerPanel;</p><p>/**</p><p> * A Simple Graphical User Interface for the Recycling Machine.</p><p> * </p><p> *</p><p> */</p><p>public class RecyclingGUI extends JFrame implements ActionListener {</p><p> public void actionPerformed(ActionEvent e) {</p><p> // System.out.println("Received: e.getActionCommand()="+e.getActionCommand()+</p><p> // " e.getSource()="+e.getSource().toString() ); </p><p> if(e.getSource().equals(slot1) ) { </p><p> myCustomerPanel.itemReceived(1);</p><p> } else if( e.getSource().equals(slot2)) { </p><p> myCustomerPanel.itemReceived(2);</p><p> } else if( e.getSource().equals(slot3)) { </p><p> myCustomerPanel.itemReceived(3);</p><p> } else if( e.getSource().equals(receipt)) { </p><p> myCustomerPanel.printReceipt();</p><p> </p><p> }</p><p> }</p><p> </p><p> JButton slot1 = new JButton("can"); </p><p> JButton slot2 = new JButton("bottle"); </p><p> JButton slot3 = new JButton("Slot 3"); </p><p> </p><p> JButton receipt = new JButton("Receipt"); </p><p> </p><p> CustomerPanel myCustomerPanel = new CustomerPanel(new BlueDisplay());</p><p></p><p> </p><p> public RecyclingGUI() {</p><p> super();</p><p> setSize(400, 100);</p><p> setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); </p><p> JPanel panel = new JPanel(); </p><p> panel.add(slot1); </p><p> panel.add(slot2);</p><p> panel.add(slot3); </p><p> </p><p> slot1.addActionListener(this); </p><p> slot2.addActionListener(this); </p><p> slot3.addActionListener(this); </p><p> </p><p> panel.add(receipt); </p><p> receipt.addActionListener(this); </p><p> </p><p> JTextArea outputWindow = new JTextArea(60,70); </p><p> outputWindow.setForeground(Color.green);</p><p> outputWindow.setBackground(Color.black);</p><p> setVisible(true);</p><p> panel.add(outputWindow);</p><p> </p><p> getContentPane().add(panel);</p><p> panel.repaint();</p><p> </p><p> }</p><p> </p><p> public static void main(String [] args ) { </p><p> RecyclingGUI myGUI = new RecyclingGUI(); </p><p> myGUI.setVisible(true); </p><p> }</p><p></p><p>}</p></blockquote><p></p>
[QUOTE="thomian, post: 20904412, member: 357290"] [COLOR=Purple][B][SIZE=5]Machan me java eke...me podi window ekaka open wena (receipt button click karana) output eka me main window eke black text area ekata ganne koamda ? :confused::confused::confused::confused:[/SIZE][/B][/COLOR] [IMG]https://s17.postimg.org/iqhxppu7j/Capture.png[/IMG] [SIZE=5][COLOR=Red]Small window eke code eka[/COLOR][/SIZE] package com.perisic.peripherals; import java.awt.Color; import javax.swing.*; import com.perisic.beds.PrinterInterface; /* * Displays text in a frame. */ public class BlueDisplay extends JFrame implements PrinterInterface { /** * A serialVersionUID is required by the JFrame class. */ private static final long serialVersionUID = -8505887234618184162L; private JTextArea outputWindow; /* * when constructed the display will be directly visible. */ public BlueDisplay() { super(); setSize(200, 600); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); outputWindow = new JTextArea(); outputWindow.setForeground(Color.BLUE); outputWindow.setBackground(Color.YELLOW); getContentPane().add(outputWindow); setVisible(true); } /* * Prints the text str to the screen. Any previous text will be overwritten. * @see com.perisic.beds.PrinterInterface#print(java.lang.String) */ public void print(String str) { outputWindow.setText(str); outputWindow.repaint(); } } [SIZE=4][COLOR=Red]Main window code[/COLOR][/SIZE] package com.perisic.peripherals; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import com.perisic.beds.CustomerPanel; /** * A Simple Graphical User Interface for the Recycling Machine. * * */ public class RecyclingGUI extends JFrame implements ActionListener { public void actionPerformed(ActionEvent e) { // System.out.println("Received: e.getActionCommand()="+e.getActionCommand()+ // " e.getSource()="+e.getSource().toString() ); if(e.getSource().equals(slot1) ) { myCustomerPanel.itemReceived(1); } else if( e.getSource().equals(slot2)) { myCustomerPanel.itemReceived(2); } else if( e.getSource().equals(slot3)) { myCustomerPanel.itemReceived(3); } else if( e.getSource().equals(receipt)) { myCustomerPanel.printReceipt(); } } JButton slot1 = new JButton("can"); JButton slot2 = new JButton("bottle"); JButton slot3 = new JButton("Slot 3"); JButton receipt = new JButton("Receipt"); CustomerPanel myCustomerPanel = new CustomerPanel(new BlueDisplay()); public RecyclingGUI() { super(); setSize(400, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.add(slot1); panel.add(slot2); panel.add(slot3); slot1.addActionListener(this); slot2.addActionListener(this); slot3.addActionListener(this); panel.add(receipt); receipt.addActionListener(this); JTextArea outputWindow = new JTextArea(60,70); outputWindow.setForeground(Color.green); outputWindow.setBackground(Color.black); setVisible(true); panel.add(outputWindow); getContentPane().add(panel); panel.repaint(); } public static void main(String [] args ) { RecyclingGUI myGUI = new RecyclingGUI(); myGUI.setVisible(true); } } [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom