Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-23-2007, 06:57 AM
Member
 
Join Date: Nov 2007
Posts: 1
look4 is on a distinguished road
Find and Replace in JTable
Hello... i'm new in this forum..
i need some help on how to to write the java code for find and replace the text in the jtable.

that is the find and replace dialog that i used:

import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JButton;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.text.*;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent.*;
import javax.swing.JEditorPane.*;
import javax.swing.JTextPane.*;
import java.text.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Font;
import javax.swing.border.*;
import javax.swing.border.LineBorder;
import javax.swing.SwingConstants;
import javax.swing.SwingConstants.*;
import javax.swing.undo.*;
import javax.swing.event.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.Action;


public class FindDialog extends JDialog implements ActionListener
{

JFrame parent;

private UIController uiController ;
private CellEditor ce =new CellEditor(uiController);
private final static int d_width = 360; // dialog width
private final static int d_height = 150; // dialog height

private JDialog m_owner;
private JTabbedPane tabbedpane;
private JTextField txtFind1;
private JTextField txtFind2;
private Document m_docFind;
private Document m_docReplace;
private JTextField JawiTextField = new JTextField();
private ButtonModel m_modelWord;
private ButtonModel m_modelCase;
private ButtonModel m_modelUp;
private ButtonModel m_modelDown;


public FindDialog(JDialog owner, int index)
{
super(owner, "\u0686\u0627\u0631\u064A\u0020\u06AC\u0646\u062A\ u064A\u0020\u06A4\u0631\u06A9\u0627\u062A\u0627\u0 674\u0646", true);

Document docJawi = ce.getDocument();

tabbedpane = new JTabbedPane();

//?????????????????????????????????????????????????? ?????????????find????????????????????????????????? ???????????????????????????????


// "Find" panel
JPanel p1 = new JPanel(new BorderLayout());

JPanel pc1 = new JPanel(new BorderLayout());

JPanel pf = new JPanel();
pf.setLayout(new GridLayout(3, 1, 5, 5));
pf.setBorder(new EmptyBorder(8, 5, 8, 0));

JLabel findWord2 = new JLabel("\u0686\u0627\u0631\u064A\u0020\u06A4\u0631 \u0643\u0627\u062A\u0627\u0674\u0646\u0020:");
findWord2.setComponentOrientation(java.awt.Compone ntOrientation.RIGHT_TO_LEFT);
findWord2.setToolTipText("Cari Perkataan");
findWord2.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
pf.add(findWord2);

txtFind1 = new JTextField();
txtFind1.setSize(150, 30);
txtFind1.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );

/////////////////////////////////////////////////////////////////////////////////
txtFind1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTexArea1KeyTyped(evt);
}
});

Keymap parent = txtFind1.getKeymap();
Keymap jawi = txtFind1.addKeymap("Jawi", parent);
JTextComponent.loadKeymap( jawi, jawiBindings, jawiActions );
TextAction a = new putJawiAction("Jawi") ;
txtFind1.setKeymap(jawi);
txtFind1.setComponentOrientation(java.awt.Componen tOrientation.RIGHT_TO_LEFT);
/////////////////////////////////////////////////////////////////////////////////

m_docFind = txtFind1.getDocument();
pf.add(txtFind1);
pc1.add(pf, BorderLayout.CENTER);

JPanel po = new JPanel(new GridLayout(2, 2, 8, 2));
po.setBorder(new TitledBorder(new EtchedBorder(), "\u06A4\u064A\u0644\u064A\u0647\u0646"));
po.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
po.setComponentOrientation(java.awt.ComponentOrien tation.RIGHT_TO_LEFT);

JCheckBox chkWord = new JCheckBox("\u0633\u0644\u0648\u0631\u0648\u0647\u0 020\u06A4\u0631\u0643\u0627\u062A\u0627\u0674\u064 6\u0020\u0633\u0647\u0627\u062C\u0020");
chkWord.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
chkWord.setMnemonic('w');
chkWord.setComponentOrientation(java.awt.Component Orientation.RIGHT_TO_LEFT);
chkWord.setToolTipText("Seluruh Perkataan Sahaja");
m_modelWord = chkWord.getModel();
po.add(chkWord);

