Now its not recreating a window
In my Jdesktop i have one internatframe and when I press evaluate it should display a new window or frame, why is this not working
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
class GUI
private static JTextField field1;
private static JLabel statusLabel; // Label for status/result info
private static JLabel outputinfix;
private static JLabel minimumValue;
private static JLabel outputpostfix;
private static JLabel outputsolver;
private static String result="";
private static JInternalFrame fr2;
private static JDesktopPane desktop;
private static JFrame f;
public static void main(String[] args)
JFrame f = new JFrame("");
ActionHandler action = new ActionHandler();
/*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
screenSize.width -=42;
screenSize.height -= 42;*/
f.setSize(1024,768);
f.setLocation(20,20);
f.setVisible(true);
desktop = new JDesktopPane();
desktop.setPreferredSize(new Dimension(1024, 768));
desktop.setBackground(new Color(148,102,75));
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
f.setContentPane(desktop);
final JInternalFrame fr = new JInternalFrame("infix", false, true, true, true);
fr.setSize(203, 126);
fr.setLocation(50, 50);
fr.setVisible(true);
fr.setOpaque(false);
fr.setBackground(new Color(100,0,255,140));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
//panel.setLayout(new BorderLayout(0,0));
panel.setSize(203,126);
panel.setBackground(new Color(0,0,255,140));
panel.setOpaque(false);
JTextField field1 = new JTextField("",60);
field1.setPreferredSize(new Dimension(200, 21));
panel.add(field1,BorderLayout.NORTH);
JButton evaluate = new JButton("Evaluate");
evaluate.addActionListener(action);
evaluate.setPreferredSize(new Dimension(101,25));
panel.add(evaluate,BorderLayout.CENTER);
JButton clear = new JButton("Clear");
clear.addActionListener(action);
clear.setPreferredSize(new Dimension(101,25));
panel.add(clear,BorderLayout.EAST);
JLabel label = new JLabel("");
label.setPreferredSize(new Dimension(34,50));
panel.add(label,BorderLayout.SOUTH);
fr.add(panel);
desktop.add(fr);
JInternalFrame fr2 = new JInternalFrame("test", true, true, true,false);
fr2.setSize(230, 300);
fr2.setLocation(50, 50);
fr2.setVisible(true);
fr2.setOpaque(false);
fr2.setBackground(new Color(0,0,255,140));
JPanel panel2 = new JPanel();
panel2.setLayout(new BorderLayout(0, 0));
fr2.add(panel2);
desktop.add(fr2);*/
f.add(desktop);
private static class ActionHandler implements ActionListener
public void actionPerformed(ActionEvent event)
if(event.getActionCommand().equals("Evaluate"))
Infixtopost theTrans = new Infixtopost(field1.getText());
result= theTrans.Trans();
outputpostfix.setText(result);
outputinfix.setText(field1.getText());
JInternalFrame fr2 = new JInternalFrame("test", true, true, true,false);
fr2.setSize(230, 300);
fr2.setLocation(50, 50);
fr2.setVisible(true);
fr2.setOpaque(false);
fr2.setBackground(new Color(0,0,255,140));
JPanel panel2 = new JPanel();
panel2.setLayout(new BorderLayout(0, 0));
fr2.add(panel2);
desktop.add(fr2);
f.add(desktop);
else if(event.getActionCommand().equals("Clear"))
System.out.println("this is a test2");
}
when I try that I get this
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
here is so new code
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
class GUI
private static JTextField field1;
private static JLabel statusLabel; // Label for status/result info
private static JLabel outputinfix;
private static JLabel minimumValue;
private static JLabel outputpostfix;
private static JLabel outputsolver;
private static String result="";
private static JInternalFrame fr2;
private static JDesktopPane desktop;
private static JFrame f;
public static void main(String[] args)
JFrame f = new JFrame("");
ActionHandler action = new ActionHandler();
/*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
screenSize.width -=42;
screenSize.height -= 42;*/
f.setSize(1024,768);
f.setLocation(20,20);
f.setVisible(true);
desktop = new JDesktopPane();
desktop.setPreferredSize(new Dimension(1024, 768));
int backcolor = (int)(Math.random()*100);
desktop.setBackground(new Color(backcolor,backcolor,backcolor+78));
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
f.setContentPane(desktop);
final JInternalFrame fr = new JInternalFrame("infix", true, false, true, true);
fr.setSize(203, 126);
fr.setLocation(50, 50);
fr.setVisible(true);
fr.setOpaque(false);
fr.setBackground(new Color(100,0,255,140));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
//panel.setLayout(new BorderLayout(0,0));
panel.setSize(203,126);
panel.setBackground(new Color(0,0,255,140));
panel.setOpaque(false);
JTextField field1 = new JTextField("",60);
field1.setPreferredSize(new Dimension(200, 21));
panel.add(field1,BorderLayout.NORTH);
JButton evaluate = new JButton("Evaluate");
evaluate.addActionListener(action);
evaluate.setPreferredSize(new Dimension(101,25));
panel.add(evaluate,BorderLayout.CENTER);
JButton clear = new JButton("Clear");
clear.addActionListener(action);
clear.setPreferredSize(new Dimension(101,25));
panel.add(clear,BorderLayout.EAST);
JLabel label = new JLabel("");
label.setPreferredSize(new Dimension(34,50));
panel.add(label,BorderLayout.SOUTH);
fr.add(panel);
desktop.add(fr);
f.add(desktop);
private static class ActionHandler implements ActionListener
public void actionPerformed(ActionEvent event)
if(event.getActionCommand().equals("Evaluate"))
// Infixtopost theTrans = new Infixtopost(field1.getText());
//result= theTrans.Trans();
//outputpostfix.setText(result);
//outputinfix.setText(field1.getText());
result = field1.getText();
System.out.println(result);
int r = (int)(Math.random()*300);
int g = (int)(Math.random()*300);
int b = (int)(Math.random()*300);
int p = (int)(Math.random()*700);
int p2 =(int)(Math.random()*700);
JInternalFrame fr2 = new JInternalFrame("test", true, true, true,true);
fr2.setSize(203, 126);
fr2.setLocation(p ,p2);
fr2.setVisible(true);
fr2.setOpaque(false);
fr2.setBackground(new Color(r,g,b,140));
JPanel panel2 = new JPanel();
panel2.setLayout(new BorderLayout(0, 0));
panel2.setSize(203,126);
panel2.setBackground(new Color(r,g,b,140));
panel2.setOpaque(false);
fr2.add(panel2);
desktop.add(fr2);
f.add(desktop);
else if(event.getActionCommand().equals("Clear"))
fr2.invalidate();
System.out.println("this is a test2");
now if I comment out the result=field.getText(); then I can recreate windows,
Similar Messages
-
! just got a new docking system so i plugged it in to my computer because it wasnt the wall charge type, so I put in my ipod, then straight away my screen went white and now its not doing anything! i press the home and lock button nothing happens... then i plug it in my computer it doesnt come up in itunes or even the copmuter. please help i can not live with out my ipod!
Your post is abit confusing, especially on getting those weird messages and emails,( assumed in your Windows machine.)
Most likely you have Restored the iPod using the new Macbook pro, using the same name as that in your Windows machine, hence the duplicate name warning, as it is trying to sync Automatically.
If you are syncing your iPod to both the Mac and Windows, you must set it to Manually Manage Music, in the first machine that you setup iTunes with the iPod. Read thsi Apple Support Article
In iTunes, Preference, tick on Prevent devices syncing automatically
Hopefully your music are still in both your iTunes library,
Connect the iPod to the Mac
Restore it (just to fix any filesystem corruption by the Windows end)
Set it to Manually Manage Music
Sync your selected songs in your library.
Whern sync complete, Eject it
Connect it to your Windows PC.
Select the song in the library
Sync it.
It should work if your ipod Hardisk is not giving any problem.
Good luck! -
My 4s wa showing update to iso7 so I updated and it kept failing now its not showing an update at all and saying my iPhone 4S is up todate on USO 6.1.3 help???
Now it's not showing any update on my phone Iv turne it off and bk on again but still saying software is up to date on 6.1.3
-
i had my ihone unlocked bt i forgot to sync it to itune before i went on Holiday. now its not working on any of the pc's here what can i do i stil have 3 wks to go!! plz help
I think you will need to restore to the itunes computer you normally sync to.
So you'll have to wait until you come back from your trip. -
my phone suddly switched off and now its not switching on can any one help me when it swithch off my phone battery was full.
Which apps do you open acouse iphone switched off? You can try to reset iPhone.
-
My iPod touch 5th generation isn't working. I plugged it in last night to charge and now its not turning on or responding to anything. It used to do this thing where it would freeze when it was 100% charged and plugged in and I was using it. I'd just unplug it, restart it (home button and top button) and then it would be fine. That had happened like 5 hours prior to me plugging it in again and then it going totally blank.
Try:
- iOS: Not responding or does not turn on
- Also try DFU mode after try recovery mode
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
- If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
- Try another cable
- Try on another computer
- If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
Apple Retail Store - Genius Bar -
I'm using Windows Illustrator CS4, and i cant find the artboard menu pallate. Its not showing under Window Dropdown menu either. How can i locate it or toggle it to turn on again?
I'm not sure what artboard view is, sorting and naming artboards is not available in CS4 either, sorting however is possible via script workaround,
Introducing: re Arrange Artboards v2 Script -
I have downloaded OS X Mountain Lion from the App Store. It took two hours to download but now its not running and I have no idea how to make it run!
Download was complete and I accepted everything and restarted computer but its still running 10.7.5
Any idea how to get OS X Mountain Lion to run?What you donwloaded was the OS installer. You still have to do the installation.
To get started, double click on the download, then double click again and follow instructions. -
I'm having problems with Siri on my iPhone 6. It worked briefly yesterday and now its not doing anything. I have turned phone off and on and made sure everything is on in settings. Please help!
Do you have an active data connection (wifi or cellular)? Have you tried resetting the phone by pressing and holding the Home and power buttons until the apple appears (this is different than just turning it off and back on).
-
i have not used ipad from last 1 year and now its not starting any suggestion how to start,
Using the Supplied iPad charger, Connect it to the mains for at least 60 minutes...
Then try to turn it on. -
Hi I purchased iphone5 in uk..Now am in India before coming I unlocked my iphone using my mail id.but now its not activating they telling now this mail id is not used to unlock this iphone.what can i do now?please anyone tel me the answers
Only the Carrier it is Locked to can Unlock it.
Contact the Carrier. -
my ipad mini and iphone 4s are not connecting over bluetooth. iphone cannot locate ipad mini or says it is not supported. It used to work perfectly but now its not working. please help.
Hi
Thanks for the support but I had already tried this . Again did it as you advised. Still not able to connect the ipad mini with Bluetooth.
Could it be that some app is causing issue. I can connect my car and computer over Bluetooth but not ipad mini.
On the other had ipad is connecting to other iPhone but only not mine.
Still showing ipad not supported message. And also shows not paired.
Please help. -
hi. i had erased iphone. now its not showing in itunes. help how restore?.
thanks feffo87.
but i hav used ERASE ALL CONTENT AND SETTINGS to erase, but my iphone 4s is not reading on itunes.
how to restore new ios now. -
I have some problem .i update my iphone3gs software .software downloaded now its not working .warning select network connect to itunes ..please help me
please help me ?
-
I updated my iphone 3gs now its not setting up, not picking the sim
i updated my iphone 3gs now its not setting up, not picking the sim.i am in pakistan
if it was jailbroken to remove a sim lock then updating the ios version will relock it to the carrier it was originally locked to
Maybe you are looking for
-
How to print the text in points wise in sap script
hi friends, how to print the text in points wise in sap script. ex: if suppose paragraph consists of 15 lines. then according to one sentence or one fullstop (.) it should give point 1. like that... 1. hai how ru. 2. what r u doing. 3.where r u. lik
-
MAPToolkit 9.1 Installation on Windows 2008 R2 Std SP1 64-bit fails
Hi, I tried an installation of the MAPToolkit V9.1 on Windows 2008 R2 SP1 with an SQL Server 2012 MAPS instance installed, but it fails with: Applying execute package: MAPSetup_x64.msi, action: Install, path: C:\ProgramData\Package Cache\{D1E2ED68-9
-
What's wrong with this save method
It won't let me add any new records to my database. Please help String sql = "insert into Sold_Vehicles(Serial_Number, Owner_Name, Make, Address, Model, Phone_Number, Year, Drivers_License_Number, Kilometers, Date_Purchased, Transmission, Warran
-
Hi all, I have a requirement where I need to show the Unbilled amount of this week as well as last 20 weeks based on region. Let say I am on fiscal week 20. Now if create a report based on region and Unbilled amount I will get $ 20 for europe. Now if
-
Folio Builder Panel Sign in failed. Please try again.
I am not able to sign in to Folio Builder Panel in Indesign CS5.5 Anyone facing the same issue now?