Added the following features: now starts with focus on the input pane, shortcut ctrl+T to translate, and after translating focus is automatically set on the first element.
This commit is contained in:
parent
58819cf43d
commit
efec654ee8
5 changed files with 58 additions and 45 deletions
|
@ -157,6 +157,11 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener
|
||||||
toolBar.add(keyboard);
|
toolBar.add(keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocusToInput()
|
||||||
|
{
|
||||||
|
duffInput.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
|
||||||
public void addFocusListener(FocusListener fl)
|
public void addFocusListener(FocusListener fl)
|
||||||
{
|
{
|
||||||
txtInput.addFocusListener(fl);
|
txtInput.addFocusListener(fl);
|
||||||
|
@ -270,6 +275,7 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener
|
||||||
}
|
}
|
||||||
table.tableChanged(new TableModelEvent(model));
|
table.tableChanged(new TableModelEvent(model));
|
||||||
table.repaint();
|
table.repaint();
|
||||||
|
if (table.getRowCount()>0) table.setRowSelectionInterval(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWylieInput(boolean enabled)
|
public void setWylieInput(boolean enabled)
|
||||||
|
|
|
@ -215,5 +215,6 @@ public abstract class ScannerPanel extends Panel implements ActionListener
|
||||||
public abstract void translate();
|
public abstract void translate();
|
||||||
public abstract void clear();
|
public abstract void clear();
|
||||||
public abstract void setWylieInput(boolean enabled);
|
public abstract void setWylieInput(boolean enabled);
|
||||||
|
public abstract void setFocusToInput();
|
||||||
public void addFocusListener(FocusListener fl) {}
|
public void addFocusListener(FocusListener fl) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,11 @@ public class SimpleScannerPanel extends ScannerPanel implements ItemListener
|
||||||
add(cardPanel, BorderLayout.CENTER);
|
add(cardPanel, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocusToInput()
|
||||||
|
{
|
||||||
|
txtInput.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
|
||||||
public void itemStateChanged(ItemEvent e)
|
public void itemStateChanged(ItemEvent e)
|
||||||
{
|
{
|
||||||
int n = listDefs.getSelectedIndex();
|
int n = listDefs.getSelectedIndex();
|
||||||
|
|
|
@ -18,21 +18,11 @@ Contributor(s): ______________________________________.
|
||||||
|
|
||||||
package org.thdl.tib.scanner;
|
package org.thdl.tib.scanner;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Frame;
|
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.Menu;
|
|
||||||
import java.awt.MenuBar;
|
|
||||||
import java.awt.MenuItem;
|
|
||||||
import java.awt.TextArea;
|
|
||||||
import java.awt.TextComponent;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.FocusEvent;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
@ -145,6 +135,12 @@ public class SwingWindowScannerFilter extends WindowScannerFilter
|
||||||
mnuDicts=null;
|
mnuDicts=null;
|
||||||
|
|
||||||
mb.add(m);
|
mb.add(m);
|
||||||
|
m = new Menu("Tools");
|
||||||
|
mnuTranslate = new MenuItem ("Translate");
|
||||||
|
mnuTranslate.setShortcut(new MenuShortcut(KeyEvent.VK_T));
|
||||||
|
mnuTranslate.addActionListener(this);
|
||||||
|
m.add(mnuTranslate);
|
||||||
|
mb.add(m);
|
||||||
|
|
||||||
m = new Menu("Help");
|
m = new Menu("Help");
|
||||||
|
|
||||||
|
@ -191,6 +187,7 @@ public class SwingWindowScannerFilter extends WindowScannerFilter
|
||||||
//else mainWindow.setSize(500,600);
|
//else mainWindow.setSize(500,600);
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.toFront();
|
mainWindow.toFront();
|
||||||
|
sp.setFocusToInput();
|
||||||
|
|
||||||
if (!ThdlOptions.getBooleanOption(AboutDialog.windowAboutOption))
|
if (!ThdlOptions.getBooleanOption(AboutDialog.windowAboutOption))
|
||||||
{
|
{
|
||||||
|
@ -323,6 +320,10 @@ public class SwingWindowScannerFilter extends WindowScannerFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (clicked == mnuTranslate)
|
||||||
|
{
|
||||||
|
sp.translate();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (objModified==null) return;
|
if (objModified==null) return;
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class WindowScannerFilter implements WindowListener, FocusListen
|
||||||
protected static String defaultOutputRows = "thdl.scanner.output-pane.rows";
|
protected static String defaultOutputRows = "thdl.scanner.output-pane.rows";
|
||||||
|
|
||||||
protected ScannerPanel sp;
|
protected ScannerPanel sp;
|
||||||
protected MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref;
|
protected MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref, mnuTranslate;
|
||||||
protected CheckboxMenuItem mnuDicts;
|
protected CheckboxMenuItem mnuDicts;
|
||||||
protected Object objModified;
|
protected Object objModified;
|
||||||
protected AboutDialog diagAbout;
|
protected AboutDialog diagAbout;
|
||||||
|
|
Loading…
Reference in a new issue