Results 1 to 7 of 7
Thread: GUI Program
- 12-01-2012, 11:18 PM #1
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
GUI Program
(A) Design a JFrame object with two text areas, one below the other and a button in between them. When the button is clicked, input text entered in the top text area should be converted into text without punctuation symbols (comma, semi-colon, etc) and the text should appear in the text area below the button.
(B) Convert the application in Part (A) into a JApplet and display it inside a web page.
This is what i have to so far, also i havent worked on B.
Java Code:package assn6; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Assn6C { public static void main(String[] args){ JFrame myframe = new JFrame("No Punc Box"); myframe.setBounds(500,140,510,480); myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextArea ipTA, opTA; JButton convertBtn; ipTA = new JTextArea(); opTA = new JTextArea(); convertBtn = new JButton("Convert"); myframe.setLayout(null); //convertBtn.addActionListener(this); // this.add(convertBtn); ipTA.setBounds(5,5,500,200); opTA.setBounds(5,250,500,200); convertBtn.setBounds(225,220,65,20); myframe.setVisible(true); myframe.add(ipTA); myframe.add(opTA); myframe.add(convertBtn); convertBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String op; op = ipTA.getText(); op.replaceAll("\\p{Punct}+", ""); } });
- 12-01-2012, 11:19 PM #2
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
Re: GUI Program
im stuck here, and not sure if im going in the right direction
- 12-02-2012, 12:01 AM #3
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
Re: GUI Program
Classes will become objects when you make instances of them. Try to make classes for your objects. Then call them in the main class. Just keep it in the same package or even the same file. This will help you when you get to JApplet. You may then run it as an applet instead. see: The Java™ Tutorials for more info.
- 12-02-2012, 12:08 AM #4
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
Re: GUI Program
just finished the "easy" part..
i added ::I just need to make the JApplet partJava Code:public void actionPerformed(ActionEvent e) { String op; opTA.setText( ipTA.getText().replaceAll("\\p{Punct}+", "") ); }
-
Re: GUI Program
If this were my project, I'd gear my GUI to create a JPanel. Then if I wanted it displayed in a JFrame, I'd create a JFrame and stuff my created JPanel into its contentPane via getContentPane().add(...). Then if I wanted to display it in a JApplet, I'd create a class that extended JApplet and in the init() method add this JPanel into the applet's contentPane.
- 12-31-2012, 12:47 PM #6
Member
- Join Date
- Sep 2012
- Location
- Guntur, India
- Posts
- 27
- Rep Power
- 0
Re: GUI Program
The GUI code could be done with NetBeans or some other IDE.
If you want to eliminate the punctuation symbols, Make an array of the punctuation symbols, write a for loop and then call replaceAll(punctuation,"") method from the String where this string is the text in the JTextArea. As the operation is not persistent on the same string, instead a new string object is created and then using the setText() method of the output JTextArea, you can set the new string.
- 12-31-2012, 04:25 PM #7
Re: GUI Program
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Workout program progression - Ways to make my Java program shorter/smarter?
By LasseA in forum New To JavaReplies: 4Last Post: 11-21-2012, 01:19 PM -
How to code a program to send messages to a chat program?
By josh2992 in forum New To JavaReplies: 2Last Post: 04-02-2011, 12:57 PM -
changing my program to array working program
By Chewart in forum New To JavaReplies: 39Last Post: 11-18-2009, 06:53 PM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks