Solve this if you can!
I have posted this three times now, and I have still not got an answer to the problem. The problem is as follows:
I have a problem with the focus of a JTextField in a JApplet. Here is my code:
class MyPanel extends JPanel {
ImageIcon imageIcon;
Image image;
public MyPanel(Image tiledBackgroundImage) {
setOpaque(false);
setLayout(new BorderLayout());
imageIcon = new ImageIcon(tiledBackgroundImage);
image = imageIcon.getImage();
public void paintComponent(Graphics g) {
for (int x = 0; x < getWidth(); x += image.getWidth(this)) {
for (int y = 0; y < getHeight(); y += image.getHeight(this))
g.drawImage(image, x, y, this);
super.paintComponent(g);
}and in the init() method of my applet I have the following call
setContentPane(new MyPanel(getAppletContext().getImage(new URL(getDocumentBase(), getParameter("backgroundImage")))));However, before I added this code for rendering the background image everything was working well. But after I added it, the JTextFields started to reject focus; when I click on them with the mouse I see a fast blink and then focus is lost again. Why is this so?
I don't know why some people have make theirself exceptionally clear by writing seven question marks... well, if you can solve it with this code I will give you the dollars. Here is the whole relevant code:
import layout.TableLayout;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Vector;
import java.net.URL;
import java.net.MalformedURLException;
class MyPanel extends JPanel {
ImageIcon imageIcon;
Image image;
public MyPanel(Image tiledBackgroundImage) {
setOpaque(false);
setLayout(new BorderLayout());
imageIcon = new ImageIcon(tiledBackgroundImage);
image = imageIcon.getImage();
public void paintComponent(Graphics g) {
setOpaque(false);
for (int x = 0; x < getWidth(); x += image.getWidth(this)) {
for (int y = 0; y < getHeight(); y += image.getHeight(this))
g.drawImage(image, x, y, this);
setOpaque(true);
super.paintComponent(g);
public class AppletGUI extends JApplet {
private Communicator databaseCommunicator;
private JRadioButton localhostRB, otherHostRB;
private ButtonGroup hostBG;
private JTextField hostTF, userNameTF, fieldTypeTF, fieldKeyTF, fieldDefaultTF, fieldExtraTF;
private JCheckBox fieldNullAllowedChB, fieldUnsignedChB, fieldZerofillChB;
private JPasswordField passwordPF;
private JTextArea messagesTA;
private JScrollPane messagesSP, databasesSP, tablesSP, tableDataSP, tableStructureSP;
private JButton loginBtn, newDBBtn, deleteDBBtn, newTableBtn, deleteTableBtn,
newColumnBtn, deleteColumnBtn, modifyColumnBtn, newTupleBtn, deleteTupleBtn, modifyTupleBtn,
disconnectBtn;
private SortedJList databasesL, tablesL, tableDataL, tableFieldNamesL;
//showColumnUI elements
JTextField columnNameTF, columnDefaultTF;
JComboBox columnTypeCB, columnSizeCB, columnDecimalsCB, columnKeyCB, columnReferencesTableCB,
columnReferencesColumnCB;
JCheckBox columnNullAllowedChB, columnZerofillChB, columnUnsignedChB, columnAutoIncrChB;
JButton addFieldBtn, cancelBtn;
String tableName;
//addTableUI elements
private JTextField tableNameTF, fieldNameTF;
private DefaultTableModel fieldsTM;
private JTable columnsT;
private JScrollPane columnsSP;
private JButton addTableBtn;
//addDatabaseUI elements
private JTextField nameTF;
private String host;
public void init() {
try {
getRootPane().setContentPane(new MyPanel(getAppletContext().getImage(new URL(getDocumentBase(),
getParameter("backgroundImage")))));
} catch (MalformedURLException e) {
e.printStackTrace();
host = getParameter("host");
public void paint(Graphics g) {
super.paint(g);
showLoginUI();
private void showLoginUI() {
getContentPane().removeAll();
//--- Create and initialize labels ---//
JLabel loginLbl = new JLabel("Login to the MySQL server");
loginLbl.setFont(new Font("Arial", Font.ITALIC, 12));
JLabel hostLbl = new JLabel("Host address:");
hostLbl.setFont(new Font("Times New Roman", Font.PLAIN, 12));
JLabel usernameLbl = new JLabel("Username:");
usernameLbl.setFont(new Font("Times New Roman", Font.PLAIN, 12));
JLabel passwordLbl = new JLabel("Password:");
passwordLbl.setFont(new Font("Times New Roman", Font.PLAIN, 12));
JLabel messagesLbl = new JLabel("Messages:");
messagesLbl.setFont(new Font("Arial", Font.ITALIC, 12));
//--- Create and initialize text fields and areas ---//
hostTF = new JTextField(15);
hostTF.setEditable(false);
hostTF.setText(host);
hostTF.setOpaque((true));
userNameTF = new JTextField(10);
passwordPF = new JPasswordField(10);
messagesTA = new JTextArea(5, 20);
messagesTA.setLineWrap(true);
messagesTA.setWrapStyleWord(true);
messagesTA.setEnabled(false);
messagesTA.setBackground(hostTF.getBackground());
messagesSP = new JScrollPane(messagesTA);
//--- Create and initialize buttons ---//
localhostRB = new JRadioButton("localhost");
localhostRB.setOpaque(false);
otherHostRB = new JRadioButton();
otherHostRB.setSelected(true);
otherHostRB.setOpaque(false);
localhostRB.setEnabled(false);
hostBG = new ButtonGroup();
hostBG.add(localhostRB);
hostBG.add(otherHostRB);
loginBtn = new JButton("Login");
loginBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (userNameTF.getText().length() == 0 || passwordPF.getPassword().length == 0)
JOptionPane.showMessageDialog(AppletGUI.this, "You must specify both username and password.",
"Compulsory field!", JOptionPane.ERROR_MESSAGE);
else if (otherHostRB.isSelected() && hostTF.getText().length() == 0)
JOptionPane.showMessageDialog(AppletGUI.this, "Specify the host name.",
"Compulsory field!", JOptionPane.ERROR_MESSAGE);
else {
try {
if (localhostRB.isSelected())
databaseCommunicator = new Communicator("mysql", userNameTF.getText(),
String.valueOf(passwordPF.getPassword()));
else
databaseCommunicator = new Communicator("mysql", userNameTF.getText(),
String.valueOf(passwordPF.getPassword()), hostTF.getText());
showMainUI();
} catch (DatabaseException e1) {
e1.printStackTrace();
messagesTA.append(e1.getMessage() + "\n");
/* JButton exitBtn = new JButton("Exit");
exitBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
final double margin = 10;
final double pref = TableLayout.PREFERRED;
final double textareaHeight = 100;
final double size[][] = {
{ margin, pref, pref, pref, margin }, //Widths
{ margin, pref, pref, pref, pref, pref,
pref, pref, pref, pref, pref,
textareaHeight, margin } //Heights
getContentPane().setLayout(new TableLayout(size));
//--- Layout column 1 ---//
// getContentPane().add(welcomeLbl, "1, 1, 3, 1");
getContentPane().add(Box.createVerticalStrut(10), "1, 2");
getContentPane().add(loginLbl, "1, 3, 2, 3");
getContentPane().add(Box.createVerticalStrut(10), "1, 4");
getContentPane().add(hostLbl, "1, 5");
getContentPane().add(localhostRB, "1, 6");
JPanel panel = new JPanel();
panel.add(otherHostRB);
panel.add(hostTF);
panel.setOpaque(true);
getContentPane().add(panel, "2, 6");
getContentPane().add(Box.createVerticalStrut(10), "1, 7");
getContentPane().add(usernameLbl, "1, 8");
getContentPane().add(passwordLbl, "1, 9");
getContentPane().add(Box.createVerticalStrut(10), "1, 10");
getContentPane().add(messagesLbl, "1, 11, l, t");
//--- Layout column 2 ---//
getContentPane().add(userNameTF, "2, 8");
getContentPane().add(passwordPF, "2, 9");
getContentPane().add(messagesSP, "2, 11");
//--- Layout column 3 ---//
getContentPane().add(loginBtn, "3, 8, 3, 9");
// getContentPane().add(exitBtn, "3, 11, l, b");
// fitSizeAndCenter(this);
// setVisible(true);
getContentPane().validate();
getContentPane().repaint();
}
Similar Messages
-
how to solve this problem? '' can not activate cellular data network failure'' authenticating PDP from already thank you
What does this have to do with using an iPhone in an enterprise environment?
What carrier are you using and where did you get the phone? -
Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks
Sorry to say it, but I think you can see from Bob's response that there's no way to solve this rapidly.
Did you take an image of your Mountain Lion install before upgrading to Yosemite? Roll back to that. If you're not in the habit of taking a snapshot of your system before performing operating system upgrades - get in that habit. If you are dependent on anything at all on hour computer, having a reliable backup method in place is essential. If you don't have a Time Capsule, or some other way to run Time Machine onto a disk that's not in your computer, go set that up yesterday.
If you can't just remove Yosemite and roll back to Mountain Lion for whatever reason, you can partition your drive so that you can install both Yosemite and Mountain Lion on the same drive, and then boot into Mountain Lion when you need to work in CS5. Or you can take your Mountain Lion disc (I assume you have one, no?) and then use it to create a virtual machine in something like VirtualBox to run Mountain Lion from inside Yosemite. -
I have recently purchased MacBook Pro with Mac OSX 10.7.3 Lion and I would like to install Final Cut Pro 6 Studio2, and it came up with this error: 'you can't open application FinalCutProStudio.mpkg because PowerPc apps are no longer supported......Is there a way to run FCP6 on lion withoput this error? Any help would be appreciated.....
Hi Shane,
Just one more quesiton re: this topic, I am looking to get rosetta but do not have Leopard or Snow Leopard...
I read that it is not on Snow Leopard only on Leopard....so do I need to get only Leopard? Can u advise?
Alternatively I do have Mac OS X Tiger so is it on this and can I install it from here?
Please excuse my lack of knowledge here, just trying to get my FCP 6 up and running asap....
Best Rgds. -
How to i get rid of the redirect notice it shows up on my safari whenever i try to go to a different page
it says "the previous page is sending you to: LINK
if you do not want to visit this page, you can return to the previous page"Yeah, this seems to be something to do with Google, not your iPhone. A search on that error found this page:
http://www.google.com/support/forum/p/Web%20Search/thread?tid=56a3c4b71b3dc1d9&h l=en
which shows people using lots of browsers on different platforms suffering from it. No definitive solutions though. -
Hi, I have the following problem with Time Capsule: La imagen del disco de copia de seguridad “/Volumes/Data/MacBook Pro de Carlos.sparsebundle” ya está en uso. Please your comments to solve this problem, i can't made a backup. Thanks.
Try Here > http://pondini.org/TM/Time_Capsule.html
Perhaps P 2 > Time Machine could not complete . . . sparsebundle could not be accessed. (Error 109). -
iPhoto has somehow uninstalled itself, or I've done something wrong. If I try to open iPhoto, it gives me this message: "You can't open the application "iPhoto" because it may be damaged or incomplete". I have an iMac OS X. How do I reinstall iPhoto please?
What is your iPhoto version and how did you install it originally?
If it came with a new mac and Lion or Mt. Lion installed, you can delete iPhoto from the Applications folder (don't empty the Trash) and download it again from the "Purchased" tab of the App Store.
If you have bought the iLife CD, reinstall iPhoto from the installation media, after deleting it from the Application folder.
Or if your Mac came with an older MacOS X, but iLIfe preinstalled, use the system Install CDs, see Terence Devlin's post here: Re: My iPhoto isn't working. Error message says "you can't open the app "iPhoto" because it may be damaged or incomplete.
Regards
Léonie
P.S: This may not only be a problem of a broken iPhoto. What did you do, directly before this happened? Did you run a program, that will clean the Mac to save space, like "Clean My Mac" or "Mac Keeper"? These little helpers can be risky and overdo it and remove too much. Then it might be safer to reinstall your system, because other essential files might be missing now. -
I attempted to open iPhoto and got this message: you can't open the application because it may be damaged or incomplete. Now the iPhoto icon has a little line through it.
Nice. Shall I say goodbye to my treasured iPhoto library? What happened?
I did just upgrade my iPhone to OS 5. Could that be related somehow?
Help!1. Back up your iPhoto Library - you should always have a back up anyway.
Most Simple Back Up
Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
Slightly more complex:
Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically. Examples of such apps: Chronosync or DejaVu . But are many others. Search on MacUpdate
2. Reinstall
To re-install iPhoto
1. Put the iPhoto.app in the trash (Drag it from your Applications Folder to the trash)
2a: On 10.5: Go to HD/Library/Receipts and remove any pkg file there with iPhoto in the name.
2b: On 10.6: Those receipts may be found as follows: In the Finder use the Go menu and select Go To Folder. In the resulting window type
/var/db/receipts/
2c: on 10.7 they're at
/private/var/db/receipts
A Finder Window will open at that location and you can remove the iPhoto pkg files.
3. Re-install.
If you purchased an iLife Disk, then iPhoto is on it.
If iPhoto was installed on your Mac when you go it then it’s on the System Restore disks that came with your Mac. Insert the first one and opt to ‘Install Bundled Applications Only.
If you purchased it on the App Store you can find it in your Purchases List. -
I just got a new MacbookPro using Mavericks OS. When I tried to load Filemaker Pro I got this message: You can't open the application Filemaker Pro.app because Power PC applications are no longer supported. This is a disaster.
GiraffeHero wrote:
I just got a new MacbookPro using Mavericks OS. When I tried to load Filemaker Pro I got this message: You can't open the application Filemaker Pro.app because Power PC applications are no longer supported. This is a disaster.
Ralph Landry1 wrote:
The only viable solution is to upgrade to the latest versions of the PPC legacy software that will run under Mavericks.
Except for the other viable solution:
If you are unable or unwilling to upgrade to a version of Filemaker that runs natively under Mavercks, you can run your existing version of Filemaker by installing Snow Leopard Server into Parallels:
[Click on image to enlarge]
Installing Snow Leopard Server into Parallels for DUMMIES:
http://forums.macrumors.com/showpost.php?p=17285039&postcount=564 -
As of today, I can no longer or Excel. I get this message: You can’t open the application “Microsoft Excel” because PowerPC applications are no longer supported. Is there a fix for this and why ha this all of the sudden happened. I've rebooted twice and that hasn't worked.
The application may be corrupt. Un-install and re-install Office.
Office 2011 Removal
Office 2011 Removal (2) -
iCloud was working fine, suddenly when I try to sync I get this message "you can't use icloud when multiple versions of outlook are installed". I only have one version of outlook installed. Any suggestions?
Message was edited by: leroydouglas
better yet, try this solution:
https://discussions.apple.com/message/12351186#12351186 -
I am transferring my mother's address book and mail etc to my computer from an external hard drive enclosure and am not able to open it due to this message: You can't use this version of the application Address Book with this version of Mac OS X. HELP! Is there a way to open her older applications and get the info out?
her email is in user>Library>Mail folder. Hopefully you've created another user on your Mac for your mother so she would have her own user Library.
-
I have installed adobe digital on my computer without an adobe ID. I want to change as I not have an ID but I get this notice: "You can only authorize this computer with an adobe ID that hasn't been previously used to authorize any other computer or mobile device. What do I have to do?
Perhaps someone in the Adobe Digital Editions forum? (Adobe Reader has no connection, we don't have much of a clue). Adobe Digital Editions
-
HI,
I got this problem : when i want to download the new version of iPhoto, i get this message : You can not update this software since you do not have the main version. What should i do ?
IPhoto was already on my MacBook Pro when i bought it.
Thank you for your help
ThierryWelcome to Apple Support Communities
Open App Store > Purchases, and see if iPhoto app is listed. If not, unhide it > http://support.apple.com/kb/HT4928 Apart from that, check that iPhoto is in Applications folder. If not, put it in this folder.
If nothing works, remove iPhoto, open App Store > Purchases, and install iPhoto free of charge -
Dear I am using iphone 4s now its connected with pc to create contact group. I have 750 contacts in phone but pc showing only 36. How can i solve this? How can I see all contacts in pc?
HI,
It may pay to bookmark this page.
http://www.apple.com/support/systemstatus/
8:40 PM Wednesday; April 10, 2013
iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
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
"Limit the Logs to the Bits above Binary Images." No, Seriously
Maybe you are looking for
-
Last night I attempted to purchase an app from the App Store on my iPhone 5s The previous day I had purchased an app with no issues, and this time was told that my payment method was invalid. When I clicked 'Continue' to fix my information, everythin
-
I cannot get my iPad 2 (brand new) to work with my MacBook pro. It says I need iTunes 7.0, but when I go to update iTunes on my MAC, it says I have teh latest version 10.6.3. I have Mac OS 10.5.8 on my MacBook Pro. Any help would be appreciated.
-
When syncing a new photo album, photos from old albums appear in the new albums.
When I try to sync a new set of albums into my iPad 2 using iTunes, photos from previous albums randomly appear in the new album! This occurs even when I delete the photo cache from the folder in question and have iTunes remake the picture cache. I a
-
Error determining address for employee when replicating
Hi, We are in SRM 5.0, classic scenario. We are using HR replication . I replicate the Org structure and the user from an HR system via ALE. Apparently all works fine (in PPOMA_BBP I see the Position, the CP, the BP, and the user links US) (similar t
-
Top component in JLayeredPane not visible but there
I'm using a JLayeredPane to overlay a component in a corner on top of another. When the top component is a JLabel, everything works fine. When I switch it to be the (third party) component (JComponent) I want to use, the component is invisible (not b