From b28b8165a5f58c7b7620e90bca413e413c5d9d74 Mon Sep 17 00:00:00 2001 From: Cybear Tron Date: Wed, 6 Oct 2021 12:24:24 +0530 Subject: [PATCH] Added a GUI chat app with no networking done) --- GUI/JAVA/BasicChatAppInterface.class | Bin 0 -> 3605 bytes GUI/JAVA/BasicChatAppInterface.java | 101 +++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 GUI/JAVA/BasicChatAppInterface.class create mode 100644 GUI/JAVA/BasicChatAppInterface.java diff --git a/GUI/JAVA/BasicChatAppInterface.class b/GUI/JAVA/BasicChatAppInterface.class new file mode 100644 index 0000000000000000000000000000000000000000..ff9f02d851ae11fd6d5d9b025d104f97cd537ba0 GIT binary patch literal 3605 zcmcInS$G>)75=ZcQO09SRvRairj3(0t!&qolMs_gp(IxA#IECnIJKh$2-nh8Jh3z* zM&raT(3F0Kw$Rc71;W0RHLL|Hl?ckdl|J*xBab}s@d%tV8po2OmcH=$^V~D{o_p5+ zoH=^+-#1*_L;|Kx=GZPD4l_ z%1kTq(iMx?rY2ljP$B37dTLR6eg3-+4F=2X64)G@UY9!SxpXTzFc(5tK-<0d;NIN6 z{W^LO)o`1E+p$@o+vk^8ym-pVJ1*IfRT(F%1p1rFs)@hJo(y3Ni&nYZp^q0|OWo=%TA*GP88ib(Za{z-@s$ z>$bDFdj)!K5f{RJq&nr;Hf2S}5R4G^l6A*bzQ`)}8+Z#2P?ltt1jlNEZzhQiN)Gse zYTVQCR?5&V+9o|!2;q=GIOQtosXkj>>2n>YpktIZAErxFj%D{ryKj8ODtVODzSI8s z5bkGF-YziG#0VDL%n*NH!_kfCIwftD*Kvg7cmzB75z{cSk!@NosC)>=354Uer`*0X zYK5XS4nxC(0=*3m^4Wx?@>v~IIKe30q2VNDqk(H|+4CGbgm+MoXO&INGwk^pO8aR= zd1O=O*wcA|!G=5*ijJ*pFK{znOYYjHhV;gOvpq*C%sS4pn`iM(1MkAS1v*L1c-Hdd zLY~mp7CXo2cn`sd4fW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terface.java b/GUI/JAVA/BasicChatAppInterface.java new file mode 100644 index 000000000..6aa48ee57 --- /dev/null +++ b/GUI/JAVA/BasicChatAppInterface.java @@ -0,0 +1,101 @@ +//Import Unga Bunga +import javax.swing.*; +import java.awt.*; + +public class BasicChatAppInterface { + //Class + public static void main(String args[]) { + //Main Method + //main frame + JFrame frame = new JFrame("Chat Frame"); + + Color bg = Color.decode("#181f23"); + Color fontclr = Color.decode("#eff9ff"); + Color panelbg= Color.decode("#ffd6a5"); + Color menubg = Color.decode("#1c2a50"); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(500, 400); + + //The Menu that will later allow us to connect and create rooms to join a chat + JMenuBar mb = new JMenuBar(); + mb.setBackground(panelbg); + JMenu m1 = new JMenu("Connect"); + JMenu m2 = new JMenu("Help"); + //This is for help + mb.add(m1); + mb.add(m2); + JMenuItem m11 = new JMenuItem("Create new room"); + JMenuItem m22 = new JMenuItem("Join an Existing Room"); + m1.add(m11); + m1.add(m22); + + //Our panel + JPanel panel = new JPanel(); + panel.setSize(400,300); + panel.setBackground(panelbg); + JLabel label = new JLabel("Enter Text"); + //The Message field + JTextField tf = new JTextField(15); + //The Sending button + JButton send = new JButton("Send"); + + + //The resetting button + JButton reset = new JButton("Reset"); + //Adding the panel + panel.add(label); + panel.add(tf); + panel.add(send); + panel.add(reset); + + //The text area where the messages will go + JTextArea ta = new JTextArea(); + ta.setEditable(false); + ta.setFont(new Font("Consolas", Font.PLAIN, 12)); + ta.setBackground(bg); + ta.setForeground(fontclr); + //Adding it to the Scroll Pane so that It has scrolls + JScrollPane sp = new JScrollPane(ta); + + //Actionlisteners allow us to listen to the actions that take place with + //The Specific components like here when the button is pressed + send.addActionListener(e ->{ + //It will first store the text of the the text field in a + //variable called msg + String msg = tf.getText(); + //Then Will remove the Text from the field so that new messages can be + //sent + tf.setText(null); + //Now it will send The message to the message text area + ta.append(msg+"\n"); + }); + reset.addActionListener(e ->{ + //This is for the reset option + ta.setText(null); + //It will jus set all the text of the message area to null + //i.e. Nothing + } + ); + + tf.addActionListener(e ->{ + String msg = tf.getText(); + tf.setText(null); + ta.append(msg+"\n"); + }); + + //adds all the content and components to the main frame. + + frame.getContentPane().add(BorderLayout.SOUTH, panel); + frame.getContentPane().add(BorderLayout.NORTH, mb); + /*notice the BorderLayout here, it is from the awt package and it + is letting us lay the components in a specific layout. + Also we have changed the component below after the center to sp + i.e. it is the scrollpane instead of our textarea to get the Scroll Bars!!*/ + frame.getContentPane().add(BorderLayout.CENTER, sp); + frame.setVisible(true); + //Pretty Self-Explanatory + } + +} +