ButtonGroup bg = new ButtonGroup();
JRadioButton rdUp = new JRadioButton("\u0686\u0627\u0631\u064A\u0020\u0627 \u0631\u0647\u0020\u0627\u062A\u0633\u0020");
rdUp.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
rdUp.setMnemonic('u');
rdUp.setComponentOrientation(java.awt.ComponentOri entation.RIGHT_TO_LEFT);
rdUp.setToolTipText("Cari Arah Atas");
m_modelUp = rdUp.getModel();
bg.add(rdUp);
po.add(rdUp);

JCheckBox chkCase = new JCheckBox("\u0643\u0633\u0633\u0648\u0627\u064A\u0 646");
chkCase.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
chkCase.setMnemonic('c');
chkCase.setComponentOrientation(java.awt.Component Orientation.RIGHT_TO_LEFT);
chkCase.setToolTipText("Padan kes");
m_modelCase = chkCase.getModel();
po.add(chkCase);

JRadioButton rdDown = new JRadioButton("\u0686\u0627\u0631\u064A\u0020\u0627 \u0631\u0647\u0020\u0628\u0627\u0648\u0647\u0020", true);
rdDown.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
rdDown.setMnemonic('d');
rdDown.setComponentOrientation(java.awt.ComponentO rientation.RIGHT_TO_LEFT);
rdDown.setToolTipText("Cari Arah Bawah");
m_modelDown = rdDown.getModel();
bg.add(rdDown);
po.add(rdDown);
pc1.add(po, BorderLayout.SOUTH);

p1.add(pc1, BorderLayout.CENTER);

JPanel p01 = new JPanel(new FlowLayout());
JPanel p = new JPanel(new GridLayout(2, 1, 2, 8));

/* ActionListener findAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
findNext(false, true);
}
};*/

JButton btFind = new JButton("\u0686\u0627\u0631\u064A\u0020\u0633\u064 4\u06A4\u0633\u0020");
btFind.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
// btFind.addActionListener(findAction);
btFind.setMnemonic('f');
btFind.setToolTipText("Cari Selepas");
p.add(btFind);

ActionListener closeAction = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setVisible(false);
}
};
JButton btClose = new JButton("\u062A\u0648\u062A\u0648\u06A4\u0020\u062 A\u062A\u064A\u06A0\u0643\u06A4");
btClose.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
btClose.addActionListener(closeAction);
btClose.setDefaultCapable(true);
btClose.setToolTipText("Tutup Tetingkap");
p.add(btClose);
p01.add(p);
p1.add(p01, BorderLayout.EAST);

tabbedpane.addTab("\u0686\u0627\u0631\u064A", p1);
tabbedpane.setToolTipText("Cari");
tabbedpane.setComponentOrientation(java.awt.Compon entOrientation.RIGHT_TO_LEFT);
tabbedpane.setSelectedIndex(index);


//?????????????????????????????????????????????????? ?????replace?????????????????????????????????????? ??????????????????


// "Replace" panel
JPanel p2 = new JPanel(new BorderLayout());

JPanel pc2 = new JPanel(new BorderLayout());

JPanel pc = new JPanel();
pc.setLayout(new GridLayout(3, 1, 5, 5));
pc.setBorder(new EmptyBorder(8, 5, 8, 0));


txtFind2 = new JTextField();
txtFind2.setSize(150, 30);
/////////////////////////////////////////////////////////////////////////////////////////
Keymap parent2 = txtFind2.getKeymap();
Keymap jawi2 = txtFind2.addKeymap("Jawi", parent2);
JTextComponent.loadKeymap( jawi2, jawiBindings, jawiActions );
TextAction b = new putJawiAction("Jawi") ;
txtFind2.setKeymap(jawi2);
///////////////////////////////////////////////////////////////////////////////////////
txtFind2.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
txtFind2.setComponentOrientation(java.awt.Componen tOrientation.RIGHT_TO_LEFT);
txtFind2.setDocument(m_docFind);
pc.add(txtFind2);


JLabel findWord = new JLabel("\u0686\u0627\u0631\u064A\u0020\u06A4\u0631 \u0643\u0627\u062A\u0627\u0674\u0646\u0020:");
findWord.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
findWord.setComponentOrientation(java.awt.Componen tOrientation.RIGHT_TO_LEFT);
pc.add(findWord);

///////////////////////////////////////////////////////////////////////////////////////
JTextField txtReplace = new JTextField();
Keymap parent3 = txtReplace.getKeymap();
Keymap jawi3 = txtReplace.addKeymap("Jawi", parent3);
JTextComponent.loadKeymap( jawi3, jawiBindings, jawiActions );
TextAction c = new putJawiAction("Jawi") ;
txtReplace.setKeymap(jawi3);

