GUI Phonebook - Getting A Button To Work For Deleting Contact?

Apr 24, 2014

I'm working on a GUI Phonebook and need getting a button to work for deleting a contact. I identified the error I get in the Gui class where it says applyDeleteEntry(); on line 106 with comments. The entries are stored in a .txt file which is created for you.

Main class:

import javax.swing.*;
import java.awt.*;
public class Main{
public static void main(String args[]) throws Exception{
Phonebook mainPhonebook = new Phonebook();
Gui mainGui = new Gui();

[Code] .....

View Replies


ADVERTISEMENT

Cannot Get First / Last And Previous Button To Work

Dec 14, 2014

Okay so I have this part done and I cannot get all the JButtons to work. This is my first GUI!

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import java.util.Arrays;
import javax.swing.BoxLayout;

[Code] ....

BTW the error is on 310, 311, and 312 and the error is cannot find symbol ....

View Replies View Related

Swing/AWT/SWT :: How To Make Restart Button Work

Mar 19, 2014

how to make this restart button work. This is what I have so far. I have put the restart button code in red and bold...

package Game;
public class Buttons extends javax.swing.JPanel {
private GameWorld world;
private int restart;

[code]....

View Replies View Related

KeyListener Doesn't Work - Button Is Not Displayed

Apr 14, 2015

Why the keyTyped function isn't triggered, when i type a key?

Here is my code:

package main;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
 
[Code] .....

I have noticed, that if i call setVisible(true) before i add the button, then it works, but the button is not displayed... How can i achieve that the button is displays AND the KeyListener works?

View Replies View Related

Swing/AWT/SWT :: Action Listener Does Not Work With Button Click

Feb 22, 2015

I have buttons created on a frame and then I register the listener from a controller in a controller-view relationship.

When I click the button on the face, the action never executes for some reason. I thought maybe there was a problem registering the listener but I can call the buttons doclick() method and it executes as it should. Perhaps I'm overlooking something really obvious here but I can't see it.

btnEight = new JButton( "8" );
// btnEight.addActionListener( controller );
btnEight.setBounds( 212, 90, 41, 23 );
frame.getContentPane().add( btnEight );

and then I add the listener

public void setController( ActionListener theController ) {
Component[] components = frame.getContentPane().getComponents();
for ( Component component : components ) {
if ( component instanceof JButton ) {
JButton button = ( JButton ) component;
button.addActionListener( theController );
}
}

again, when i click the button nothing happens. but if i add the following code

btnEight.doclick()

the actionPerformed invokes in theController as I intended.

You can see the entire project on GitHub so you can see the full context. The controller class contains the listener and the view class contains the buttons.

View Replies View Related

PhoneBook Application - Allow User To Enter Names / Numbers Of Up To 20 Friends

Apr 13, 2014

This application is supposed to allow a user to enter the names an phone numbers of up to 20 friends, until the user enters "zzz" or 20 names. Then the console is supposed to display the names and have the user enter a name to get the phone number. Here's my code:

import java.util.Scanner;
public class PhoneBook{
public static void main(String[] args){
String name;
int phoneNumber;
final int nameAmount=20;

[Code] ....

I can't seem to get it correct, every time I correct a compiler error, another set of them appear.

View Replies View Related

Contact List - Showing Different Details

Sep 27, 2014

I have this Contact List program and im stuck on how to make my contact list show their different details. I don't know what to do , I want my program to be like this. What should I do next to make my every entry have different information then show on to the right side of the panel the information when i click the show details button .

package phonebook;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;

[Code] ....

View Replies View Related

Contact Information - How To Utilize Objects

Jun 14, 2014

I'm trying to create contact information as object and another object as parcel then calculate the shipping fee. Problem is I don't have a good understanding in implementing object type to my code. Attached are what I've done and I know that my constructor in my parcel class and contact class are probably wrong too but I don't know what to do with it.

//contact class
public class Contact {
private String Name;
private String Address;
private String City;
private String State;
private double Xco;
private double Yco;

[Code] .....

View Replies View Related

Working On A Contact List Program With A GUI

Nov 27, 2014

I am working on a contact list program with a GUI for a school project.I'm running into all kinds of issues when trying to update the JList in my GUI which displays the contacts.I think my issues are being caused by a lack of synchronization between the contact list that stores the data, and the contact list that is being displayed.I've tried all kinds of getters and setters, passing array indexes, passing array member objects etc.

General rundown of how I want the GUI/Code to work: When I select an object in the JLIst, the fields on the right should display that objects information.When the "Add Contact" button is created, a new blank contact should be created and added to the Contact List, and then displayed in the JList.When a field on the right side of the GUI is updated, the object in the contact list is updated simultaneously (using document listener), and therefore the JList would also be updated.

View Replies View Related

ArrayList - Contact Information / Address Book

Jul 5, 2014

I have a question about arraylist objects.... I want to create an address book that will contain a persons information (name, phone, address, email..etc..). The first two snippets of code are from the same class ContactArrayList and the last one is from the class Contact. Do I need to create a separate arraylist for each data type? Is it possible to use a single arraylist to contain all the object (person) information and then be searched for using a GUI? I would also like to be able to access this data to be manipulated using a JFrame (add, edit, and search).

public class ContactArrayList<E> implements List<E> {
public int size, capacity;
E contact;
private E[] contacts;
public ContactArrayList() {
size = 0;
capacity = 20;

[Code] ....

View Replies View Related

Choose Option To Get Contact Details - Not Getting Output Expected

Feb 20, 2015

When I run my program and choose option 2 to get contact details I am expecting it to display as follows (First Name, Last Name): Contacts how have been entered:

0) John Doe
1) George Smith
2) Nancy Davis

Please enter the number corresponding to the contact you would like to view:

Instead for a personal contact it is displaying as follows:Contacts who have been entered:

0) Doe 1 F St. (last name, address)

Please enter the number corresponding to the contact you would like to view:

Instead for a business contact it is displaying as follows:Contacts who have been entered:

0) 1 F St. jd@gmail.com (address, email)

Please enter the number corresponding to the contact you would like to view:

Then when I enter the number to display the contact for personal it is returning me only first name and business is only returning me first and last name. It should be returning the full contact info that was put in during the add contact step. I thought I programmed everything properly but it isn't displaying what I want to seeMy code is listed below.

ContactList

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package contactlist;
import java.util.ArrayList;
import java.util.Scanner;

[code]....

View Replies View Related

Add Color To Ball In Pong - Speed Up When Contact Made With Paddle

Apr 23, 2014

I wrote a code from our text book for Pong. Im trying to figure out how to fill the ball with color. Im also wondering how to speed the ball up once there is contact with the paddle. The initial speed is ok but once contact is made with the paddle, it slows down. Makes it too easy to play. Here is my code so far. As far as the game goes, it works and is good. Just wanted to add a couple customizations.

Java Code:

package pong;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.event.ActionEvent;

[Code] .....

View Replies View Related

Deleting A Node From A BST

Oct 23, 2014

I am having an issue deleting a node for a tree for one of the cases.The cases for deleting a node are:

1. if its the root set it to null
2. if its a leaf, have its parent point to null
3. if the node you want to delete does not have a right child, have deleted nodes parent point to delted nodes only child
4. find the nodes predecessor(next largest value), have have predecessor's left child be deletes left, and preds right to be deletes right. then have deletes parent point to pred and finally, delete preds old spot (the one that is giving me an issue, I believe)

The pre order of the tree I am currently on is 50 5 4 10 190 100 100 200 190 201

or------------------50
-------------5--------------190
---------4------10-----100-------200
--------------------100---190--201

I am trying to delete 190 (which should be the first one)but when I try to print out the list after I delete, I get a stack overflow error when I try printing everything out.I am pretty sure that it has something to do with me hooking up the nodes incorrectly since error occurs for case 4, since it prints out just fine when I deleted previous nodes (like a leaf).Here is my delete method: (note, ignore my determineX and checkOtherHalf methods)

public boolean delete (E item) {
if(root == null){
return false;

else if(item == root){
root = null;
return true;

[code]....

I have confirmed that it is a pointer issue: I need to assign replacements old parents left child to null, to stop it, but idk how.Here is a screen shot of it when I debug it

View Replies View Related

Deleting Word From Sentence

Feb 7, 2015

How to delete word "kumar" from sentence

import java.util.*;
class kumar
{
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
System.out.println("Enter a sentence");
String s=in.nextLine();
s=s=" ";

[Code] ....

I do not get any output nor any error....

View Replies View Related

Deleting From ArrayList / Goes Through Both If And Else And Prints

Dec 8, 2014

I've a ArrayList with dogs on, and I've a function that should allow me to delete a dog from the register and if the dog was found it prints "The dog was deleted" and if the dog doesn't exist in the arraylist it should print "the dog couldn't be found".

Everything works perfect until I shall delete a dog that is not first on the list. Then the program shows first "dog was not found" and on the row after "the dog was deleted" if the dog was second on the list. If it was third I will get 2 messages that the dog wasn't found and then that the dog was deleted. I've no clue why it prints both else and if!

public static void taBortHund(){
//Har tar vi bort hund fran listan
//System.out.println(hundlista);
System.out.print("Vilken hund vill du ta bort? ");
String hunden = tangentbord.nextLine();
for (int taBort = 0; taBort<hundlista.size(); taBort++){

[code]....

View Replies View Related

While Loop - Deleting Elements

Apr 27, 2014

ok so for class I'm supposed to Write a class DeleteElements that prints out an array and asks the user which number should be deleted and then deletes that number, if it exists from the array.

The first part tells me to

Step 1
o Start by simply searching the element.

o Pseudocode:
-Create an array and populate it with random positive integers.
-Print the array to show the user which elements the array contains.
-Use a WHILE loop to search the element—a WHILE loop is better than a FOR loop because you can stop when the element is found by using a Boolean value in the loop condition—and also keep track of the location where the
element might be found.
-If the element is not found, output the error message, “Number not found.”
-Otherwise output the message, “Number found at index #.” where # is the index where the element is.
-Print out the array.

Example of output:
34 65 12 76 45 39 86 71 67
Number to delete: 76
Number found at index 3

This is what I've got so far but I can't seem to get the "number not found part to print out only once".

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class DeleteElement {
public static final int ARR_LENGTH = 10;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Random ran = new Random();

[Code] ....

Current output result if value does not exist:

61 89 52 16 20 71 37 91 4 36
Number to delete:
23
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Current output result if value exists:

97 48 51 22 89 5 42 97 43 96
Number to delete:
89
Number found at index 4

Maybe I'm not understanding the part about the boolean value.

View Replies View Related

Deleting First Line From A Text File

Feb 14, 2015

I am want to delete the first line of text file using RandomAccessFile class. My Input file "bulkwfids.txt" has the data as below:

234567
345578
455678
566667

Expected output needs to be(first line deleted):

345578
455678
566667

But the actual ouput I am getting is as follows:

78
56
345578
455678
566667

Here is the code snippet I have written:

import java.io.*;
class DeleteLine {
public static void main(String [] args) throws FileNotFoundException, IOException {
  RandomAccessFile raf = new RandomAccessFile("C://Users/hp/Desktop/bulkwfids.txt", "rw");
raf.readLine();
 
[Code] .....

View Replies View Related

Servlets :: JSP - Deleting Multiple Row Using Checkbox

Mar 12, 2014

out.println("</select>");
out.println("<link rel='stylesheet' type='text/css' href='css/table.css'/>");
out.println("<input type='text' id='searchText'/>");
out.println("<input type='hidden' id='hide' value='" + selected + "'/>");
out.println("<input type='button' value='Search' onclick='getData()'/>");

[Code] .....

What I want is ..on selecting heading check box...all the below check box should get selected....and clicking on delete button which i will create later on...i want multiple rows to be deleted from database....

Refer image ....

View Replies View Related

Adding And Deleting Item From Array In GUI

Oct 12, 2014

Working on my final which is due today, its' and Inventory Program which I have been working on for the last 5 weeks. My Buttons on my GUI Add/Delete doesn't add items to my inventory. I'm not sure exactly what wrong with my code, I'm not getting any error and the Program compiles just fine, I just can get the Items to add of delete.

my Delete button starts on line 281
my Add Button begins on line 319

//
/** Purpose:the purpose of this software is to display inputs as wells as the stocks and price of inputs,
*as well as display a 5 % restocking fee per dvd and for the entire Invenotry of each object.
*adding a GUI to the code. Adding a Previous button to the existing code allowing the user to cycle through
*the Inventory list freely. Also adding a graphics logo to page. adding more buttons and allowing program to
*save new items added to the inventory.
**/

//Needed Imports for GUI

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.border.EmptyBorder;
import java.io.File;
import java.io.IOException;

[Code] .....

View Replies View Related

Deleting Spaces In Java Code

Mar 1, 2014

My method below works fine to print a matrix but when it prints every row, it is printing extra 4 white spaces which is not required. How can I delete those extra spaces at the end? when I use

System.out.print((matrix[i][j] + " ").replaceAll("^s+", ""));

It trims every thing including the spaces I needed for my matrix. So where should I put replaceAll("^s+", "") ?

Java Code:

private static void printMatrix(int[][] matrix) {
System.out.println();
System.out.println("Matrix:");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
} mh_sh_highlight_all('java');

View Replies View Related

Deleting A Block Of Items From ArrayList

Jan 7, 2015

My current lesson in Java is about ArrayLists and I'm having a tough time to understand this bit of code: This exercise is concerned with the problem of deleting a block of items from an ArrayList.

public static void deleteBlock( ArrayList<String> strings, int n )
{
for ( int i = 0; i < n; i++ )
{
if ( strings.size() > 0 )
strings.remove( i );

[Code] ....

This is the output: [rosion, sion, on, n]

View Replies View Related

Deleting White Spaces In Java Code

Mar 1, 2014

My method below works fine to print a matrix but when it prints every row, it is printing extra 4 white spaces which is not required. How can I delete those extra spaces at the end? when I use

System.out.print((matrix[i][j] + " ").replaceAll("^s+", ""));

It trims every thing including the spaces I needed for my matrix. So where should I put replaceAll("^s+", "") ?

private static void printMatrix(int[][] matrix) {
System.out.println();
System.out.println("Matrix:");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
}

View Replies View Related

Deleting And Editing Phone Book Entries

Jun 22, 2014

I have a program for a phone directory. It needs to add, delete, append, and edit telephone records. I've gotten it to write and search the files. Just need to get it to delete and edit them.

Here's what I have so far:

import java.nio.file.*;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

[code]....

View Replies View Related

Swing/AWT/SWT :: Deleting Shape Drawn On JPanel

Apr 7, 2015

I want to delete the shape i have drawn on the panel. Here is my code

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;

[Code] ....

Why it is not deleting my rectangle.

View Replies View Related

Deleting Case Sensitive File In Java

Oct 17, 2014

If my file name is MyBigXMLFile.xml it won't delete but if I rename it to mybigxmlfile.xml it will delete. How do you get around the case sensitive issue?

View Replies View Related

Deleting Complex Object In Java List

Sep 3, 2014

I am following those three tutorials and I have completed it with success.

( [URL] .... )
( [URL] .... )
( [URL] .... )

But then, as author haven't implemented removeCountries method I tried to create it. What I did initially was to just add to class Countries this method:

public boolean removeCountry(Country country) {
return countries.remove(country);
}

But although compiler wasn't complaining it didn't work. Actually it worked last night (before reboot) but not today. Must be some SOAP iterator/binding thing or whatever. Or I thought that it worked but in fact it didn't.

Here are original classes:

//-------------------------------
public class Country {
String CountryId;
String CountryName;
public Country() {
super();

[Code] ....

I would like to avoid my own iterator as JDeveloper can generate automatically iterators for webservices, but if I can't get it that way, what would be better way to write above mentioned iterator in removeCountry method?

Is there any way to remove object directly with something like this:

co.countries.remove(o);
co.removeCountry(country)

using method

// This left unused
public boolean removeCountry(Country country) {
return countries.remove(country);
}

from class Countries?

Parameters should be set by web service iterator.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved