How To Implement UNDO Feature

Mar 10, 2014

I need to design 'notepad' application as my assignment.

Requirement: Only text is allowed, all the characters are having same size and font. It should have feature like new, open, save , save as , exit , UNDO , find , replace and font.

For this i use JTextArea and menu bar .

I am able to develop features like new, open, save , save as , exit. Need to implement now UNDO , find , replace and font but struck at 'UNDO'.

UNDO feature should be enable only when user writing in the writing area but not when it opens any file. What i thought is to have a flag on whenever user save whatever he wrote and if he use select UNDO then it check for the flag. If flag is ON then it will not do UNDO and if flag is not set then it cleared everything from the Text Area.

View Replies


ADVERTISEMENT

Undo Option In Jtable?

Apr 24, 2014

I am trying to create a JTable and I want to implement an undo option in it. Is it possible that I store the table model at some part of the operation and later when i press an undo button or something, I can set the saved table model so that it will perform like an undo.

View Replies View Related

Using Command Pattern For Undo And Redo In ArrayLists

Apr 15, 2015

So I have a program where you can log in and add/remove friends to and from the friends arraylist. Also I can like a certain thing and that thing will be stored into the likes arraylist. I'm asked to make undo and redo options for whichever action I do.I want to add apple as a friend. After that when I select the undo option, I can undo that action so apple wouldn't be my friend. How I can approach this with a Command Pattern when the input is whatever name or word I inputted to store into the friends arraylist?

I did some research and found that using a command pattern could be my best bet since this has to be done under the Facebook Class I already have. I decided to add parts of what I have ...

In the driver program

Facebook facebook1 = new Facebook();