///////////////////////////////////////////////////////////////////////////////////////
m_docReplace = txtReplace.getDocument();
txtReplace.setComponentOrientation(java.awt.Compon entOrientation.RIGHT_TO_LEFT);
txtReplace.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
pc.add(txtReplace);

JLabel chgWord = new JLabel("\u06AF\u0646\u062A\u064A\u0020\u06A4\u0631 \u0643\u0627\u062A\u0627\u0674\u0646\u0020\u062F\u 06A0\u0646\u0020:");
chgWord.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
chgWord.setComponentOrientation(java.awt.Component Orientation.RIGHT_TO_LEFT);
chgWord.setToolTipText("Seluruh Perkataan Sahaja");
pc.add(chgWord);
pc2.add(pc, BorderLayout.CENTER);

po = new JPanel(new GridLayout(2, 2, 8, 2));
po.setBorder(new TitledBorder(new EtchedBorder(), "\u06A4\u064A\u0644\u064A\u0647\u0646"));
po.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
po.setComponentOrientation(java.awt.ComponentOrien tation.RIGHT_TO_LEFT);

chkWord = new JCheckBox("\u0633\u0644\u0648\u0631\u0648\u0647\u0 020\u06A4\u0631\u0643\u0627\u062A\u0627\u0674\u064 6\u0020\u0633\u0647\u0627\u062C\u0020");
chkWord.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
chkWord.setMnemonic('w');
chkWord.setComponentOrientation(java.awt.Component Orientation.RIGHT_TO_LEFT);
chkWord.setModel(m_modelWord);
chkWord.setToolTipText("Seluruh Perkataan Sahaja");
po.add(chkWord);

bg = new ButtonGroup();
rdUp = new JRadioButton("\u0686\u0627\u0631\u064A\u0020\u0627 \u0631\u0647\u0020\u0627\u062A\u0627\u0633\u0020") ;
rdUp.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));;
rdUp.setMnemonic('u');
rdUp.setComponentOrientation(java.awt.ComponentOri entation.RIGHT_TO_LEFT);
rdUp.setToolTipText("Cari arah Atas");
rdUp.setModel(m_modelUp);
bg.add(rdUp);
po.add(rdUp);

chkCase = new JCheckBox("\u0643\u0633\u0633\u0648\u0627\u064A\u0 646\u0020");
chkCase.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
chkCase.setMnemonic('c');
chkCase.setModel(m_modelCase);
chkCase.setComponentOrientation(java.awt.Component Orientation.RIGHT_TO_LEFT);
chkCase.setToolTipText("Padan Kes");
po.add(chkCase);

rdDown = new JRadioButton("\u0686\u0627\u0631\u064A\u0020\u0627 \u0631\u0647\u0020\u0628\u0627\u0648\u0647\u0020", true);
rdDown.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
rdDown.setMnemonic('d');
rdDown.setModel(m_modelDown);
rdDown.setComponentOrientation(java.awt.ComponentO rientation.RIGHT_TO_LEFT);
chgWord.setToolTipText("Cari Arah Bawah");
bg.add(rdDown);
po.add(rdDown);
pc2.add(po, BorderLayout.SOUTH);

p2.add(pc2, BorderLayout.CENTER);

JPanel p02 = new JPanel(new FlowLayout());
JPanel pr = new JPanel(new GridLayout(3, 1, 2, 8));

/*ActionListener replaceAction = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
findNext(true, true);
}
};*/
JButton btReplace = new JButton("\u06AC\u0646\u062A\u064A\u0020\u06A4\u063 1\u0643\u0627\u062A\u0627\u0674\u0646");
btReplace.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
// btReplace.addActionListener(replaceAction);
btReplace.setMnemonic('r');
btReplace.setToolTipText("Ganti Perkataan");
pr.add(btReplace);

/* ActionListener replaceAllAction = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int counter = 0;
while (true)
{
int result = findNext(true, false);
if (result < 0) // error
return;
else if (result == 0) // no more
break;
counter++;
}
// JOptionPane.showMessageDialog(m_owner, counter+"\u06AC\u0646\u062A\u064A\u0627\u0646\u002 0\u06A4\u0631\u0643\u0627\u062A\u0627\u0674\u0646. ", "Info",JOptionPane.INFORMATION_MESSAGE);
}
};*/

