As I said, I am creating an application for professional use. I'm programming in Java and use the Firebird database. Java and chose this database because it's all in Open Source, to run on Windows, Linux, and perhaps in OS X (not tried yet).
I was using jaybird-full-2.1.6.jar, to make connections to store images in BLOB fields. But each time he made the connection with specific parameters, always gave the following error:
java.sql.SQLException: not yet implemented
The problem was in the library which had created the necessary methods.
The quickest solution is to use the latest version, jaybird-full-2.2.0.jar.
A popup menu to be used in the swing. This code is simplified. Can be used in a fnal class or within a class of its own.
public class GPaises extends javax.swing.JInternalFrame {
private void createPopupMenu() {
try {
//Create the popup menu wiht icons .
JPopupMenu popup = new JPopupMenu();
JMenuItem menuItem;
menuItem = new JMenuItem("Cut, new ImageIcon(getClass().getResource("/gii/images/cut_red.png")));
menuItem.setHorizontalTextPosition(JMenuItem.RIGHT);
menuItem.addActionListener(menuListener);
popup.add(menuItem);
menuItem = new JMenuItem("Copy", new ImageIcon(getClass().getResource("/gii/images/page_copy.png")));
menuItem.setHorizontalTextPosition(JMenuItem.RIGHT);
menuItem.addActionListener(menuListener);
popup.add(menuItem);
menuItem = new JMenuItem("Paste", new ImageIcon(getClass().getResource("/gii/images/page_paste.png")));
menuItem.setHorizontalTextPosition(JMenuItem.RIGHT);
menuItem.addActionListener(menuListener);
popup.add(menuItem);
menuItem = new JMenuItem("Delete", new ImageIcon(getClass().getResource("/gii/images/page_delete.png")));
menuItem.setHorizontalTextPosition(JMenuItem.RIGHT);
menuItem.addActionListener(menuListener);
popup.add(menuItem);
popup.addSeparator();
menuItem = new JMenuItem("Add", new ImageIcon(getClass().getResource("/gii/images/picture_add.png")));
menuItem.setHorizontalTextPosition(JMenuItem.RIGHT);
menuItem.addActionListener(menuListener);
popup.add(menuItem);
menuItem = new JMenuItem("Save", new ImageIcon(getClass().getResource("/gii/images/picture_save.png")));
menuItem.setHorizontalTextPosition(JMenuItem.RIGHT);
menuItem.addActionListener(menuListener);
popup.add(menuItem);
//Add listener to the text area so the popup menu can come up.
MouseListener popupListener = new PopupListener(popup);
//ActionListener the choice of the popup, the event will buy the name / description in JMenuItem
ActionListener menuListener = new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (event.getActionCommand().contentEquals("Cur")) {
copy();
} else if (event.getActionCommand().contentEquals("Copy")) {
copy();
} else if (event.getActionCommand().contentEquals("Paste")) {
paste();
} else if (event.getActionCommand().contentEquals("Delete")) {
clear();
} else if (event.getActionCommand().contentEquals("Add")) {
add();
} else if (event.getActionCommand().contentEquals("Save")) {
saveAs();
}
}
private void copy() {
//Copy action
}
private void paste() {
//Paste action
}
private void clear() {
//Clear action
}
private void add() {
//Add action
}
private void saveAs() {
//Save ass action
}
};
//Mouse popup Componunet listener
//Here we define which is the component that will invoke the popup
jLIcon.addMouseListener(popupListener);
} catch (Exception ex) {
//Error Exception
}
}
class PopupListener extends MouseAdapter {
JPopupMenu popup;
PopupListener(JPopupMenu popupMenu) {
popup = popupMenu;
}
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}
private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.show(e.getComponent(),
e.getX(), e.getY());
}
}
}
}
I accept any comment or improvement. We're always learning.
This code allows an t right mouse click event. For So may we popup menu. Or other action we want.
So we can add multiple actions, such as a popup menu.
private void EventMouseReleased(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isRightMouseButton(evt)) {
//CODE
}
}
I accept any comment or improvement. We're always learning.