if (userInput == 6) {
System.out.println("Login");
String operand1 = getOperand("What is the Username? ");
String operand2 = getOperand("What is the Password? ");
System.out.println("Enter a friend to be added. ");
String operand3 = getOperand("What is the Username? ");
facebook1.friend(operand3);

[code]....

View Replies View Related

Web Services :: Add Uploading Image Feature To Form

Apr 21, 2015

I'm using json to submit form from web and mobile, I want to add uploading image feature to this form. How can I do that with code if possible?

View Replies View Related

JSF :: Export To Excel With Indexing Feature With Icefaces 1.8.2

Feb 24, 2014

As of now am using icefaces 1.8.2 provided tags for downloading data into excel sheet where i can download all the data from a data table. But now the requirement is like need to download the data into excel sheet based on values passed from UI as parameters to the action class method.

Attaching the code snippet along with this post.

CustomerList.xhtml :-
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<ice:outputLabel value="Export:" />

[Code] ....

View Replies View Related

Erasure Feature From Generics - Duplicated Bound Error

Jun 14, 2014

The erasures of all constituent types of a bound must be pairwise different, or a compile-time error occurs.

Well I know what type erasure is, and I think I kind got what this statement means. My understanding from it is that if your type parameter has more than one bound and those bounds occurs to be the same type after erasure that is a compile-time error. Is that it?

The only thing I could found related is something like this:

class A<T extends List<Integer> & List<Integer>>{
}

Which as you might know gives the Duplicated bound error.

View Replies View Related

Which Iterator To Be Use To Create Instances From Feature Value Pairs (Mallet API)

Mar 12, 2015

I am tring to run LDA to generate some topics from txt files as the following one:

Document1 label1 forest=3.4 tree=5 wood=2.85 hammer=1 colour=1 leaf=1.5
Document2 label2 forest=10 tree=5 wood=2.75 hammer=1 colour=4 leaf=1
Document3 label3 forest=19 tree=0.90 wood=2 hammer=2 colour=9 leaf=4.3
Document4 label4 forest=4 tree=5 wood=10 hammer=1 colour=6 leaf=3

Each numeric value in the file is an indication of the number of occurrences of each feature (e.g., forest, tree) multiplied by a given penalty. To generate instances from such a file, I use the following Java code:

String lineRegex = "^(S*)[s,]*(S*)[s,]*(.*)$";
String dataRegex = "[p{L}([0-9]*.[0-9]+|[0-9]+)_=]+";
InstanceList generateInstances(String dataPath) throws UnsupportedEncodingException, FileNotFoundException {
ArrayList<Pipe> pipeList = new ArrayList<Pipe>();
pipeList.add(new Target2Label());

[Code] .....

I then add the so-generated instances to my model using the instruction model.addInstances(generatedInstances). The resulting output is described below.

It contains errors caused by the instruction model.addInstances(generatedInstances). Debugging my code showed me that the alphabet associated to the model is null. Am I using the wrong iterator?

name: document1
target: label1
input: TokenSequence [forest=3.4 feature(forest)=3.4 span[0..10], tree=5 feature(tree)=5.0 span[11..17], wood=2.85 feature(wood)=2.85 span[18..27], hammer=1 feature(hammer)=1.0 span[28..36], colour=1 feature(colour)=1.0 span[37..45], leaf=1.5 feature(leaf)=1.5 span[46..54]]
Token#0:forest=3.4 feature(forest)=3.4 span[0..10]

[Code] ....

View Replies View Related

Servlets :: Feature Detection - Determine Browser Type

Apr 22, 2014

I need to be able to detect IE 9, IE 10, IE 11 and the latest from Firefox and Chrome. The old method using the user-agent string is unreliable and not recommended. There is a different approach called, "Feature Detection". But I need to know what features to test to determine the browser. I can write it myself, or if there is a handy dandy API using feature detection already written that would be OK too.

View Replies View Related

How To Create Withdraw / Deposit Feature So It Can't Exceed Maximum Limit

Nov 25, 2014

So lets say I got maximum of 20 deposit, I want to create a method/function (idk what proper name for it is) so that you cannot deposit more than 20 nor withdraw more than you have in your account, so this function checks your account, if your total is for example 18 and you're trying to deposit 10, it rejects it and doesn't add to your total and pops up with a message, vice versa for withdraw.

This is what I have so far

Not I already have the maximum limit + total feature created just not displayed here

public void depositMoney (int dMoney) {
if(DMoney > 0 ) {
totalMoney = totalMoney + dMoney;
}
else {
System.out.println("Please insert money more than 0");

[Code] .....

View Replies View Related

How To Create Withdraw / Deposit Feature So It Cannot Exceed Maximum Limit (read)

Nov 25, 2014

So lets say I got maximum of 20 deposit, I want to create a method/function (idk what proper name for it is) so that you cannot deposit more than 20 nor withdraw more than you have in your account, so this function checks your account, if your total is for example 18 and you're trying to deposit 10, it rejects it and doesn't add to your total and pops up with a message, vice versa for withdraw.

This is what I have so far . Not I already have the maximum limit + total feature created just not displayed here

Java Code:

public void depositMoney (int dMoney) {
if(DMoney > 0 ) {
totalMoney = totalMoney + dMoney;
} else {
System.out.println("Please insert money more than 0");

[Code] ....

View Replies View Related

Web Services :: How To Implement Rest API

Mar 26, 2015

how to implement the Rest API which is like "URL...". And how to implement in Java where the class extends ServerResource.

View Replies View Related

How To Implement A Variable Into Another Class

Apr 13, 2015

I would like to implement a variable in a class that is used in another class, how can I do that?

I have a Mall class and a Customer class I would like to associate the position of the customer that is in the Mall class and also implement the same in the Customer class.

Here is a small part of the code without all the methods.

//the two objects
Mall m = new Mall("RandomMall",50,30);
Customer c1= new Customer("Jack",1240);
//the first part of the mall class without the methods
class Mall{
private String name;
private int width,length;
String[][]grid = new String[width][length];

[code]...

View Replies View Related

Swing/AWT/SWT :: How To Implement ActionListener

Feb 7, 2014

I have a class with jbutton declared inside like these:

public class UI{
private JFrame ventana;
private JTable table;
private JPanel panel;
private JScrollPane tableScrollPane;
private JTextField aBuscar;

[Code] .....

I would like to add actionlistener in my JButton's. Where must I declared these listener. How should I do these?

View Replies View Related

How To Implement JMenu Actions

Dec 17, 2014

I'm trying to modify an existing code and I'm having trouble with it. I want to add two things to a java Sudoku menu. I added JMenu 5 and JMenu 6 but now I have to make them work. When the user clicks on "Aide" and then "Reglements", I need to have an image that pops and that disappear when the user clicks on it.

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

[Code] .....

View Replies View Related

Implement A Priority Queue

Apr 15, 2014

Implement a priority queue based on a sorted linked list. The remove operation on the priority queue should remove the item with the smallest key.

View Replies View Related

Implement Type Of Container

Mar 15, 2014

I want to implement a kind of "container" in which to store objects (instances) of different types. Then with an iterator I'd call common methods. This is what I have in mind:

Java Code:
with(Positionables){
translate(2, 0, 4);
} mh_sh_highlight_all('java');

Where translate(x, y, z) is a method common for objects in Positionables which objects are of different types (Sphere, Box etc.).

Now I was thinking Positionables could be a List<Positionable> and Positionable is an abstract class and Sphere and Box extends from it. But I don't know how to propagate the call of translate() to the subclasses.

What are the best approaches for this matter? It would be perfect if I could make it so I could somehow use the "with" construction like in the example above.

View Replies View Related

ERROR When Try To Implement A Class

Dec 6, 2014

I'm writing a simple queue program using a netbeans as a GUI program I've used netbeans GUI editor to create the GUI my main problem was I've written the queuing code to a button function it works but it runs only once and the queue becomes empty on the second run. So I implemented a class which will create the queue outside the button click event but when I do that I get a Symbol not found: method error . The place where I get the error:

addStd1.setText("Add Student");
addStd1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addStd1ActionPerformed(evt);
}

My button function with the class:

class stdQueCls{
Queue stdQue;
public stdQueCls(){
stdQue = new LinkedList();
}
private void addStd1ActionPerformed(java.awt.event.ActionEvent evt) {

[code]....

View Replies View Related

Class Can't Implement Chart

Mar 10, 2014

i'm getting cryptic error messages for the following code:

class MyChar implements CharSequence{
private String s;

public MyChar(String input)
{
StringBuilder b = new StringBuilder(input);
b.reverse();
this.s = b.toString();

[code]....

it's telling me something's wrong with the class modifier and that my class can't implement chart

View Replies View Related

Implement Attached Interface

Nov 16, 2014

I need to implement the attached interface ("Locality"). In the attached UML diagram it has a 1 on 1 relationship with the class "Team". I don't know if this can be somehow implemented in Java. Can I create the attribute "team" in the Locality interface and let it be used by the "Town" and "City" classes? Could it be better to implement it as an abstract class instead?

View Replies View Related

How To Implement Own String Class

Feb 12, 2015

I am a beginner at Java programming. how to implement my own String class, but I have to provide my own implementation for the following methods:

public MyString1(char[ ] chars)
public char charAt(int index)
public int length( )
ublic MyString1 substring(int begin, int end)
public MyString1 toLowerCase( )

[code]....

I have looked through the API, but I don't really understand where to start.

View Replies View Related

JSF :: Getting ClassNotFoundException When Trying To Implement Web Filter In App

Feb 6, 2014

I have a JSF app and for some reasons i need to refresh the page on browser back button.I tried implementing the solution given in Force JSF to refresh page / view / form when back button is pressed ,the only difference is that my app runs with servlet version 2.5 so i did the mapping in web.xml as below

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>

[code]....

View Replies View Related

Implement Filewriter To Code

Apr 27, 2014

Ive been trying to implement the Filewriter to my code. What I want is to have the textfield data written to a text field. Im thinking you have to specify the text field you want to have in the filewriter statement,I've done something like this, Ive used the try catch block.

if (source == jBPay) {
System.out.println("Pay");
{
double dOrderTotal = dTotal*1.2;
jTTotal.setText(Double.toString(dOrderTotal));
jTTotal.setHorizontalAlignment(JTextField.CENTER); // align text field centre
jTotal.setText(String.format("%.2f", dTotal)); // set pay text field to 2 decimal place

[code]...

What I want is to have the textfield data written to a text file*Hi all, Ive been trying to implement the Filewriter to my code but I cant figure out what im doing wrong.What I want is to have the file data written to a text field. Im thinking you have to specify the text field you want to have in the filewriter statement.

if (source == jBPay) {
System.out.println("Pay");
{
double dOrderTotal = dTotal*1.2;

[code]...

how do I delete a double comment?

View Replies View Related

How To Implement ToString For Arrays

Mar 3, 2015

I really want to know it. When we write ...

>>> Student s = new Student("Roll No", "Name");
>>> System.out.println(s);

Then it gives output according to the way that toString() of Student is implemented,right ? What if I wanna do the same for arrays?? I mean to ask, let us say I have array int[] arr = { 1, 2, 3, 4, 5}. When I say System.out.println(arr), it should give the output as it gives for collections [1,2,3,4,5].

I know that Arrays.toString(int[]) can work for us in this regard. But my question is that can we write our own toString() method so that when I print the "arr" (an Object itself) it should call the toString() that we implemented like a callback function.

View Replies View Related

How To Implement Class DynamicArrayStack

Feb 9, 2015

While learning how to implement the class DynamicArrayStack, I've run into some operators and syntax I'm unfamiliar with!

public class DynamicArrayStack{
protected int capacity
public static int MINCAPACITY=1<<15;
protected int[] stackRep;
protected int top = -1;
//initializes stack to use an array of default length
public DynamicArrayStack()
this(CAPACITY)

[code]....

View Replies View Related

JSF :: Implement A File Upload Functionality?

Apr 16, 2014

I am trying to implement a file upload functionality. One of the requirement is to display a 'Please Wait!!!' message to the user while the upload is going on. My project currently uses JSF 1.2, Tomahawk, JQuery 1.9, JQuery UI 1.10. I am aware that this can be accomplished using a4j with richfaces, however I am not supposed to add any new library to the existing project. how this can be done?

View Replies View Related

Classes Of Object - Implement Two Out Of Three Interfaces

May 8, 2014

I have three classes of object, most of which must implement two out of three interfaces. The interfaces look like this:

public interface Source {
public void startSending();
} public interface Sender {
public void setReceiver();

[Code] .....

That works fine, but I am wondering if pairing the interfaces into subinterfaces is a defensible methodology. For example, all classes that act like Producer must implement both the Source and Sender interfaces. And all classes that act like Relayer must implement the Sender and BlackHole interfaces. I could define two subinterfaces like this:

public interface Factory extends Source, Sender {
}
public interface Modifier extends BlackHole, Sender {
}

I could then define my classes like this:

public class Producer implements Factory {
}
public class Relayer implements Modifier {
}
public class Consumer implements BlackHole {
}

Within the class definitions, it makes no difference, as I will have to implement the same methods either way. But it seems more self-documentary to create the subinterfaces from their parent interfaces and name them in ways that reflect what the classes that implement them must actually do.

View Replies View Related







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