Class inhertis from JButton, but button is not visible
Hi!
I'm having a class that inherits JButton. The idea was to give the button additional parameters, so it inherits from JButton to have all the attributes from JButton... But the problem is, that the Buttons are only visible when I touch them with the mouse. When I move the window they are invisible again...
Does anybody know why? Thanks for your help!
P.S Sorry for my bad english....
Okay, thanks for that hint!
Here is the class for the gui:
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
public class Temp extends JFrame{
private static final long serialVersionUID = 5945597724189252185L;
private JMenuItem closeItem = null;
private JMenuItem newItem = null;
private JPanel mainPanel = null;
private JLabel startImage = null;
private MineFieldButton[][] mines = null;
public Temp(){
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
addMenu();
this.add(getMainPanel());
this.pack();
private JPanel getMainPanel(){
if (mainPanel == null){
mainPanel = new JPanel();
if (mines == null)
mainPanel.add(getStartImage());
else{
mainPanel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 20;
c.ipadx = 20;
for (int x=0;x<mines.length;x++){
for (int y=0;y<mines[x].length;y++){
c.gridx = x;
c.gridy = y;
mainPanel.add(mines[x][y],c);
return mainPanel;
private JLabel getStartImage(){
if(startImage == null){
startImage = new JLabel();
return startImage;
private void addMenu(){
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menu.add(getNewItem());
menu.add(getCloseItem());
menuBar.add(menu);
this.setJMenuBar(menuBar);
private JMenuItem getNewItem(){
if (newItem == null){
newItem = new JMenuItem("New");
newItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
createMines();
return newItem;
private JMenuItem getCloseItem(){
if (closeItem == null){
closeItem = new JMenuItem("Close");
closeItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(0);
return closeItem;
public void showGUI(){
this.setVisible(true);
private void createMines(){
initMinesGUI();
this.remove(getMainPanel());
mainPanel = null;
this.add(getMainPanel());
this.pack();
private void initMinesGUI(){
mines = new MineFieldButton[10][10];
for (int x=0;x<mines.length;x++){
for (int y=0;y<mines[x].length;y++){
mines[x][y] = new MineFieldButton();
mines[x][y].setBorder(BorderFactory.createRaisedBevelBorder());
mines[x][y].setX(x);
mines[x][y].setY(y);
mines[x][y].setNumber(x*y);
}And here for the class that inherits JButton "MineFieldButton":
import javax.swing.JButton;
public class MineFieldButton extends JButton{
private static final long serialVersionUID = -1020769129018597011L;
private int number = 0;
private int x;
private int y;
public int getNumber() {
return number;
public void setNumber(int number) {
this.number = number;
public int getX() {
return x;
public void setX(int x) {
this.x = x;
public int getY() {
return y;
public void setY(int y) {
this.y = y;
}I hope that you can find my error.... And that this is a SSCCE :-)
Thanks!
Similar Messages
-
Choose from List-CFL button is not visible
Hi Experts,
I am using SAP B1 8.8 PL 05 in ramp up. I have observed that in some of the clients PCs in Sales Order window I am not able to see the Choose from list button / CFL button for selecting Customer Or say Item.
This happens only in some Client PCs, where as in other clients PCs it works fine.
BR
Samir GandhiHi Rashid,
I did that. Now the indicator is displayed, but still I am not able to see the customer / item list.
BR
Samir Gandhi -
I bought an I pad 2 from us but I can not activate the Facetime in UAE(Dubai)as I can not see the country in the I pad's drop list, anyone has an idea as to how to resolve this issue
I'm not that familiar with how FaceTime works. I know how to set It up but I don't use it. I just know that you can't activate in the UAE. I believe that you can activate in any country that permits it's use. Whether you will need a new ID or not, I can't confirm.
You can Google this and get all sorts of articles on workarounds. Apparently if you set up a VPN you can use it in the UAE. Here is one article that I found.
http://talkfree7.blogspot.com/2010/09/how-to-facetime-voip-call-from-uae.html
I Googled "workaround for FaceTime in UAE" to find this. -
I purchased a video from iTunes but it will not sync to my iPod. I get a message stating that the video "was not loaded to the iPod because iyt cannot be played on this iPod." I tried to use the "create an iPod version" but the command is grayed out
I was refering to the "sample rate", normally 44.1 KHz, the iPod might not be able to play tracks with a non-standard rate. Otherwise I'm not sure what the issue might be.
tt2 -
In Mail I have checked Remove copy from server but they do not delete, In Mail when I have checked Remove copy from server but they do not delete.
I have a hotmail accout. When the emails have downloaded and I "Get Account Info" in Messages on server it shows all the messages I have just downloaded if I switch to That have been downloaded to my Mac the display it is blank. Also if I delete the downloaded messages and then get new info. All the messages are downloaded again and the count of new messages increases (this increases every time I Get New Messaages) .See:
*https://support.mozilla.org/kb/ive-lost-my-firefox-sync-account-information -
My Itunes account was hacked and my Apple ID was disabled. I followed the instructions from APPLE to backup and restore from Itunes but that did not work. Any suggestions?? Thanks!!
Are you saying that you contacted Apple support and they instructed you to backup and restore your iPad? Or do you mean that you picked up this information from an online support article? If you spoke to an Apple rep or received these instructions via email, contact them again for further help.
I fail to see how restoring your iPad would enable yoyr Apple ID. -
I recently purchased CS2 premium from Amazon but I do not come with a serial number. How do I go about acquiring a serial number for the premium suite
Huh?
Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
Mylenium -
Where can I find the third party app?
I'm really in trouble that I can't record and check my blood glucose.
Of cause I exported the data from app, but It's not readable for me.
Please reply ASAP and give me other solution.You find third-party apps in the App Store. What app are you looking for? Due to problems, Apple removed the ability to record that information in Health. You can always go back to whatever you used before three weeks Health was released. Why can you not check and record your blood glucose? I would assume you check it using blood samples and a glucose meter which has nothing to do with your phone. You should be able to record it in any number of apps, from Notes to purpose made third-party apps.
-
I bought series 4 of Greys Anatomy from itunes but it will not sync to ipad error messge says cannot be played on ipad . Is it an issue with Itunes/ipad and can I get my money back?
Welcome to the Apple Community.
In iTunes Preferences > store, make sure automatic downloads for music is enabled. -
HT1391 I have purchased a song from itune but it is not listed under my purchased items, why
I have purchased a song from itune but it is not listed under my purchased items, why
By 'purchased items' do you mean the Purchased link under Quick Links in the store ? If you do then do other songs that you've purchased appear there (music can't be re-downloaded in all countries) ?
-
i bought an unlocked iphone 4s from dubai but it does not work with an indian idea sim..help
If you are both on the T-mobile network, the sim card should work. If you did a Erase All Content and Settings, then she should be at the point of activation as a new device...talk to T-mobile and be sure the sim she is using is a valid sim card.
-
When I launch a video from Finder the video is not visible, it's like it's playing on an extended desktop but I can't see the other screen - what is going on?
Hi Dan - I'm not sure I know what you mean by 'kick in Expose', can you please explain?
It's a weird one as it doesn't happen all the time. Could it have anything to do with running Apple TV and the MacBook 'thinking' there is another display (extended desktop) and playing the video there? -
I just get a new iPhone 4s I will like to backup from iCloud but I can not cuz the lattes backup is wiv version 7.1.1
Huevomix wrote:
I just get a new iPhone 4s I will like to backup from iCloud but I can not cuz the lattes backup is wiv version 7.1.1
Update the iPhone 4s to iOS 7.1.1 and then Restore from your iCloud Backup. -
Purchased music videos from iTunes but it will not play, no video or sound
Purchased music videos from iTunes but it will not play, no video or sound. There were several vidoes on the purchase I made and two of the videos will not play the video or sound. I've checked to see if they were waiting for download and nothing is there. Any suggestions.
Is your iTunes account authorized for this computer in iTunes? - to check, open iTunes, and in the top menu bar, select "store", then "authorize this computer". How to Authorize iTunes - http://www.apple.com/support/itunes/authorization/.
-
i have purchased cycloramic aap from itunes but it was not download and 60 INR. debited from account. i have tried two time both time same problame...
what are you doing?
Maybe you are looking for
-
Pages TOC lost when converting to ePub
Being new to Pages, I viewed the online tutorials to get me started. I have managed to create a short book and the formatting of the text seems fine in Pages. However, when I export the file to ePub, and view this in iBooks on the iPad, the Table of
-
IOs7: iPod Touch 5. iMessage and Facetime not working.
I just updated to ios7 and now imsg and facetime aren't working. It asks me for my Apple ID usename and password and then I get a message that says "Could not sign in. Please check your network connection and try again." I am in wifi and internet is
-
How can we configure in MSS to view Employee work schedule?
Hi, How can we configure in MSS to view Employee work schedule? Regards, Poornima
-
I just got the iPod Classic 80GB for Christmas... it was great for the first week or so. As i started to add more music, I noticed that some songs did not get put onto my iPod; this kept happening more and more. I then realized that when my iPod was
-
Family share approval keeps requesting icloud password
I have Family Sharing set to require my approval when my daughter buys something from the store. Today when I try to approve items it keeps asking me to input my icloud password. Sign In To Approve Enter the iCloud Apple ID password for [icloud emai