How to add words from a JTextField to a JList

Im working on my final project for Java programming class using JApplet.
Im trying to create a spelling test/wordfind
I want to be able to have the user type a word in the JtextField press the "Add" button (Jbutton) and have the word be added to the JList.
then click the "Start" Button and have the all the words from the JList be put in random stops in a panel and fill around all the words with random letters.
then when the user clicks on the letter of the words they are finding it will change colors if they click on it again it will change back to its original color.
So far I have my layout set up its adding the proper Listeners and events to achieve the desired results.
I know this is way more advanced than what My Instructor is even teacher but I am very interested in Java and want to learn a lot more about it.
If anyone has suggestions or know where i can find the information Im looking for please let me know.
Thanks
Code I have so Far:
* @(#)SpellingTest.java
* SpellingTest Applet application
* @author
* @version 1.00 2010/11/10
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SpellingTest extends JApplet implements ActionListener {
     Image img;
     ImageIcon icon;
     private Image title;
     JTextField word;
     JButton addWord;
     JLabel label;
     JList wordList;
     public void init() {//opening init
               getContentPane().setLayout(null);
               getContentPane().setBackground(Color.WHITE);
               title = getImage(getDocumentBase(), "title.jpg");
               //The text field
               word = new JTextField();
               word.setLocation(190,100);
               word.setSize(85,30);
               getContentPane().add(word);
               word.addActionListener(this);
               //The addWord button
               addWord = new JButton("ADD");
               addWord.setLocation(295, 100);
               addWord.setSize(90,30);
               getContentPane().add(addWord);
               addWord.setBackground(new Color(146, 205, 220));
               addWord.addActionListener(this);
               //The label
               label = new JLabel("Type your spelling words:");
               label.setLocation(25, 65);
               label.setSize(250,100);
               getContentPane().add(label);
               label.setForeground(new Color(146, 205, 220));
               //The List
               wordList = new JList();
               JScrollPane scrollPane = new JScrollPane(wordList,
               ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
               ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
               scrollPane.setLocation(25,150);
               scrollPane.setSize(150,300);
               getContentPane().add(scrollPane);
     }//closing init
     public void actionPerformed (ActionEvent ae){
          Object obj = ae.getSource();
          String text = word.getText();
          if (obj == addWord){
               if (text.length()>0);
               wordList.addString("");
     public void paint(Graphics g) {
          super.paint(g);
}

Read the first posting titled "Welcome to the new home" to learn how to use code tags. Then you can edit your posting so the code is formatted and readable.
I want to be able to have the user type a word in the JtextField press the "Add" button (Jbutton) and have the word be added to the JList.Read the JList API and follow the link to the Swing tutoral on "How to Use Lists" where you will find a working example.
So far I have my layout Actually you haven't. You should learn how to use layout managers. Again the Swing tutorial explains what layout managers are and provides working example of using them.
I am very interested in Java and want to learn a lot more about it.A great place to start is by read tutorials because they always contain working example. Here are some [url http://download.oracle.com/javase/tutorial/]Java tutorrial.

Similar Messages

  • YouTube - How to add videos from youtube on jsf-adf

    YouTube - How to add videos from youtube on jsf-adf.
    when i using iframe i can't send data from beans.

    you can use a <f:verbatim> tag in your page and in it just write the HTML code for embedding a video.
    and can i send data from beans class in html components?
    i wrote this
    <af:iterator id="i2" var="row"
    value="#{MyBean.src_items}"
    varStatus="st">
    <af:showDetail disclosed="false" id="sd1"
    styleClass="AFStretchWidth"
    disclosedText="#{row}">
    <f:verbatim>
    <iframe id="ifv" src="#{row}"/>
    </f:verbatim>
    </af:showDetail>
    </af:iterator>
    but that were not worked .
    Edited by: Vakhushti on May 9, 2011 12:40 PM

  • HT1473 How to add music from macbook pro to iPad

    How do I add musci from Macbok pro to ipad2?

    Open itunes, connect ipad, select what you want, sync.

  • How to add name from text file to jtable?

    hello all,
    how to add name (string) from the notepad file(.txt) into jTable rows.
    I am not able to add it.
    try {
                 FileInputStream fis = new FileInputStream("Devices/Devices_Lst.txt");
                 BufferedReader br = new BufferedReader(new InputStreamReader(fis));
                 String line = null;
                 Vector data = new Vector();
                 line = br.readLine();
                 while ( (line = br.readLine()) != null)
                    int rowCount1 = nmsTable.getRowCount();
                    for(int i=0;i<rowCount1;i++)      
                        myTableInit();  // it initialize the table
                       /* nmsTable.setValueAt(i+1,i,0);
                        Table.setValueAt(line,i,1);
                        Table.setValueAt(" ",i,2);
                        Table.setValueAt(" ",i,3);
                        Table.setValueAt(" ",i,4);
                        Table.setValueAt(" ",i,5); */
                        int rowNo = nmsTable.getRowCount();
                        row.addElement((rowNo+1));
                           //row.addElement(ipText.getText()+"-"+nameText.getText());
                           row.addElement(line);   
                           row.addElement((String)" ");
                           row.addElement((String) "");
                           row.addElement((String) "");
                           row.addElement((String) "");      
                            row.addElement((String) "");      
                            rows.add(row);                                     //rows is the Vector for table row.
                            Table.addNotify(); 
                  br.close();
                 if possible give me some examples.
    thank you.

    For every row you need to create a new Vector and add the data to that Vector. Then the Vector is added to the TableModel.
    If you add 6 items to the single Vector, then you will get 6 columns. So you need to create 6 Vectors and add a single item to each Vector and therefore you will end up with 6 rows with 1 column of data.

  • How to add users from person or group field in a sharepoint list to sharepoint group

    Hi,
    How to add users(single or multiple) from person or group field in a sharepoint list to sharepoint group programmatically?
    Any suggestions would be appreciated.
    Thank you,
    AA.

    Hello,
    Use SPGroup.AddUser() method to add user in group. I have just written sample code in notepad so it is not tested:
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using(SPSite Site = new SPSite(SPContext.Current.Site.Url))
    Using(SPWeb Web = Site.OpenWeb())
    SPList list = web.Lists["ListName"];
    SPQuery query=new SPQuery ();
    query.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Test</Value></Eq></Where>";
    SPListItemCollection items = list.GetItems(query);
    if(items.Count > 0)
    foreach(SPListItem item in items)
    //Get USers from person or group column
    SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
    SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString());
    SPGroup spGroup = spSite.RootWeb.Groups[groupName];//group name
    if (users.Count != 0)
    bool isUserInGroup = false;
    foreach (SPFieldUserValue user in users)
    foreach (SPUser item in spGroup.Users)
    string itemUserName = item.LoginName;
    string UserName = user.User.LoginName;
    if (itemUserName == UserName)
    isUserInGroup = true;
    break;
    if (!isUserInGroup)
    spGroup.AddUser(user.User);
    The above code will query list item and then get users from "Users" column. Now it will check whetehr user is already in group not, if not then add user in group.
    http://rajanijilla.blogspot.sg/2012/09/add-users-to-group-programmatically.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to add photo from Photos app as iCloud/user avatar?

    Hello,
    I would like to change my login and iCloud user avatar. I have photos in the new Photos app, but I can't import or drag&drop files on the settings screen from Photos.
    "Take a photo with your iOS device or manually add photos from the Photos app." - I would like to do that, but how?
    Thank you!

    Hello,
    I would like to change my login and iCloud user avatar. I have photos in the new Photos app, but I can't import or drag&drop files on the settings screen from Photos.
    "Take a photo with your iOS device or manually add photos from the Photos app." - I would like to do that, but how?
    Thank you!

  • How to add music from ipod to brand new laptop

    I just bought a new laptop and now downloaded itunes, i was needing to know how to add my music from my ipod touch to my itunes library?

    - Transfer iTunes purchases by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    - Transfer othr stuff with third-party programs discussed here:
    Best iPod to PC

  • How to add music from a second computer to my iPhone 5

    I just got an iPhone 5. I can manually control music from my personal laptop and put it on my iPhone. However I can't add it from my brother's lap top. When ever I try to click "manually manage" on his computer, it tells me to erase everything from my iPhone and sync his library. I did autherize  hi computer. How do I add music from his computer with still keeping all of my current music?

    Thanks AmishCake.
    While I'd prefer to not have to do this I suppose it's the only way with my current set up.
    Lots of hostile attention on this forum from people who claim to not care about what I do.

  • How to add folder from KM content to Portal Favorites for selected users

    Hi all,
    I have cretaed  a folder in KM content (In documents) for uploading implementation related ddocuments.
    how to add this folder in "Portal Favorites" of selected users only.
    Please guide.
    Thanks in advance.

    Hi,
    well one way could be the following.
    Go into KM-Content --> Repository "userhome" --> select the user you want --> navigate into his folder Favorites --> create a new internal link in this folder to the folder you want
    In the favorites of the user there is now a link to the desired folder and after clicking a new window will be opened. You can copy this internal link to the favorites folder of the other users you want.
    Regards
    Alex
    Edited by: Alexander Götz on Apr 16, 2009 5:12 PM

  • How to add Activity from ANE to AIR app

    I have developed some native Android code that will (in theory) allow me to play video using the Android MediaPlayer. There are some issues with streaming h264 MP4 videos with AIR on Android that is making this necessary. How do I go about displaying the MediaPlayer within the application? I know it is possible as it is done using this native maps ANE, but I can't seem to figure out how it is done or find source code for it.
    Could anyone shed any light on how you display content from native code in the actual app? I am perfectly okay with it behaving like a StageWebView in terms of sizing and positioning (as is said is necessary by countless people I have read/listened to over the last day or so).
    Thanks for any help

    This isn't available in the default .air install (other than a shortcut to the application.)  However, I would suggest taking a look at the captive runtime options and rolling your own installer.  This way you can do whatever you want on installation without restriction.
    http://www.adobe.com/devnet/air/articles/air3-install-and-deployment-options.html
    Thanks,
    Chris

  • How to add photo from iCloud Photo Library to Apple Mail?

    I have enabled iCloud Photo Library (Beta) and Upload to My Photo Stream on iPhone 5 iOS 8.1, but on OSX new photos are not showing under iCloud drive folder, also if I press Photo Browser button visible are only iPhoto & iCloud menu without new Photos. How to attach photos to Mail from iCloud Photo Library?

    Hi Salsalove,
    Welcome to Apple Support Communities.
    The article linked below will walk you through the process of deleting the photos and videos that you no longer want saved on iCloud, so you don’t have to wait 30 days for them to be delted.
    iCloud security and privacy overview
    Photos
    You can delete unwanted photos from My Photo Stream at any time. Learn about deleting your photos.
    You can delete unwanted photos and videos from your shared albums at any time. Learn how to delete photos and videos from a shared album.
    You can remove subscribers from shared albums that you created at any time. Learn how to move subscribers from your shared album.
    If you’re using Family Sharing, you will be automatically added to an iCloud Photo Sharing shared album with your family members. However, you're in control of what photos, videos, and comments you want to share. Nothing is shared automatically or by default.
    Take care,
    -Jason

  • How to add contents of an arrayList to a JList

    Hi,
    I am trying to figure out how to add the contents of an arraylist to a Jlist.
    Basically I have 3 classes which are as follow:
    1. AuctionItems(String name, int bid) which represents an item in auction
    2. AuctionItemsFactory which creates AuctionItems and adds them to an arraylist called stock
    3. AuctionBidsGui1 which is the interface where the user can see the items in the auction and select them from a JList.
    But I dont know how to read the contents of the stock(arraylist) into the JList which is in AuctionBidsGui1. Below are the 3 classes mentioned above
    public class AuctionItems {
         String name;
         int bid;
         public AuctionItems(){
              name = null;
              bid = 0;
         public AuctionItems(String name, int bid){
              this.name = name;
              this.bid = bid;
         public String getName(){
              return name;
         public int getBid() {
              return bid;
    public class AuctionItemsFactory {
         private ArrayList<AuctionItems> stock;
         int size;
         public AuctionItemsFactory() {
              stock = new ArrayList<AuctionItems>();
         public void addItems(AuctionItems item) {
              stock.add(item);
    //removes last element of the arrayList
         public void removeItems() {
              int n = stock.size() - 1;
              stock.remove(n);
         public void printNumOfItems() {
              int n = stock.size();
              System.out.println(n);
         public int numberOfItems(){
              return stock.size();
         public void printItems(){
              for (AuctionItems item : stock) System.out.println(item);
    and this one is a small part of the AuctionBidsGui1 class which represents the JList where the list of the items will go.
    public void addItemListWidgets() {
              itemsList = new JList();
              itemsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
              itemsList.setLayoutOrientation(JList.VERTICAL);
              itemsList.setVisibleRowCount(10);
              itemsList.setSelectedIndex(0);
              JScrollPane itemsListScroller = new JScrollPane(itemsList); // put the list in the scroller
              itemsListScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
              itemsListScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
              itemsListPanel.add(itemsListScroller);
         }

    I know that I have to use the toArray() but i dont know what type of method to use for this because i will need to implement a method in my AuctionItemsFactory class which will copy the contents of the arraylist into an array so then i can call this methos from my AuctionBidGui1 class.
    I would appreciate if you could give me a bit more hints.

  • How to scan using HP Officejet 4620 create Microsoft Word file how add Word from computer

    Unable to find option to add, install Microsoft Word ( docx) to HP Officejet 4620 Scan.   Need to scan documents to create Word docx file.  Also concerned about Word file size acceptable to email. 
    Dell printer AIO has option to easily add applications as Microsoft Word for scan but not found with HP.
    Searched but did not find solution.  Such as simple question but takes hours and maybe a fee to find answer.

    Hi @Frederickoe8 
    If I understand correctly, you are trying to scan and open the scan file using Word. When you open the scan software, choose Everyday Scan, then under File Type, you can change the file format. If you select Rich Text, the saved scan can then open in Word. As for the scan size and concern with emailing the scan, make sure you do not set the dpi too high as the higher the dpi the larger the file size.
    I hope this helps. 
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • How to add  word document

    Hi ..
    Our aim is to see word document after clicking  context menu(rigt click of mouse) at ANALYZER..
    To see this document,what procedur we have to follow? HOw can we add this word document..?

    Hi,
    As of 7.0 we can upload or main tain documents in deocument are but from 7.3 we can create and maintain in Bex QD it self
    check the below link...
    http://help.sap.com/saphelp_nw73/helpdata/en/43/4e3a1c430e324ee10000000a422035/content.htm
    Regards,
    Satya

  • How to add songs from itunes library to ipod touch 4th gen.?

    i have an ipod touch 4th generation and i have added some new song from the internet to my itunes library. now, how do i add it on to my ipod??

    By:
    iOS: Importing personal photos and videos from iOS devices to your computer

Maybe you are looking for

  • Disable a Column in a JTable

    hiya, i have JTable, and with a button click, i want to make one of the Columns DISABLE not editable or not. can i do that? tx

  • Schedule agreement by target qty

    Is there a way to set up Schedule Agreements by Target qty verses by validity date?  We are using LPA (SA's with JIT/FRC) and would like the schedule agreement to stop generating schedule lines based on the Target Qty set up in the Schedule Agreement

  • I am not able to set high and low limits for each channel seperately using LabWindows/CVI

    I am using AI_StartAcquisition and AI_ReadAcquisition functions to acquire data using PCI 6025E DAQ card and iam using Lab/Wuindows/CVi5.0 software. But one of my transducer has its range in +/- 500 mV soi need to set the high low limits of each chan

  • Writing on a frame.

    Hello. any one know how to write string/s on a frame? what method do I need to use? what class? Thanks in advance , Gonen

  • IBook G3 will not boot from CD/DVD

    Ok, I have an iBook G3. I was restoring it to factory with the Software Restore disks which came with the unit as I was planning to move on to a new unit.. But there was a power cut in the middle of the process and the unit shut off. Now, it does not