Home Answers Viewqa Java-Beginners Lost Using Swing Components

 
 


Andrew Meikle
Lost Using Swing Components
1 Answer(s)      2 years and 5 months ago
Posted in : Java Beginners

Hello, I sound like every other newbie but I desperately need help. I have to write an application for the WebBuy Company that allows a user to compose the three parts of a complete email message: the "To", "Subject", and "Message:" text. The "To" and "Subject:" text areas should provide a single line for data entry. The "Message:" area should allow multiple lines of input and be able to scroll if necessary to accommodate a long message. The user clicks a button to send the email message. When the message is complete and the a send button is clicked, the application displays "Mail has been sent!" on a new line in the message area. I then save the files as JEmauil.java. This is what the code is that I have and it shows what I am missing. I would be indebted if someone could help me:

//Insert missing code here. import java.awt.*; import java.awt.event.*;

public class JEMail extends JFrame implements ActionListener { //Insert missing code here. private JTextField toField = new JTextField(24); private JLabel subjectLabel = new JLabel("Subject:"); private JTextField subjectField = new JTextField(24); //Insert missing code here. private JButton sendButton = new JButton("Send"); private JTextArea message = new JTextArea(4, 22);

public JEMail()
{
    super("WebBuy Company E-Mail");
    setSize(370, 270);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container pane = getContentPane();
    FlowLayout flow = new FlowLayout(FlowLayout.RIGHT);
    pane.setLayout(flow);
//Insert missing code here.
    panel1.add(toLabel);
//Insert missing code here.
    pane.add(panel1);
    JPanel panel2 = new JPanel();
    panel2.add(subjectLabel);
    panel2.add(subjectField);
//Insert missing code here.
    JPanel panel3 = new JPanel();
    panel3.add(messageLabel);
    message.setLineWrap(true);
    message.setWrapStyleWord(true);
    JScrollPane scroll = new JScrollPane(message,
       JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
       JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    panel3.add(scroll);
//Insert missing code here.
    JPanel panel4 = new JPanel();
    panel4.add(sendButton);
    pane.add(panel4);
    sendButton.addActionListener(this);
//Insert missing code here.
}

public static void main(String[] arguments)
{
    JEMail email = new JEMail();
//Insert missing code here.
}
public void actionPerformed(ActionEvent event)
{
  Object source = event.getSource();
  if (source == sendButton)
    message.append("\nMail has been sent!");
}

}

View Answers

December 13, 2010 at 1:12 PM


Hi Friend,

Try the following code:

import java.awt.*; 
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class JEMail extends JFrame implements ActionListener { 
    private JTextField toField = new JTextField(24);
    private JLabel subjectLabel = new JLabel("Subject:"); 
    private JTextField subjectField = new JTextField(24); 
    private JLabel toLabel = new JLabel("To:"); 
 private JButton sendButton = new JButton("Send"); 
 private JLabel messageLabel = new JLabel("Message:"); 
 private JTextArea message = new JTextArea(4, 22);
 StringBuffer buffer=new StringBuffer();
public JEMail()
{
    super("WebBuy Company E-Mail");
    setSize(370, 270);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   setLayout(null);
    toLabel.setBounds(10,10,100,20);
    toField.setBounds(150,10,100,20);
    subjectLabel.setBounds(10,40,100,20);
    subjectField.setBounds(150,40,100,20);

    messageLabel.setBounds(10,70,100,20);
    message.setBounds(150,70,300,80);

    sendButton.setBounds(150,170,80,20);
    message.setLineWrap(true);
    message.setWrapStyleWord(true);
   add(toLabel);
    add(toField);
     add(subjectLabel);
      add(subjectField);
       add(messageLabel);
        add(message);
         add(sendButton);
sendButton.addActionListener(this);
    setVisible(true);
    setSize(500,300);
}

public static void main(String[] arguments)
{
    JEMail email = new JEMail();
}
public void actionPerformed(ActionEvent event){
    Object source = event.getSource();
  if (source == sendButton){
      String mess=message.getText();
   message.append(mess+"\nMail has been sent!");
   System.out.println("Mail has been sent");
   }
}
}

Thanks









Related Pages:
Lost Using Swing Components
Lost Using Swing Components  Hello, I sound like every other newbie but I desperately need help. I have to write an application for the WebBuy... be indebted if someone would help me out as I am lost: //Insert missing code here
Lost Using Swing Components
Lost Using Swing Components  Hello, I sound like every other newbie but I desperately need help. I have to write an application for the WebBuy Company that allows a user to compose the three parts of a complete email message
Lost Using Swing Components
Lost Using Swing Components  Hello, I sound like every other newbie but I desperately need help. I have to write an application for the WebBuy Company that allows a user to compose the three parts of a complete email message
Lost Using Swing Components(2)
Lost Using Swing Components(2)  Here is the code block corrected: //Insert missing code here. import java.awt.*; import java.awt.event.*; public class JEMail extends JFrame implements ActionListener { //Insert missing code
Lost Using Swing Components(3)
Lost Using Swing Components(3)  Hello, I sound like every other newbie but I desperately need help. I have to write an application for the WebBuy Company that allows a user to compose the three parts of a complete email message
Finding Lost Frames - Java tutorial
Finding Lost Frames 2001-05-10 The Java Specialists' Newsletter [Issue 019] - Finding Lost Frames Author: Dr. Heinz M. Kabutz If you are reading... Lost Frames Something that I have encountered in some almost-complete
Introduction to Components
you will learn to use Swing components. Some advantages of using... Java NotesIntroduction to Components Swing Components You can draw... for you to put on the screen. These are called components. An example
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir i am doing a project so i am working in netbeans i have to print a JFrame it contains Labels and few... link: http://www.roseindia.net/java/example/java/swing/Print.shtml Hope
Components
Java NotesComponents Components (also known as "widgets") are the basic..., ... Components are placed in a container (eg, JPanel). The visual arrangement of the components depends on the container's layout. When the user does
JFrame Components Printing - Swing AWT
PrintExample() { super("Printing Swing Components...JFrame Components Printing  hi sir thanks a lot for your reply.../example/java/swing/Print.shtml and downloaded the codes and compiled it got
JFrame components printing - Swing AWT
Swing Components"); WindowShow.setNativeLookAndFeel(); Container content...JFrame components printing  hi sir thanks a lot for your reply.../example/java/swing/Print.shtml and downloaded the codes and compiled it got
JFrame components printing - Swing AWT
Swing Components"); WindowShow.setNativeLookAndFeel(); Container content...JFrame components printing  hi sir thanks a lot for your reply.../example/java/swing/Print.shtml and downloaded the codes and compiled it got
java total lost data in hard drive
java total lost data in hard drive  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
java total lost data in hard drive
java total lost data in hard drive  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
java total lost data in hard drive
java total lost data in hard drive  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
JAVA TOTAL LOST DATA IN HARD DRIVE
JAVA TOTAL LOST DATA IN HARD DRIVE  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
Serializing GUI Components Across Network - tutorial
Components Across Network When Swing came out, I was puzzled by the following... in the Swing source essentially tells us we should not write GUI components onto...Serializing GUI Components Across Network 2001-03-14 The Java Specialists
Display Logo on login form using swing
Display Logo on login form using swing In this tutorial, you will learn how to display a logo in login form using swing components. Here is an example where... file from the system and using setIcon() method, the image as a logo will get
Insert into table using Java Swing
INSERTION IN TABLE USING SWING In this section, We will insert rows into "Mysql" database using "Swing". What is Swing? Swing is the extension to the Awt library, includes new and improved components
What is Java Swing?
and GUIs components. All Java Swing classes imports form the import.... JComponent In java swing, All components are used the JComponent except.... JFrame It extends the Frame and supports the swing components
GPS Lost Mobile Phone Tracking Services
. For using our GPS based lost mobile tracking service, you must have a GPS...GPS Lost Mobile Phone Tracking Services Now a day?s mobile phones are not only.... Our subscription charges are very low while our GPS Lost Mobile Tracking
Java Swing
table controls All AWT flexible components can be handled by the Java Swing. Swing toolkit contains far more components than the simple component toolkit.... Not only this you can also create your own look and feel using Swing other than
swing components are not running in my system what to do now??
swing components are not running in my system what to do now??  Exception in thread "main" java.lang.ExceptionInInitializerError at javax.swing.JOptionPane.showInputDialog(Unknown Source
Sitemap Java Swing Tutorial
Out Components in a Grid  | Laying Out Components Using Absolute... Using Java Swing | Noise Image in Graphics in Java Swing |  Event... using Swing | Chess Application In Java Swing Jboss 3.0 Tutorial Section 10
Java Code - Swing AWT
Java Code  How to Make an application by using Swings JMenuBar and other components for drawing various categories of Charts(Line,Bar etc
scrolling a drawing..... - Swing AWT
scrolling a drawing.....  I am using a canvas along with other components like JTable over a frame the drawing which i am going to show over canvas... information. http://www.roseindia.net/java/example/java/swing/use-canvas
tooltip problem - Swing AWT
tooltip problem  Hi All, I am using SWT_AWT bridge in my code to embed swing components into SWT Composite. I am using a Swing JButton in SWT Composite. My problem is that I am unable to see the tooltip for this button even
Referencing components in flex 4
Referencing components in flex 4  I used to create flex 3 applications using canvas as main components. In this moment I am creating flex 4 applications but components (now based on s:Group) are not referenced inside
Creating Custom Components using JSF
JSF contains its basic set of UI components and provides an easy way of creating custom components of your own according to the need of the application. Components in JSF are elements like text box, button, table etc. that are used
Editing UI components using managed bean
Editing UI components using managed bean  Hello friends... I want to edit the properties of a inputText on JSP page using its managed bean. I have a simple inoutText and commandButton on jsp page and on click of button, i want
JSF Components
. So the final conclusion of using third party components is that a more...JSF Components      Components in JSF are elements like text box, button, table etc.. that are used
Composite Components
Composite Components This section contains a brief description and complete example over Composite Components in JSF2.0 . About Composite Components... components consist of collections of markup-tags with other components. These user
SplitPane in Java Swing
Learn SplitPane in Java Swing In this section, you will learn how to create split pane using java swing. For this, we have used JSplitPane class. Basically this class is used to divide two components. Here splitpane
Laying Out Components Using Absolute Coordinates
Laying Out Components Using Absolute Coordinates... and the y-axis of the frame. This program shows a frame which contains some swing components like: JLabel, JTextField and JButton. These components are arranged
Summary - Basic GUI Components
Java: Summary - Basic GUI Components Swing API provides lots components for crating the GUI for Java Swing applications. In this section we are studying the Basic GUI components of Swing framework. We will study the following GUI
Create Layout Components in a Grid in Java
layout components with the help of grid in Java Swing. The grid layout provides the facility to arrange some created GUI components for the frame. The grid... Create Layout Components in a Grid in Java   
Swing Jobs at Rose India
skills and solid software development experience in Java, using Swing components. Job Description for Java Swing developers: You will be designing... of developing application using Java Swing Candidate must be well versed with all
swing/awt - Swing AWT
swing/awt  How to create richtexteditor using swings...?I'm very much new to swings....It's urgent.....Thank u...   hello read this book you get idea; JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second
creation of table using a Java swing
creation of table using a Java swing  how to create a table dynamically in Java swing
swing sms
swing sms  HOW TO SEND SMS MESSAGE FROM SWING USING SQL DATABASE
Swing paint - Swing AWT
Swing paint  hi, i want to print something on window using swing applet.. m doing dis.. protected void paintComponent(Graphics g... the Swing Applet, use html file with the following code: Java Applet Demo
Flex custom components
Custom Flex Components: In the Flex 3 development, User can create custom components using mxml or ActionScript. In this example user can see mxml custom component. The purpose to create custom components in the Flex application
Reading .doc file using swing
Reading .doc file using swing  Sir, Could U Please Tell me the Way To Read .doc file in java using swing,with code
SWING - Swing AWT
SWING  how to insert image and components such as JLabel,JButton,JTextfield in JFrame in swing?  Hi Friend, Try the following code: import java.io.*; import java.awt.*; import javax.swing.*; import
java swing
java swing  view the book details using swing
Using swing - Java Beginners
Using swing  How can one use inheritance and polymophism while developing GUI of this question. Develop an application that allows a student to open an account. The account may be a savings account or a current account
Print Screen Using Java Swing
Print Screen Using Java Swing   ... PrintExample() {     super("Printing Swing Components... swing. The printable that is passed to setPrintable must have a print method
Action Script custom components
Flex Custom Components using Action Script:- You can create custom components by define Action Script class. User can create two type of custom components. First is visual custom components like Button, LinkButton, CheckBox, ComboBox
java swing
java swing  add two integer variables and display the sum of them using java swing
swing with jdbc - Swing AWT
swing with jdbc  Hi, i m developing the desktop application using swing.i want to use table structure for that.also its DB specific application. i have some problems with swing using jdbc. 1. the values entered in table

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.