JButton btReplaceAll = new JButton("\u06AC\u0646\u062A\u064A\u0020\u0633\u064 5\u0648\u0627");
btReplaceAll.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18));
// btReplaceAll.addActionListener(replaceAllAction);
btReplaceAll.setMnemonic('a');
pr.add(btReplaceAll);

btClose = new JButton("\u062A\u0648\u062A\u0648\u06A4\u0020\u062 A\u062A\u064A\u06A0\u0643\u06A4");
btClose.setFont( new Font("Arial Jawi KUTPM", Font.PLAIN, 18) );
btClose.addActionListener(closeAction);
btClose.setDefaultCapable(true);
pr.add(btClose);
p02.add(pr);
p2.add(p02, BorderLayout.EAST);

// Make button columns the same size
p01.setPreferredSize(p02.getPreferredSize());

tabbedpane.addTab("\u06AC\u0646\u062A\u064A", p2);
tabbedpane.setComponentOrientation(java.awt.Compon entOrientation.RIGHT_TO_LEFT);
tabbedpane.setSelectedIndex(index);
getContentPane().add(tabbedpane, BorderLayout.CENTER);
pack();
setResizable(false);
}

// public int findNext(boolean doReplace, boolean showWarnings){
// return (true, false);
// }

public void actionPerformed(ActionEvent event){

}

private void jTexArea1KeyTyped(java.awt.event.KeyEvent evt) {
JawiTextField.repaint();
}

static final JTextComponent.KeyBinding[] jawiBindings =
{
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' q'),"putJawi \u0636"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' w'),"putJawi \u0635"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' e'),"putJawi \u062B"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' r'),"putJawi \u0642"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' t'),"putJawi \uu0641"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' y'),"putJawi \u063A"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' u'),"putJawi \u0639"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' i'),"putJawi \u06BE"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' o'),"putJawi \u062E"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' p'),"putJawi \u062D"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' P'),"putJawi \u061B"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke('['),"putJawi \u062C"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(']'),"putJawi \u062F"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' a'),"putJawi \u0634"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' s'),"putJawi \u0633"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' d'),"putJawi \u064A"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' f'),"putJawi \u0628"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' g'),"putJawi \u0644"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' h'),"putJawi \u0627"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' j'),"putJawi \u062A"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' k'),"putJawi \u0646"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' l'),"putJawi \u0645"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' ;'),"putJawi \u06A9"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' "'),"putJawi \u0637"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' z'),"putJawi \u0626"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' x'),"putJawi \u0621"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' c'),"putJawi \u0624"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' v'),"putJawi \u0631"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' b'),"putJawi \u0644\u0627"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' n'),"putJawi \u0649"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' m'),"putJawi \u0629"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' ,'),"putJawi \u0648"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' .'),"putJawi \u0632"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke('/'),"putJawi \u0638"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' `'),"putJawi \u0630"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 1'),"putJawi \u0661"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 2'),"putJawi \u0662"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 3'),"putJawi \u0663"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 4'),"putJawi \u0664"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 5'),"putJawi \u0665"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 6'),"putJawi \u0666"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 7'),"putJawi \u0667"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 8'),"putJawi \u0668"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 9'),"putJawi \u0669"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' 0'),"putJawi \u0660"),//changed!
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' ?'),"putJawi \u061F"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' <'),"putJawi \u060C"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' Q'),"putJawi \u0686"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' W'),"putJawi \u06AF"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' E'),"putJawi \u06A4"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' R'),"putJawi \u06A0"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' T'),"putJawi \u06CF"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' Y'),"putJawi \u0625"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' U'),"putJawi \u066C"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' S'),"putJawi \u0643"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' K'),"putJawi \u06BD"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' G'),"putJawi \u0674"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' H'),"putJawi \u0623"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' X'),"putJawi \u06D5"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' >'),"putJawi \u002E"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke('-'),"putJawi \u002D")
};

