Can't get clipboard to work.
I can't seem to get the clipboard to work on the JTextArea. Can anyone see what I am doing wrong:
import javax.swing.table.*;
import javax.swing.event.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Dimension;
import java.awt.datatransfer.*;
public class SQL
extends JFrame
implements ActionListener, ClipboardOwner {
JPanel mainPanel;
JButton loadButton, exitButton;
JTextArea SQLField;
SQLDataModel dt = new SQLDataModel();
JTable tableView;
String SQLStatement = new String("");
Clipboard clipboard;
public SQL() {
super("Dynamic SQL");
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}});
// Create the table
JTable tableView = new JTable(dt);
tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JScrollPane scrollpane = new JScrollPane(tableView);
scrollpane.setPreferredSize(new Dimension(750, 400));
mainPanel = new JPanel();
getContentPane().add(mainPanel);
mainPanel.setLayout(new BorderLayout());
mainPanel.add(scrollpane, BorderLayout.CENTER);
// Create the query panel
JPanel top = new JPanel();
top.setLayout(new FlowLayout());
mainPanel.add(top, BorderLayout.NORTH);
SQLField = new JTextArea("", 5, 30);
top.add(SQLField);
// Create the button panel
JPanel button = new JPanel();
button.setLayout(new FlowLayout());
loadButton = new JButton("Load");
loadButton.addActionListener(this);
button.add(loadButton);
exitButton = new JButton("Exit");
exitButton.addActionListener(this);
button.add(exitButton);
// Create the bottom panel
JPanel bottom = new JPanel();
bottom.setLayout(new BorderLayout());
bottom.add(button, BorderLayout.SOUTH);
mainPanel.add(bottom, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent event) {
String cmd = event.getActionCommand();
if(cmd == "Exit")
System.exit(0);
if(cmd == "Load") {
String SQLStatement = new String(SQLField.getText());
tableView = new JTable(dt);
dt.executeQuery(SQLStatement);
dt.fireTableStructureChanged();
public void lostOwnership(Clipboard clip, Transferable transferable){
System.out.println("Lost ownership");
public static void main(String[] args) {
SQL frame = new SQL();
frame.pack();
frame.setVisible(true);
Look at this code, it does nothing with it yet if you right click in either of the text fields you can cut and paste???
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
public class ClipboardTest extends Frame implements ClipboardOwner{
private Clipboard clipboard;
private TextField copyFrom;
private TextArea copyTo;
private Button copy, paste;
ClipboardTest(){
setLayout( new FlowLayout());
clipboard = Toolkit.getDefaultToolkit ().getSystemClipboard();
copyFrom = new TextField(20);
copyTo = new TextArea(3, 20);
copy = new Button("Copy");
paste = new Button("Paste");
add(copyFrom); add(copyTo); add(copy); add(paste);
addWindowListener( new WindowAdapter(){
public void windowClosing(WindowEvent we){
dispose();
System.exit(0);
setSize(200,200);
show();
public void lostOwnership(Clipboard clip, Transferable transferable){
System.out.println("Lost ownership");
public static void main (String args[]) {
ClipboardTest clipBoardTest = new ClipboardTest();
Similar Messages
-
Can't get Mail to work - I get the spinning wheel and Mail freezes. I have to Force Quit Mail . How do I fix this problem?
Please follow these directions to delete the Mail "sandbox" folder.
Back up all data.
Triple-click the line below on this page to select it:
~/Library/Containers/com.apple.mail
Right-click or control-click the highlighted line and select
Services ▹ Reveal
from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
Log out and log back in. Launch Mail and test. If the problem is resolved, you may have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
*If you don't see the contextual menu item, copy the selected text to the Clipboard (command-C). In the Finder, select
Go ▹ Go to Folder...
from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return. -
Have entrourage and want to use Mail. Can't get it to work.
I had a macbook and purchased the Microsoft office for Mac which included Entrourage.
I have now purchased a new macbook Pro and want to begin to use Mail rather than Entrourage.
I have Entrourage on my new computer but i can't get it to transfer my information to the the Mail program
I am on Charter.net at my office and sbcglobal.net at home.
How can i get this to work. I can receive on Mail, but i can't send.check your outgoing port settings and make sure it's using a specific port and not the default port, also you might want to check to see if it is using SSL, TLS or any other encryption. Verify the setting from your old machine setup.
-
got my password wrong twice and my mini is disable. I connected to iTunes, but can't get it to work. Can some one guide my through?
If it's showing the red disabled screen due to incorrect passcodes then you may need to put the iPad into recovery mode : http://support.apple.com/kb/ht1808 - you should then be able to reset the iPad via your computer's iTunes and restore/resync your content to it
-
HT1151 i have a new apple external dvd drive, and i can't get it to work with my iMac?
I have a new apple dvd drive, I was told it will work with my imac, but when i plug it in ...nothing... iv been for update... still nothing. How can i get it to work???
If it is this drive, note that it is for MBA's and Mini's only:
http://store.apple.com/us/product/MC684ZM/A
Ciao. -
Is there a way to reset my messages account, I can't get iMessage to work on IPad nor Mac osx. Help please this is really frustrating.
Hi,
Is there an iPhone involved ?
If not, what happens if you remove the Apple ID on the iPad and then set it in Airplane Mode (allow a couple of minutes at this point) followed by re-adding the Apple ID ?
What, if any error messages are appearing on the Mac when you try to launch the App or Login to the iMessages server ?
Is the Apple ID linked to an iCloud account ?
In Messages 7 (Mountain Lion) this did not seem to be important but it seems it is in Mavericks/Messages 8
9:14 pm Friday; April 11, 2014
iMac 2.5Ghz i5 2011 (Mavericks 10.9)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad -
I bought an IR receiver and an Apple Remote, and I can't get it to work. What am I doing wrong? The receiver is a Lenovo eHome OVU430006/01 USB IR Receiver.
Hello,
You would need to pair the Apple Remote with the receiver. So I would use the generic Mac/PC receiver and follow these instructions:
http://support.apple.com/kb/HT1619
If that doesn't work then check in System Profiler to see if the IR receiver has been recognized by the PowerBook's hardware. You may require the install of drivers for this device to be recognized.
Best of luck -
I have a go daddy email account and I can't get it to work on my iPad
I have a go daddy email account and I can't get it to work on my iPad
Try turning the email account off and then turn it on again. Settings>Mail, Contacts, Calendars>select your gmail account>Off. Go to the mail app and then come back to the account in the settings and turn it on again.
If you can't find any other way for the iPad to accept the password, delete the email account and then add it back onto the iPad. -
I have a Mac Mini and I can't get it to work with my Ricoh Aficio MP 161. Any ideas?
I have a Mac Mini and I can't get it to work with my Ricoh Aficio MP 161. Any ideas?
The latest Apple driver support begins with the MP 171.
Here is Ricoh's official driver download page specifically for the Afico MP 161. Note that new drivers for this device were released on Aug 2, and include Lion and Mountain Lion.
Hopefully, this will solve your device issues. -
Iphone 5 went black. Tried pushing on/off and circle at the same time. Worked yesterday and then did it again today. Can't get it to work.
You need to hold those button longer until you see the apple logo, then release, then wait for the phone to boot back up.
-
I just bought a new computer and had files transferred along with itunes to the new computer. I can't get it to work. It doesn't recognize the extensions for itunes. I also tried downloading Quicktime and couldn't get it to download.
iOS: Device not recognized in iTunes for Windows
I would start with:
Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7 -
I bought a DATAPILOT to transfer pictures to my macbook and can't get it to work. Any suggestions please?
Best if you try and explain what you are trying to acheive.
Iphoto is a different paradigm than you're used to. I don't understand why you are trying to transfer your edited photos back to an external disk.
There are tutorials here
http://www.apple.com/findouthow/photos/
Regards
TD -
I have signed up for adobe conversion to microsoft word and i can't get it to work - can you help me
I have signed up for adobe conversion to microsoft word and I can not get it to work - can you help me?
Hi Mike,
I've checked your account. I see that you just purchased the subscription this morning. The order is still pending processing, which is why you haven't yet been able to log in an use your subscription. It can take 24-48 hours for a subscription to process fully. Once it does, you'll be able to log in and convert files.
I apologize for the inconvenience.
Best,
Sara -
Trying to connect 2010 Mac mini to alba hd tv but can't get it to work, any theories?
Trying to connect 2010 Mac mini to alba hd tv but can't get it to work, any theories?
Welcome to the Apple Community.
The iPad 1 is only able to do basic AirPlay, many providers of programming have blocked their apps from working with AirPlay. -
I just bought Quick time Pro and I can't get it to install. It shows a yellow box in my application folder, but I can't get it to work. Help!
you launch QT then go to its REGISTRATION
Maybe you are looking for
-
the adobe application manager, says the PS is up to date, yet it's not on my computer.
-
Itunes opens in another user account and I can't open in mine
We have a computer with 6 user accounts on it. When ever you open itunes in one account it opens in all of them even when they are not logged in. The admin. accounts wins and he gets itunes so all of the other accounts get frozen out. I have to fi
-
Hi All, Good afternoon. I have one requirement to work on to work on FILE->XI---->RFC(synch) scenario using BPM. I am new into BPM. Any body have the step-by-step documentaion, please send me ASAP. I am very thankful to you in advance. Thanks & Regar
-
What's the best way to keep two computers synchronized?
I just got Lr4, which I use in addition to CS5.5 Design Premium, and I want to use Lr as the primary raw file manager and editor. I keep my work and home computers synchronized via a 2TB external drive that fits in my pocket, and SmartSync Pro softwa
-
TS1424 error 4002/ what is this
It says there is an error connecting to the I tunes store the error number is 4002