ShutDown from JButton

When i use this from NetBeans it's work but when i use outside of NetBenas don't Code of the ShutDown Class is:
import java.io.IOException;
public class ShutDown {
public static void shutdown() throws RuntimeException, IOException {
String shutdownCommand;
String operatingSystem = System.getProperty("os.name");
if (operatingSystem.startsWith("Lin") || operatingSystem.startsWith("Mac")) {
shutdownCommand = "shutdown -h now";
else if (operatingSystem.startsWith("Win")) {
shutdownCommand = "shutdown.exe -s -t 0";
else {
throw new RuntimeException("Unsupported operating system.");
Runtime.getRuntime().exec(shutdownCommand);
System.exit(0);
Code of the ShutDown Button is:
private void ShutDownBtnActionPerformed(java.awt.event.ActionEvent evt)
try {
ShutDown.shutdown();
} catch (RuntimeException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}

Hi,
What error do you get?
How are you running the application, are you using a jar file, or from command line?

Similar Messages

  • IMac will only restart or shutdown from power button.

    My iMac will only restart or shutdown from the power button, it also will not logoff users. It starts ok, but only after a hard reboot?? I have repaired permisions and no change. I have a clone I can restore from but any ideas whats up here?
    The only things that I know I have altered are deleting files saved during migration from Panther (months ago)and running Unbuntu Live CD.
    iMac G4 15 Mac OS X (10.4.7) 728ram

    Are you booting into Ubuntu Linux? Most of us here wouldn't now anything to do with it. If the problem is occurring when booted into Mac OS X, it may be a sign of data corruption in the power management and user settings. Some corruption is easy to repair such as fixing the directory (which I'd only do after a clone). Here's how according to my FAQ:
    http://www.macmaps.com/directoryfaq.html
    And I assume the issue is with your iMac G4.

  • 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!

  • Scripting question: Is there a difference between shutdown from within the VM and using the WMIService InitiateShutdown

    Hi,
    Are there any problems with shutting down a virtual machine using a script?  (example of shutdown script here). 
    In this case, I want to start VM's in a particular sequence and timing, and then reverse the sequence and timing for shutdown.  The built-in settings of hyper-V haven't been adequate.
    Is the command "ShutdownList.ItemIndex(0).InitiateShutdown(True,"script
    shutdown")" the same thing as initiating a GUI activated shutdown process?
    If not, does commanding a shutdown from the host using a script cause
    any system problems inside the VM?  If so, are there other or better ways to accomplish this?
    Thanks.
    Best Regards,
    Alan

    Hi Alan,
    I would like to check if you need further assistance .
    Best Regards
    Elton Ji
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • [SOLVED] I cannot shutdown from Xfce

    I use arch 64 bit, xfce 4.4.1 and kdm. After update today I can no longer shutdown from xfce - I can only log out to kdm, and then shutdown.
    I am in group 'power' and I have /opt/xfce4/libexec/xfsm-shutdown-helper in sudoers, but that file (xfsm-shutdown-helper) seem to no longer exist in that place or anywhere else in my hdd. What should I do?
    Last edited by senjin (2007-04-13 05:05:55)

    baze wrote:
    senjin wrote:
    baze wrote:shutdown via hal is preferred in xfce. if that does not work, sudo is tried, but it is only a fallback.
    to enable shutdown via hal, just add your user to the power group and make sure hal is running. easy as that.
    How should I start hal? Should I add it to deamons on /etc/rc.conf?
    yes
    It works. Thanks!

  • Startup and shutdown from command line with version 9i

    Hi, i'm an Oracle newbie. I heard it's possible to startup and shutdown an oracle (instance? or database? which one is it) from the command line.
    A little background on what it is that I want to do:
    I'm looking to backup a database by copying the files that make up the database to a location from where they will be commited to tape media. To do this I must shutdown the database, copy the files, and startup the database again.
    At the moment the backups are full exports which I find unnecessary since it is a development database which is never used at night. It is therefore not an issue if we want to shut it down and re-start it after a few minutes. (I think it would take longer to export as opposed to copy the files right?)
    I need help and advice :
    1. Is my way of going about this correct ?
    2. How do I startup/shutdown from the command line (sqlplus user/password command) or should I use another utility ?
    Thanks,
    Gabriel

    set oracle_sid=ORCL ==> your database namethis is NOT always true. It's instance name. usually, we set instance name is same as database name.But we also can set instance name is different from database name.
    for example.
    C:\>oradim -new -sid abc123
    C:\>set ORACLE_SID=abc123
    C:\>sqlplus /nolog
    SQL*Plus: Release 9.0.1.4.0 - Production on Tue Jun 20 22:40:59 2006
    (c) Copyright 2001 Oracle Corporation.  All rights reserved.
    SQL> conn / as sysdba
    Connected to an idle instance.
    SQL> startup pfile=E:\ora901DB\admin\init.ora
    ORACLE instance started.
    Total System Global Area  344748244 bytes
    Fixed Size                   282836 bytes
    Variable Size             184549376 bytes
    Database Buffers          159383552 bytes
    Redo Buffers                 532480 bytes
    Database mounted.
    Database opened.
    SQL> select name from v$database;
    NAME
    DB901
    SQL> select instance_name from v$instance;
    INSTANCE_NAME
    abc123

  • Start OC4J Server from JButton

    I have JClient Swing applicaton and i have to start the Embedded OC4J Server from JButton because after that a jsp file must be run from this button. I tried this:Runtime.getRuntime().exec("java -jar oc4j.jar") but no effect. Any ideas?!

    I tried what you suggested. Put the link which is like
    "http://localhost:port/context-root/my.jsp" before
    Runtime.getRuntime().exec("java.exe -jar oc4j.jar");
    but with no effect again. The Embedded OC4J Server doesn't start.What I do wrong?

  • How do I shutdown from within Genome??

    How do I shutdown from within Genome??
    There is only a logout option - and that do not work.
    If I open a terminal and enter init 5 nothing happens.
    Or so it seems some services maybe stop.
    BUT there is no logoff and shutdown of Genome. So I swicth
    off my pc and next time I boot up my file system was corrupted.
    FSCK did not work I end up install everything this time use bypass
    option and install the patches for PC-Solaris 8.
    How do I go to a command line environment within Genome
    a .dtconfig stop ?? Will this let Genome come down without
    booting up and loosing my system again??

    ok... i figured it out... a 'Sprite' is really also a DisplayObjectContainer... so if i make my class an extension of Sprite i can 'addChild' to the Sprite and then add them all to the stage at once by adding Sprite to the stage...

  • [SOLVED] How do I shutdown from SLIM ?

    I am using SLIM to login to Fluxbox.  I should be able to type halt as username from within SLIM to shutdown.  Typing halt as username does not shutdown.  I have set sudo to allow my user to shutdown, but that doesn't help.
    How do I enable shutdown from within SLIM?
    Thank you
    Last edited by glenn69 (2012-04-26 17:49:01)

    glenn69 wrote:I am using SLIM to login to Fluxbox.  I should be able to type halt as username from within SLIM to shutdown.  Typing halt as username does not shutdown.  I have set sudo to allow my user to shutdown, but that doesn't help.
    Does it work with root password?

  • Disable shutdown from console

    Does anyone know if there is an easy way to restrict access to the "Commands" page
    (the page where you see the buttons for Shutdown, Cancel Shutdown, Disable Logins,
    etc.) from the Weblogic v5.1 console? The problem I have is that due to some
    high ranking staff wanting to be able to access the console, I do not want them
    to have access to that page in case they accidentally shutdown the server. If
    it is not possible, is there some kind of hack which can be implemented which
    will allow me to disable at least the Shutdown from the console? (ie. the name
    of the class being invoked, so I can rename it or something).
    I am not sure how to handle this issue, so any help would be greatly appreciated.
    Thanks.
    Jim

    You could create users for them and set-up the ACLs the way you want them to be. As
    far as I remember there is an ACL for the shutdown from the console, so you should be
    able to achieve what you want to do.
    Cheers,
    Deyan
    Jim Dritsas wrote:
    Does anyone know if there is an easy way to restrict access to the "Commands" page
    (the page where you see the buttons for Shutdown, Cancel Shutdown, Disable Logins,
    etc.) from the Weblogic v5.1 console? The problem I have is that due to some
    high ranking staff wanting to be able to access the console, I do not want them
    to have access to that page in case they accidentally shutdown the server. If
    it is not possible, is there some kind of hack which can be implemented which
    will allow me to disable at least the Shutdown from the console? (ie. the name
    of the class being invoked, so I can rename it or something).
    I am not sure how to handle this issue, so any help would be greatly appreciated.
    Thanks.
    Jim[dejan_bektchiev.vcf]

  • Selecting Shutdown from Apple menu causes restart AND MBP won't stay asleep

    2 possibly related problems. When I select shutdown from the Apple menu, my comp restarts.
    When I close the lid, the MBP wakes up every 20 secs or so. It's like living with someone who has had the hiccups for 2 years.
    Bluetooth is disable. No usb devices are connected. Wake on network is turned off.
    I have tried resetting the PMC, zapping the PRAM, AND deleting com.apple.Autowake.plist and com.apple.PowerManagement.plist
    From console, about shutdown:
    5/13/10 8:46:06 PM shutdown[195] SHUTDOWN_TIME: 1273808766 865706
    5/13/10 8:46:06 PM kernel systemShutdown true
    5/13/10 8:46:06 PM kernel systemShutdown true
    5/13/10 8:46:40 PM kernel systemShutdown false
    5/13/10 8:46:41 PM kernel Previous Shutdown Cause: 5
    5/13/10 8:49:11 PM shutdown[201] halt by tommaroney:
    from console, about sleep:
    5/13/10 8:44:35 PM kernel sleep
    5/13/10 8:44:35 PM kernel Wake reason =
    5/13/10 8:44:35 PM kernel System Wake
    5/13/10 8:44:35 PM kernel Previous Sleep Cause: -60
    5/13/10 8:44:35 PM kernel AirPort: Link Down on en1. Reason 4 (Disassociated due to inactivity).
    5/13/10 8:44:35 PM configd[14] network configuration changed.
    5/13/10 8:44:35 PM mDNSResponder[19] RegisterInterface: Frequent transitions for interface en1 (FE80:0000:0000:0000:021E:C2FF:FEB9:C2A7)
    5/13/10 8:44:36 PM kernel Auth result for: 00:20:a6:b8:55:ee MAC AUTH succeeded
    5/13/10 8:44:36 PM kernel AirPort: Link Up on en1
    5/13/10 8:44:36 PM configd[14] network configuration changed.
    5/13/10 8:44:36 PM mDNSResponder[19] RegisterInterface: Frequent transitions for interface en1 (10.11.1.42)
    5/13/10 8:44:40 PM mDNSResponder[19] DeregisterInterface: Frequent transitions for interface en1 (10.11.1.42)
    5/13/10 8:44:41 PM kernel hibernate image path: /var/vm/sleepimage
    5/13/10 8:44:41 PM kernel sizeof(IOHibernateImageHeader) == 512
    5/13/10 8:44:41 PM kernel Opened file /var/vm/sleepimage, size 2147483648, partition base 0xc805000, maxio 400000
    5/13/10 8:44:41 PM kernel hibernate image major 14, minor 1, blocksize 512, pollers 5
    5/13/10 8:44:41 PM kernel hibernateallocpages flags 00000000, gobbling 0 pages
    5/13/10 8:44:41 PM Firewall[59] krb5kdc is listening from :::88 proto=6
    5/13/10 8:44:41 PM Firewall[59] krb5kdc is listening from 0.0.0.0:88 proto=6
    5/13/10 8:44:42 PM kernel AppleYukon2: 00000000,2524d000 sky2 - HardwareNotResponding, marking offline
    5/13/10 8:44:43 PM kernel System SafeSleep
    5/13/10 8:44:43 PM kernel hibernatepage_listsetall start
    5/13/10 8:44:43 PM kernel hibernatepage_listsetall time: 83 ms
    5/13/10 8:44:43 PM kernel pages 187393, wire 35045, act 37976, inact 132, spec 35, zf 0, throt 0, could discard act 20320 inact 17074 purgeable 2201 spec 74610
    5/13/10 8:44:43 PM kernel hibernatepage_listsetall found pageCount 73188
    5/13/10 8:44:43 PM kernel IOHibernatePollerOpen, mlget_interruptsenabled 0
    5/13/10 8:44:43 PM kernel IOHibernatePollerOpen(0)
    5/13/10 8:44:43 PM kernel writing 71701 pages
    5/13/10 8:44:43 PM kernel image1Size 73461248
    5/13/10 8:44:43 PM kernel PMStats: Hibernate write took 4330 ms
    5/13/10 8:44:43 PM kernel all time: 4330 ms, comp time: 484 ms, deco time: 0 ms,
    5/13/10 8:44:43 PM kernel image 137517568, uncompressed 294051840 (71790), compressed 131663056 (44%), sum1 48a3dfe, sum2 fc9481ea
    5/13/10 8:44:43 PM kernel hibernatewriteimage done(0)
    5/13/10 8:44:43 PM kernel sleep

    2 possibly related problems. When I select shutdown from the Apple menu, my comp restarts.
    When I close the lid, the MBP wakes up every 20 secs or so. It's like living with someone who has had the hiccups for 2 years.
    Bluetooth is disable. No usb devices are connected. Wake on network is turned off.
    I have tried resetting the PMC, zapping the PRAM, AND deleting com.apple.Autowake.plist and com.apple.PowerManagement.plist
    From console, about shutdown:
    5/13/10 8:46:06 PM shutdown[195] SHUTDOWN_TIME: 1273808766 865706
    5/13/10 8:46:06 PM kernel systemShutdown true
    5/13/10 8:46:06 PM kernel systemShutdown true
    5/13/10 8:46:40 PM kernel systemShutdown false
    5/13/10 8:46:41 PM kernel Previous Shutdown Cause: 5
    5/13/10 8:49:11 PM shutdown[201] halt by tommaroney:
    from console, about sleep:
    5/13/10 8:44:35 PM kernel sleep
    5/13/10 8:44:35 PM kernel Wake reason =
    5/13/10 8:44:35 PM kernel System Wake
    5/13/10 8:44:35 PM kernel Previous Sleep Cause: -60
    5/13/10 8:44:35 PM kernel AirPort: Link Down on en1. Reason 4 (Disassociated due to inactivity).
    5/13/10 8:44:35 PM configd[14] network configuration changed.
    5/13/10 8:44:35 PM mDNSResponder[19] RegisterInterface: Frequent transitions for interface en1 (FE80:0000:0000:0000:021E:C2FF:FEB9:C2A7)
    5/13/10 8:44:36 PM kernel Auth result for: 00:20:a6:b8:55:ee MAC AUTH succeeded
    5/13/10 8:44:36 PM kernel AirPort: Link Up on en1
    5/13/10 8:44:36 PM configd[14] network configuration changed.
    5/13/10 8:44:36 PM mDNSResponder[19] RegisterInterface: Frequent transitions for interface en1 (10.11.1.42)
    5/13/10 8:44:40 PM mDNSResponder[19] DeregisterInterface: Frequent transitions for interface en1 (10.11.1.42)
    5/13/10 8:44:41 PM kernel hibernate image path: /var/vm/sleepimage
    5/13/10 8:44:41 PM kernel sizeof(IOHibernateImageHeader) == 512
    5/13/10 8:44:41 PM kernel Opened file /var/vm/sleepimage, size 2147483648, partition base 0xc805000, maxio 400000
    5/13/10 8:44:41 PM kernel hibernate image major 14, minor 1, blocksize 512, pollers 5
    5/13/10 8:44:41 PM kernel hibernateallocpages flags 00000000, gobbling 0 pages
    5/13/10 8:44:41 PM Firewall[59] krb5kdc is listening from :::88 proto=6
    5/13/10 8:44:41 PM Firewall[59] krb5kdc is listening from 0.0.0.0:88 proto=6
    5/13/10 8:44:42 PM kernel AppleYukon2: 00000000,2524d000 sky2 - HardwareNotResponding, marking offline
    5/13/10 8:44:43 PM kernel System SafeSleep
    5/13/10 8:44:43 PM kernel hibernatepage_listsetall start
    5/13/10 8:44:43 PM kernel hibernatepage_listsetall time: 83 ms
    5/13/10 8:44:43 PM kernel pages 187393, wire 35045, act 37976, inact 132, spec 35, zf 0, throt 0, could discard act 20320 inact 17074 purgeable 2201 spec 74610
    5/13/10 8:44:43 PM kernel hibernatepage_listsetall found pageCount 73188
    5/13/10 8:44:43 PM kernel IOHibernatePollerOpen, mlget_interruptsenabled 0
    5/13/10 8:44:43 PM kernel IOHibernatePollerOpen(0)
    5/13/10 8:44:43 PM kernel writing 71701 pages
    5/13/10 8:44:43 PM kernel image1Size 73461248
    5/13/10 8:44:43 PM kernel PMStats: Hibernate write took 4330 ms
    5/13/10 8:44:43 PM kernel all time: 4330 ms, comp time: 484 ms, deco time: 0 ms,
    5/13/10 8:44:43 PM kernel image 137517568, uncompressed 294051840 (71790), compressed 131663056 (44%), sum1 48a3dfe, sum2 fc9481ea
    5/13/10 8:44:43 PM kernel hibernatewriteimage done(0)
    5/13/10 8:44:43 PM kernel sleep

  • How to get name from JButton?

    Hey
    Is it possible to get the name from a clicked JButton in the actionPerformed so that if i have for example 2 JButtons i can do an
    if statement to do different things when a button is clicked?
    For example if button1 is clicked the screen writes "YippiKayYeah mother ......" and if button2 is clicked it writes "Go home Lazy Boy".
    Here is my code, if it is for any use:
    public class Main extends JPanel implements ActionListener {
        private Players players;
        JTextArea output;
        JScrollPane scrollPane2;
        JButton button1, button2;
        String newline = "\n";
        public Main(){
            players = new Players();
        public JMenuBar createMenuBar(){
            JMenuBar menuBar = new JMenuBar();
            JMenu menu = new JMenu("File");
            menu.setMnemonic(KeyEvent.VK_A);
            menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
            menuBar.add(menu);
            // add menuitems/buttons
            JMenuItem menuItemSave   = new JMenuItem("Save");
            menuItemSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
            menuItemSave.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
            // add actionlistener       
            JMenuItem menuItemOpen   = new JMenuItem("Open");
            JMenuItem menuItemQuit   = new JMenuItem("Quit");
            // add to menu
            menu.add(menuItemSave);
            menu.add(menuItemOpen);
            menu.add(menuItemQuit);
            return menuBar;
        public Container createContent(){
            JPanel contentPane = new JPanel(new GridLayout(3,1));
            ImageIcon icon = createImageIcon("middle.gif", "a pretty but meaningless splat");
            JTable scrollPane = new JTable(players.showPlayers()); 
            //Create the first label.
            button1 = new JButton("Silkeborg IF");
            button1.setToolTipText("Klik her for at se Silkeborg IF");
            button1.addActionListener(this);
            button1.setActionCommand("enable");
            //Create the second label.
            button2 = new JButton("FC Midtjylland");
            button2.setToolTipText("Klik her for at se FC Midtjylland");
            button2.addActionListener(this);
            button2.setActionCommand("disable");
            //Create a scrolled text area.
            output = new JTextArea(5, 30);
            output.setEditable(false);
            scrollPane2 = new JScrollPane(output);
            //Add stuff to contentPane.
            contentPane.add(button1);
            contentPane.add(button2);
            contentPane.add(scrollPane);
            contentPane.add(scrollPane2, BorderLayout.CENTER);
            return contentPane;
        public void actionPerformed(ActionEvent e){
            String s;
            if ("enable".equals(e.getActionCommand())){
                s = "Silkeborg IF"+e.getSource();
                output.append(s + newline);
                button1.setActionCommand("disable");
                button2.setActionCommand("enable");
            } else{
                s = "FC Midtjylland"+e.getSource();
                output.append(s + newline);
                button1.setActionCommand("enable");
                button2.setActionCommand("disable");
        protected static ImageIcon createImageIcon(String path,
                                                   String description) {
            java.net.URL imgURL = Main.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL, description);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
        public static void createGUI(){
            JFrame frame = new JFrame("Test af yo yo yo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Main menu = new Main();
            frame.setJMenuBar(menu.createMenuBar());
            frame.setContentPane(menu.createContent());
            frame.setSize(500, 300);
            frame.pack();
            frame.setVisible(true);
         * @param args the command line arguments
        public static void main(String[] args) {
            createGUI();
    }

    what i do with my JButtons is create and inner class that implements actionListener like this:
         private JButton button;
         button = new JButton("Button");
         button.addActionListener(new BListener());
         private class BListener implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   if(e.getSource() == button){
                        //code for when the JButton button is pushed
         }Also, rather than comparing the names (Strings) and creating overhead, this compares the buttons reference variables :). Oh, and make sure that the buttons used are class variables. A good idea is to keep related buttons; listeners in one private class e.g. navigation buttons in a browser are all registered with the listener NavListener.

  • Is there anyway to shutdown from Terminal

    My aging G5 running Leopard is hanging up at random times. Up to now, I have had to shut down the machine by pushing and holding the power switch. I know this is a bad thing to do, but I do not know any other way.
    Is there any special set of keystrokes that will bring up the terminal from a hung up machine and allow me then shut it down ????
    Thanks for your help.
    Dick B

    Hi Dick, and a warm welcome to the forums!
    Nothing at all may work depending where/how it's froze, but the key combo of Control+Eject, (F12), may bring up the Restart/Shutdown Dialog box and the 1st letter of each will selct that button.
    CommandOptionesc = Bring up Force Quit window
    CommandControleject = Restart immediately
    CommandOption+Controleject = Shutdown immediately
    CommandControlpower button = Force restart

  • Windows service does not stop when DB is shutdown from SQL*Plus

    I have a 11g XE DB in a Windows 7 machine.
    The installation has created a Windows service called OracleServiceXE. It's status is STARTED.
    I then login to SQLPLUS as sysdba and do a shutdown immediate;
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    Problem is, when I refresh the services, the OracleServiceXE is still showing as STARTED.
    If I use the listener control to stop the listener the Windows service OracleXETNSListener changes status to BLANK.
    Why is this?

    tvCa-Oracle wrote:
    That service is a prerequisite Windows service to be able to start the database, but it is not the status of the database itself.
    When you do start the database, he may or may not start the service automatically (not sure there), but it is a needed service, for each database SID, on Windows.
    If you want to know what it is, open Task Manager or Process Explorer, only start the service (not the database), and see which OS process is launched.
    AFAIK, this is only on Windows, there's no comparable component on Linux/Unix for this.
    The Windows service OracleServiceXE has c:\app\oracle\product\11.2.0\server\bin\ORACLE.EXE XE as the Parth to executable.
    If I click on the Services tab in Task manager, then right-click the OracleServiceXE and click Go to process, it show the oracle.exe in the processes tab.
    If stop it, the service, from the Windows service control, the oracle.exe disappears and we cannot login to the DB.
    If we start the service from the windows service control, the oradim.exe appears, then a second later the oracle.exe appears. Once the DB status of the Windows service is STARTED, the oradim.exe disappears.
    So, I can start and stop the oracle DB with the Windows service. But If I stop the DB from sql*plus the the service is not stopped....

  • Shutdown from Lion, Mail stop the shutdown.

    Hello,
    i have the following problem. If i want to shutdown the iMac with menu - shutdown, i have often the problem, that mail stops the shutdown. Only a hard kill from mail will shutdown the mac. What can i do ? Has someone the some problem ?
    Thx

    iMac, Mac OS X (10.7.3)   <  your profile
    If that is correct, try updating your system software. Click your Apple menu > Software Update.
    And try "force quitting" using Activity Monitor (located in HD > Applications > Utilities) instead of Command + Option + E or force quit from the Apple menu.

Maybe you are looking for