static final Action[] jawiActions =
{
new putJawiAction("\uFE95"),
new putJawiAction("\uFEB1"),
new putJawiAction("\uFB8E"),
new putJawiAction("\uFEA1"),
new putJawiAction("\u0627"),
new putJawiAction("\u0628"),
new putJawiAction("\u062A"),
new putJawiAction("\u062B"),
new putJawiAction("\u062C"),
new putJawiAction("\u062D"),
new putJawiAction("\u062E"),
new putJawiAction("\u062F"),
new putJawiAction("\u0630"),
new putJawiAction("\u0631"),
new putJawiAction("\u0632"),
new putJawiAction("\u0633"),
new putJawiAction("\u0634"),
new putJawiAction("\u0635"),
new putJawiAction("\u0636"),
new putJawiAction("\u0637"),
new putJawiAction("\u0638"),
new putJawiAction("\u0639"),
new putJawiAction("\u063A"),
new putJawiAction("\u0641"),
new putJawiAction("\u0642"),
new putJawiAction("\u06A9"),
new putJawiAction("\u0644"),
new putJawiAction("\u0645"),
new putJawiAction("\u0646"),
new putJawiAction("\u0648"),
new putJawiAction("\u06BE"),
new putJawiAction("\u0644\u0627"),
new putJawiAction("\u0623"),
new putJawiAction("\u0625"),
new putJawiAction("\u0626"),
new putJawiAction("\u0674"),
new putJawiAction("\u0621"),
new putJawiAction("\u064A"),
new putJawiAction("\u06CF"),
new putJawiAction("\u0686"),
new putJawiAction("\u06A0"),
new putJawiAction("\u06A4"),
new putJawiAction("\u0647"),
new putJawiAction("\u06D5"),
new putJawiAction("\u06AF"),
new putJawiAction("\u06BD"),
new putJawiAction("\u06CC"),
new putJawiAction("\u0649"),
new putJawiAction("\u0629"),
new putJawiAction("\u002D"),
new putJawiAction("\u0624"),
new putJawiAction("\u066C"),
new putJawiAction("\u061B"),
new putJawiAction("\u0660"),
new putJawiAction("\u0661"),
new putJawiAction("\u0662"),
new putJawiAction("\u0663"),
new putJawiAction("\u0664"),
new putJawiAction("\u0665"),
new putJawiAction("\u0666"),
new putJawiAction("\u0667"),
new putJawiAction("\u0668"),
new putJawiAction("\u0669"),
new putJawiAction("\uFDF2"),
new putJawiAction("\u060C"),
new putJawiAction("\u061B"),
new putJawiAction("\u061F"),
new putJawiAction("\u0020"),
new putJawiAction("\u0640")
};
static class putJawiAction extends TextAction {

public putJawiAction( String s ) {
super("putJawi "+s);
//System.out.println(s);
this.s = s;
}

public void actionPerformed(ActionEvent e) {
JTextComponent target = getTextComponent(e);
if (target != null) {
target.replaceSelection(s);
}
}
private String s;
}
}
//find word
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-23-2007, 08:42 PM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
It depends on the JTable. The easiest way is if you have the JTable populated from a String[]. Then you can just iterate trough the array finding what you need to replace.

Code:
public void replace(String old, String new) { for (int i =0; i < arr.length(); i ++) { if(arr[i].equals(old)) { arr[i] = new; } } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-24-2007, 01:27 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,141
hardwired is on a distinguished road
In attempting to compile your code
Code:
... fd.java:324: illegal unicode escape btClose = new JButton("\u062A\u0648\u062A\u0648\u06A4\u0020\u062 A\u062A\u064A\u 06A0\u0643\u06A4"); ^ fd.java:336: ')' expected tabbedpane.setComponentOrientation(java.awt.Compon entOrientation.RIGHT_TO_LEFT) ; ^ ... fd.java:408: unclosed character literal new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(' T'),"putJawi \u06CF"), ^ 100 errors
After fixing the typos and commenting out the KeyStrokes
Code:
C:\jexp>javac fd.java fd.java:38: cannot find symbol symbol : class UIController location: class FD private UIController uiController ; ^ fd.java:39: javax.swing.CellEditor is abstract; cannot be instantiated private CellEditor ce =new CellEditor(uiController);
Your KeyStroke.getKeyStroke arguments are messed up and
we do not have the UIController and CellEditor classes.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace ( in a String hamish10101 New To Java 6 01-17-2008 06:51 AM
Using a replace method... paul New To Java 2 08-07-2007 05:50 AM
problems with replace method cecily New To Java 1 08-02-2007 10:11 PM
String replace method venkata.tarigopula Advanced Java 1 07-10-2007 09:14 PM
Using Find And Replace In Eclipse IDE JavaForums Eclipse 0 04-26-2007 11:15 AM


All times are GMT +3. The time now is 01:10 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org