| Constructor: |
public SavableTableDialog(Frame owner) {
super(owner);
buildMenus();
}
|
public SavableTableDialog(Dialog owner) {
super(owner);
buildMenus();
}
|
public SavableTableDialog(Frame owner,
JTable table) {
super(owner, table);
buildMenus();
}
|
public SavableTableDialog(Dialog owner,
JTable table) {
super(owner, table);
buildMenus();
}
|
public SavableTableDialog(Frame owner,
TableModel model) {
super(owner, model);
buildMenus();
}
|
public SavableTableDialog(Dialog owner,
TableModel model) {
super(owner, model);
buildMenus();
}
|
public SavableTableDialog(Frame owner,
JScrollPane scrollpane,
JTable table) {
super(owner, scrollpane, table);
buildMenus();
}
Use for tables that are already in a JScrollPane.
Pass table, too, so that it can be contacted for save
operation.
This constructor should work with JRCTables and either
the JTable that describes the reference column or th
the JTable that combines the body columns because those
JTables share the same TableModel. |
public SavableTableDialog(Dialog owner,
JScrollPane scrollpane,
JTable table) {
super(owner, scrollpane, table);
buildMenus();
}
Use for tables that are already in a JScrollPane.
Pass table, too, so that it can be contacted for save
operation.
This constructor should work with JRCTables and either
the JTable that describes the reference column or th
the JTable that combines the body columns because those
JTables share the same TableModel. |
| Methods from java.awt.Component: |
|---|
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, findNextFocusComponent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, generateName, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getGraphicsConfigurationImpl, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setPeer, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, translateEvent, update, validate |
| Method from net.sourceforge.jbird.swing.SavableTableDialog Detail: |
protected final void buildMenus() {
file_menu = new JMenu("File");
csv_item = new JMenuItem("Save as CSV ...");
html_item = new JMenuItem("Save as HTML ...");
close_item = new JMenuItem("Close");
class CloseListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
hide();
if (nullify_on_close) {
nullifyThread();
dispose();
}
}
}
close_item.addActionListener(new CloseListener());
class CSVListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
saveAsCSV();
}
}
csv_item.addActionListener(new CSVListener());
class HTMLListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
saveAsHTML();
}
}
html_item.addActionListener(new HTMLListener());
file_menu.add(csv_item);
file_menu.add(html_item);
file_menu.add(close_item);
menu_bar = new JMenuBar();
menu_bar.add(file_menu);
setJMenuBar(menu_bar);
}
|
public final String getCSVFile() {
return csv_file_name;
}
Return name of file to which table will be saved. |
public final String getHTMLFile() {
return html_file_name;
}
Return name of file to which table will be saved. |
protected void handleException(IOException e) {
if (exception_listener != null) {
exception_listener.receiveObject(e);
} else {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
|
public void nullify() {
file_menu = null;
csv_item = null;
html_item = null;
close_item = null;
menu_bar = null;
exception_listener = null;
if (html_map != null) {
html_map.clear();
html_map = null;
}
if (csv_map != null) {
csv_map.clear();
csv_map = null;
}
super.nullify();
}
Set fields to null and invoke super. Called automatically
when close icon pushed or close menu item chosen if
nullify_on_close is true (see setNullifyOnClose). May
also be closed manually. |
protected void saveAsCSV() {
String userdir = System.getProperty("user.dir");
JFileChooser fc = new JFileChooser(new File(userdir));
fc.setDialogType(JFileChooser.SAVE_DIALOG);
fc.setDialogTitle("WORK HERE");
File file = null;
if (csv_file_name != null && csv_file_name.length() > 0) {
file = new File(csv_file_name);
fc.setSelectedFile(file);
}
int rc = fc.showDialog(this, accept_text);
if (rc == JFileChooser.APPROVE_OPTION) {
file = fc.getSelectedFile();
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file));
}
catch (IOException e) {
handleException(e);
return;
}
try {
TableToDelimited.write(bw,
table,
csv_delimiter, csv_map);
}
catch (IOException e) {
handleException(e);
}
finally {
try {
bw.close();
}
catch (IOException e1) {
}
}
}
}
|
protected void saveAsHTML() {
String userdir = System.getProperty("user.dir");
JFileChooser fc = new JFileChooser(new File(userdir));
fc.setDialogType(JFileChooser.SAVE_DIALOG);
fc.setDialogTitle("WORK HERE");
File file = null;
if (csv_file_name != null && csv_file_name.length() > 0) {
file = new File(csv_file_name);
fc.setSelectedFile(file);
}
int rc = fc.showDialog(this, accept_text);
if (rc == JFileChooser.APPROVE_OPTION) {
file = fc.getSelectedFile();
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file));
}
catch (IOException e) {
System.out.println("saveAsHTML: IOException "
+ e.getMessage());
return;
}
try {
TableToHTML.writeDocument(bw,
table, html_map);
}
catch (IOException e) {
System.out.println("saveAsHTML: IOException "
+ e.getMessage());
}
finally {
try {
bw.close();
}
catch (IOException e1) {
}
}
}
}
|
public final void setCSVFile(String txt) {
csv_file_name = txt;
}
Set file that will appear in file chooser. |
public final void setCSVFormatters(Map map) {
csv_map = map;
}
|
public final void setCSVText(String txt) {
csv_item.setText(txt);
}
Customize name of Save to CSV menu item. |
public final void setCloseText(String txt) {
close_item.setText(txt);
}
Customize name of Close menu item. |
public final void setExceptionListener(ObjectListener ol) {
exception_listener = ol;
}
Supply a listener that will receive
IOExceptions. If no listener is supplied
or if a null value is supplied
the default behavior is to print
the exception and the traceback. |
public final void setFileButton(String txt) {
accept_text = txt;
}
Customize label on Accept button of file
chooser |
public final void setHTMLFile(String txt) {
html_file_name = txt;
}
Set file that will appear in file chooser. |
public final void setHTMLFormatters(Map map) {
html_map = map;
}
|
public final void setHTMLText(String txt) {
html_item.setText(txt);
}
Customize name of Save to HTML menu item. |
public final void setMenuText(String txt) {
file_menu.setText(txt);
}
Customize name of File menu. |