Window#setAlwaysOnTop andJava 1.4.x

Hello,
does anybody know a way to simulate the beaviour of the method Window#setAlwaysOnTop from Java 1.5.x in Java 1.4.x
It should be possible to focus the main-frame( is an applet) or the always on top frame...
Thank you, Fabian

Implement a WindowListener and in windowDeactivated you call e.getWindow().toFront();
Maybe you also need some stuff in windowIconified()

Similar Messages

  • Is only ONE .jar file allowed in resources tag?

    I can run my web launch program when use the jnlp file configured this way:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp spec="1.0+" codebase="http://www.u.arizona.edu/~michaelo/" href="launch.jnlp">
    <information>
    <title>JFlashCalc Pharmacologic Calculations Program</title>
    <vendor>OSSIPOV</vendor>
    <homepage href="http://www.u.arizona.edu/~michaelo"/>
    <description>jflashcalc</description>
    <description kind="short">Pharmacologic Calculations with JFlashCalc</description>
    </information>
    <resources>
    <j2se version="1.4+"/>
    <jar href="main-app/jflashcalc.jar"/>
    </resources>
    <application-desc main-class="jflashcalc.JFlashTable">
    </application-desc>
    </jnlp>
    But, in order to be able to use the FreeHep VectorGraphics classes, I reconfigured the .jnlp file like this (emulating their own ExportDemo.jnlp, which works fine)
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp spec="1.0+" codebase="http://www.u.arizona.edu/~michaelo/" href="launch.jnlp">
    <information>
    <title>JFlashCalc Pharmacologic Calculations Program</title>
    <vendor>OSSIPOV</vendor>
    <homepage href="http://www.u.arizona.edu/~michaelo"/>
    <description>jflashcalc</description>
    <description kind="short">Pharmacologic Calculations with JFlashCalc</description>
    </information>
    <resources>
    <j2se version="1.4+"/>
    <jar href="main-app/jflashcalc.jar"/>
    <jar href="lib/freehep-export.jar"/>
    <jar href="lib/freehep-graphics2d.jar"/>
    <jar href="lib/freehep-graphicsio.jar"/>
    <jar href="lib/FreeVG.jar"/>
    <jar href="lib/freehep-io.jar"/>
    <jar href="lib/freehep-swing.jar"/>
    <jar href="lib/freehep-util.jar"/>
    <jar href="lib/freehep-xml-2.0.1.jar"/>
    <jar href="lib/jas-plotter-2.0.jar"/>
    <jar href="lib/jdom-1.0.jar"/>
    <jar href="lib/junit-3.8.2.jar"/>
    <jar href="lib/openide-lookup.jar"/>
    </resources>
    <application-desc main-class="jflashcalc.JFlashTable">
    </application-desc>
    </jnlp>
    Now, I get this error message, which is consistent with unsigned jar files. I signed ALL the jar files used, so what can be happening here?
    Exception in thread "AWT-EventQueue-0" java.security.AccessControlException: access denied (java.awt.AWTPermission setWindowAlwaysOnTop)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.awt.Window.setAlwaysOnTop(Unknown Source)
         at jflashcalc.JFlashTable.<init>(JFlashTable.java:486)
         at jflashcalc.JFlashTable$1.run(JFlashTable.java:72)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    If I remove these lines from .jnlp, all works fine again, except I can't do the file export:
    <jar href="lib/freehep-export.jar"/>
    <jar href="lib/freehep-graphics2d.jar"/>
    <jar href="lib/freehep-graphicsio.jar"/>
    <jar href="lib/FreeVG.jar"/>
    <jar href="lib/freehep-io.jar"/>
    <jar href="lib/freehep-swing.jar"/>
    <jar href="lib/freehep-util.jar"/>
    <jar href="lib/freehep-xml-2.0.1.jar"/>
    <jar href="lib/jas-plotter-2.0.jar"/>
    <jar href="lib/jdom-1.0.jar"/>
    <jar href="lib/junit-3.8.2.jar"/>
    <jar href="lib/openide-lookup.jar"/>

    In order to get all-permissions, you need to add the security element in the jnlp file:
    <security>
    <all-permissions/>
    </security>
    otherwise, javaws will not try to validate the jar(s) certificates and grant the required permissions.

  • Signed java applets not working on lion?

    After downloading java plugin on osx Lion, signed java applets fail to start. This is the error I get in java console, seems like the certificate is not imported to keychain? any workaround?:
    java.lang.reflect.InvocationTargetException
        at java.awt.EventQueue.invokeAndWait(EventQueue.java:1078)
        at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1326)
        at com.koutbo6.gui.swing.GameApplet.init(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.ja va:1640)
        at java.lang.Thread.run(Thread.java:680)
    Caused by: java.security.AccessControlException: access denied (java.awt.AWTPermission setWindowAlwaysOnTop)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:37 4)
        at java.security.AccessController.checkPermission(AccessController.java:546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.awt.Window.setAlwaysOnTop(Window.java:2038)
        at com.koutbo6.gui.swing.Q.<init>(Unknown Source)
        at com.koutbo6.gui.swing.GameApplet.a(Unknown Source)
        at com.koutbo6.gui.swing.P.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
        at java.awt.EventQueue.access$000(EventQueue.java:85)
        at java.awt.EventQueue$1.run(EventQueue.java:638)
        at java.awt.EventQueue$1.run(EventQueue.java:636)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlConte xt.java:87)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:29 6)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:20 1)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

    All these settings were set as expected, yet im still facing the same problem
    I enabled security debugging and this is the information I got:
    security: Loading certificates from Deployment session certificate store
    security: Loaded certificates from Deployment session certificate store
    security: Loading Root CA certificates from from keychain
    security: Loaded Root CA certificates from from keychain
    security: Validate the certificate chain using CertPath API
    security: Obtain certificate collection in Root CA certificate store
    security: Obtain certificate collection in Root CA certificate store
    security: Obtain certificate collection in Root CA certificate store
    security: jpicertstore.cert.getkeystore
    security: No timestamping info available
    security: Cannot find jurisdiction list file
    security: The CRL support is enabled
    security: KB Programming Analysis and PC Operating Center
    security: ObjectId: 2.5.29.31 Criticality=false
    CRLDistributionPoints [
      [DistributionPoint:
         [URIName: http://crl.thawte.com/ThawteCodeSigningCA.crl]
    security: Thawte Code Signing CA
    security: ObjectId: 2.5.29.31 Criticality=false
    CRLDistributionPoints [
      [DistributionPoint:
         [URIName: http://crl.thawte.com/ThawtePremiumServerCA.crl]
    security: Use CRL setting from certificate
    security: The OCSP support is enabled
    security: KB Programming Analysis and PC Operating Center
    security: ObjectId: 1.3.6.1.5.5.7.1.1 Criticality=false
    AuthorityInfoAccess [
       accessMethod: 1.3.6.1.5.5.7.48.1
       accessLocation: URIName: http://ocsp.thawte.com]
    security: This certificate does not have AIA extension
    security: Use OCSP setting from certificate
    network: Cache entry not found [url: http://crl.thawte.com/ThawtePremiumServerCA.crl, version: null]
    network: Connecting http://crl.thawte.com/ThawtePremiumServerCA.crl with proxy=DIRECT
    network: Connecting http://crl.thawte.com:80/ with proxy=DIRECT
    network: Downloading resource: http://crl.thawte.com/ThawtePremiumServerCA.crl
              Content-Length: 181,278
              Content-Encoding: null
    network: Wrote URL http://crl.thawte.com/ThawtePremiumServerCA.crl to File /Users/koutbo6/Library/Caches/Java/cache/6.0/38/2fb889a6-30a08967-temp
    network: Connecting http://ocsp.thawte.com/ with proxy=DIRECT
    network: Connecting http://ocsp.thawte.com:80/ with proxy=DIRECT
    network: CleanupThread used 990300 us
    network: Connecting http://ocsp.thawte.com/ with proxy=DIRECT
    network: Connecting http://ocsp.thawte.com:80/ with proxy=DIRECT
    security: This certificate has been revoked
    Ignored exception: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Certificate has been revoked

  • TrayIcon with PopupMenu or JPopupMenu ?

    Hi. (Sorry for my english.)
    I spent last 10 whole days digging menu things in TrayIcon with no success :((.
    I have three questions.
    I can make JPopupWindow above MS-Windows task bar ( SwingUtilities.windowForComponent( JPupupMenu ).window.setAlwaysOnTop( true ) ) , but how to get keyboard focus/input ????
    Looking back to normal PopupMenu ... when it pop up -> it blocks Event Dispatch Thread (EDT) (even if I fire it manually .show() from new Thread , I also tryed install new EventQueue ).
    How to make non-blocking PopupMenu ? How to pop up via .show() without "origin" ? ( MouseEvent of TrayIcon returns null in .getComponent() ).
    I am using Java 6.0 b105 and u1 b03 at WinXP.
    Does anybody know solutions ?
    Thanks !
    PS: I wrote a very simple example.
    It changes tray icon and JPanel background every 0.5 second. The question is : is program continue to work when you popup tray icon menu (right click) ?
    This is the last event that goes thru EventQueue after I right click tray icon, and before menu shows (and blocks everythig): java.awt.event.InvocationEvent[INVOCATION_DEFAULT,runnable=sun.awt.windows.WTrayIconPeer$1@128e20a,notifier=null,catchExceptions=false,when=1172501444578] on sun.awt.windows.WToolkit@1e0cf70
    //====================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class IsTrayIconMenuBlocking3
         public static void main( String[] args ) throws Exception
              // --- JFrame & JPanel section
              final JPanel jp = new JPanel();
              JFrame jf = new JFrame();
              jf.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              jf.add( jp );
              jf.setSize( 300 , 300 );
              jf.setVisible( true );
              // --- menu item action
              ActionListener itemExitAction = new ActionListener()
                   public void actionPerformed( ActionEvent e )
                        System.out.println( "item action: exit" );
                        System.exit( 0 );
              // --- popup menu
              PopupMenu pm = new PopupMenu( "Tray Menu" );
              MenuItem mi = new MenuItem( "Exit" );
              mi.addActionListener( itemExitAction);
              pm.add( mi );
              // --- system tray & tray icon
              final TrayIcon ti = new TrayIcon( ((ImageIcon)UIManager.getIcon("OptionPane.questionIcon")).getImage() , "Tray Icon" , pm );
              SystemTray st = SystemTray.getSystemTray();
              ti.setImageAutoSize( true );
              st.add( ti );          
              // --- color & icon changing loop
              final Image[] trayIcons = new Image[3];
              trayIcons[0] = ((ImageIcon)UIManager.getIcon("OptionPane.errorIcon")).getImage();
              trayIcons[1] = ((ImageIcon)UIManager.getIcon("OptionPane.warningIcon")).getImage();
              trayIcons[2] = ((ImageIcon)UIManager.getIcon("OptionPane.informationIcon")).getImage();
              Runnable colorChanger = new Runnable()
                   private int counter = 0;
                   private int icon_no = 0;
                   public void run()
                        System.out.println( "Hello from EDT " + counter++ );
                        if( jp.getBackground() == Color.RED )
                             jp.setBackground( Color.BLUE );
                        else
                             jp.setBackground( Color.RED );
                        ti.setImage( trayIcons[icon_no++] );
                        if( icon_no == trayIcons.length ) icon_no = 0;                    
              while( true )
                   javax.swing.SwingUtilities.invokeLater( colorChanger);
                   try{Thread.sleep( 500 );} catch ( Exception e ){}
    //====================================

    Hi,
    thanks for help.
    I am closing this subject.
    My solution can be found at http://forums.java.net/jive/thread.jspa?threadID=23466&tstart=0 .
    ( java.net Forums � Java Desktop Technologies � Swing & AWT � TrayIcon PopupMenu or JPopupMenu ? )
    Bye !

  • JWindow shows just an empty square

    Below i will give two classes. They works fine except one thing - when i push button, JWindow appears, but it is empty. Why? If I put a code from work() method to main() everything works perfect. Can someone help and explain what to do?
    This class works fine
    package bin;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JWindow;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    public class Indikatorius implements Runnable{
         private static final long serialVersionUID = 1L;
         private ImageIcon ii = new ImageIcon("Menas/Indikatorius.gif");
         private JLabel l = new JLabel("TEST");
         private Container contentPane;
         private Frame f;
         private JWindow window;
        public Indikatorius(Frame owner) {
             f = owner;
        private void centruok(){
             Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
              window.setLocation((dim.width-window.getWidth())/2, (dim.height-30-window.getHeight())/2 );
        private void sukurk(){
             window = new JWindow(f);
             contentPane = window.getContentPane();
             contentPane.setLayout(new BorderLayout());
             contentPane.add(l, BorderLayout.CENTER);
             window.setAlwaysOnTop(true);
             window.pack();
             centruok();
             window.setVisible(true);
        public void kill(){
             window.dispose();
        public void run(){
             sukurk();
        public static void main(String[] args) throws InterruptedException{
             Indikatorius i = new Indikatorius(null);
             Thread t = new Thread(i);
             t.start();
             t.join();
             t.sleep(5000);
             i.kill();
    }This - not.
    package bin;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test extends JFrame implements ActionListener{
         * Creates a new instance of <code>Test</code>.
        private JButton b = new JButton("push me");
        public Test() {
             setSize(400,600);
             getContentPane().setLayout(new BorderLayout());
             getContentPane().add(b, BorderLayout.CENTER);
             b.addActionListener(this);
             centruok();
             setVisible(true);
        private void centruok(){
             Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
              setLocation((dim.width-getWidth())/2, (dim.height-30-getHeight())/2 );
        private synchronized void work() throws InterruptedException{
             Indikatorius i = new Indikatorius(this);
             Thread t = new Thread(i);
             t.start();
             t.join();
             t.sleep(5000);
             for (int j = 0; j < 1000; j++)
                  System.out.println("Numeris: "+j);
             i.kill();
             Thread.sleep(2000);
             setVisible(false);
             dispose();
        public void actionPerformed(ActionEvent e) {
             try{
                  work();
             catch(InterruptedException ie){
         * @param args the command line arguments
        public static void main(String[] args){
            // TODO code application logic here
            new Test();
    }

    If someone want a working waiting window - feel free to use
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.BorderLayout;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JWindow;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.border.BevelBorder;
    import javax.swing.BorderFactory;
    public class Indikatorius extends JWindow implements Runnable{
         private static final long serialVersionUID = 1L;
         private ImageIcon ii = new ImageIcon("Menas/Indikatorius.gif");
         private JLabel l = new JLabel(ii);
         private Container contentPane;
        public Indikatorius(JFrame owner) {
             super(owner);
             setSize(200, 200);
             contentPane = getContentPane();         
             ((JPanel)contentPane).setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
             contentPane.add(l, BorderLayout.CENTER);
             setAlwaysOnTop(true);
             centruok();         
             //setVisible(true);
        private void centruok(){
             Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
              setLocation((dim.width-getWidth())/2, (dim.height-30-getHeight())/2 );
        public void run(){
             setVisible(true);
    }AND
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test extends JFrame implements ActionListener{
      private JButton b = new JButton("push me");
        public Test() {
             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
             setSize(400,600);
             getContentPane().setLayout(new BorderLayout());
             getContentPane().add(b, BorderLayout.CENTER);
             b.addActionListener(this);
             centruok();
             setVisible(true);
        private void centruok(){
             Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
              setLocation((dim.width-getWidth())/2, (dim.height-30-getHeight())/2 );
        public void actionPerformed(ActionEvent e){
             final Indikatorius ind = new Indikatorius(this);
             Thread appThread = new Thread(){
                  public void run(){
                       try{
                            //SwingUtilities.invokeAndWait(ind);
                            SwingUtilities.invokeLater(ind);
                            for (int j = 0; j < 100; j++)
                                 System.out.println("Numeris: "+j);
                       catch (Exception e){
                            e.printStackTrace();
                       //System.out.println("Finished on " + Thread.currentThread());
                       for (int j = 0; j < 1000; j++)
                            System.out.println("Numeris: "+j);
                       ind.dispose();
            appThread.start();
         * @param args the command line arguments
        public static void main(String[] args){
            // TODO code application logic here
            new Test();
    }

  • Change and set Focus of window

    HI
    Guys
    I have encountered a problem while setting focus of my application's windows.
    i found the way i.e. by
    public void windowGainedFocus(WindowEvent wgf) {          
              if(this.isActive()){
                   VWM.theVWMDetailWindow.setAlwaysOnTop(true);
                   System.out.println(wgf.getSource());
         }by doing that there is errors came.....
    but there is no effect on the window theVWMDetailWindow to have operation setAlwaysOnTop successfully functoned
    Please help me out
    Thanks

    HI
    Yannix
    actually , i want to get the focus of my application window
    and then perform the action on it..
    The case is that::
    I have a main window..then on it a menu bar...
    when i click on one of the menu option then another separate window will be opened....and many other windows on different menu options....
    SO now i want to control their focus..... rite
    when my main window's focus lost means if i select another application
    another related opened window's must also lost their focus at that time.and when i came back to the main window another window's already opened must be on top.....
    So could you please suggest me some way , some solution to solve this
    Thanks

  • Problem repaint ( Refresh ) window

    Hi Friends,
    I have GUI JFrame window , in which i have added
    combo box and add button when i click add one new JFrame window
    opens and ask for name and when click OK, that is added to database.
    1) Main Window in which add button is there
    2) Secondary JFrame inputs the Username
    Now i want to show name should be added in Main Window's combo
    while clicking the Secondary windows OK button.
    How can I repaint thing ??
    I tried
    panel.updateUI( )but still it not showing me new added name.
    When i close application and restart it , it will showing me last added name , but it should not be the solution.
    HELP.

    MyExpenseTracker.java
    (Main Class)
    * MyExpenseTracker.java
    * Created on October 11, 2007, 6:10 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package app;
    import app.AddNewItem;
    import java.util.*;
    * @author Administrator
    public class MyExpenseTracker
        /** Creates a new instance of MyExpenseTracker */
        public MyExpenseTracker()
        public static void main(String args[])   
                ExpTracker t = new ExpTracker();
                MyExpenseTracker mymain = new MyExpenseTracker();
                //LoginForm loginf = new LoginForm();
                t.setVisible(true);
    }ExpTracker.java ( Main Window for project - no main method )
    * ExpTracker.java
    * Created on October 11, 2007, 1:39 PM
    package app;
    import app.AddNewItem;
    import app.AddNewName;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    * @author  Administrator
    public class ExpTracker extends javax.swing.JFrame
        /** Creates new form ExpTracker */
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        String query;
        int status =0;
        String URL="jdbc:mysql://localhost:3306/exptracker";
        String DRIVER ="com.mysql.jdbc.Driver";
        //String user =loginf.getAuthenticatedUser();
        Calendar cal = Calendar.getInstance();
        int day = cal.get(Calendar.DATE);
        int month = cal.get(Calendar.MONTH)+1;
        int year = cal.get(Calendar.YEAR);
        public ExpTracker()
            super("Expense Tracker v1.0");
            initComponents();
            //System.out.println("User name got :"+user);
            //javax.swing.JOptionPane.showMessageDialog(this,"Username:"+ user);
            //System.out.println("user :"+user);
            loadNameCombo();
            cmbdate.setSelectedItem(day);
            cmbmonth.setSelectedIndex(month-1);
            cmbyear.setSelectedItem(year);
        public void doConnection()
            //make connection
            try
                Class.forName(DRIVER).newInstance();
            catch(Exception e)
            { System.out.println("driver not found"+e.getMessage());     }
            //making query
            try
                con = DriverManager.getConnection(URL, "root", "");
                stmt = con.createStatement();
            catch(Exception e)
            { System.out.println("Connection Failure !"+ e.getMessage());  }
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jp1 = new javax.swing.JPanel();
            lbldate = new javax.swing.JLabel();
            cmbdate = new javax.swing.JComboBox();
            cmbmonth = new javax.swing.JComboBox();
            cmbyear = new javax.swing.JComboBox();
            lblfixdate = new javax.swing.JLabel();
            lblitem = new javax.swing.JLabel();
            cmbitem = new javax.swing.JComboBox();
            lblqty = new javax.swing.JLabel();
            tfqty = new javax.swing.JTextField();
            lblprice = new javax.swing.JLabel();
            tfprice = new javax.swing.JTextField();
            lblqtyfix = new javax.swing.JLabel();
            lblpricefix = new javax.swing.JLabel();
            btnAdd = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            lblname = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            ta = new javax.swing.JTextArea();
            btnReport = new javax.swing.JButton();
            btnAddRecord = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            cmbname = new javax.swing.JComboBox();
            btnAddname = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            menu = new javax.swing.JMenu();
            menu1exit = new javax.swing.JMenuItem();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jp1.setBorder(javax.swing.BorderFactory.createTitledBorder("Expense Detail"));
            lbldate.setFont(new java.awt.Font("Tahoma", 0, 10));
            lbldate.setText("Date :");
            cmbdate.setFont(new java.awt.Font("Tahoma", 0, 10));
            for(int i=1; i<=31; i++)
                cmbdate.addItem(i);
            cmbmonth.setFont(new java.awt.Font("Tahoma", 0, 10));
            cmbmonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }));
            cmbyear.setFont(new java.awt.Font("Tahoma", 0, 10));
            for(int i=2006; i<=2050; i++)
                cmbyear.addItem(i);
            lblfixdate.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblfixdate.setText("*Format is dd-MM-yyyy");
            lblitem.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblitem.setText("Item :");
            cmbitem.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqty.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqty.setText("Quantity :");
            tfqty.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblprice.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblprice.setText("Price :");
            tfprice.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqtyfix.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqtyfix.setText("*you can write like 2 ,3 or 300gm");
            lblpricefix.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblpricefix.setText("*ex. 300, 13.50 etc. no characters");
            btnAdd.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnAdd.setText("Add");
            btnAdd.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddActionPerformed(evt);
            jLabel1.setFont(new java.awt.Font("Tahoma", 0, 10));
            jLabel1.setText("*if item is not in list, click Add button");
            org.jdesktop.layout.GroupLayout jp1Layout = new org.jdesktop.layout.GroupLayout(jp1);
            jp1.setLayout(jp1Layout);
            jp1Layout.setHorizontalGroup(
                jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jp1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jp1Layout.createSequentialGroup()
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, lblitem, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, lbldate, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jp1Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmbdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmbmonth, 0, 59, Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmbyear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(jp1Layout.createSequentialGroup()
                                    .add(10, 10, 10)
                                    .add(lblfixdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(cmbitem, 0, 168, Short.MAX_VALUE)
                                .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)))
                        .add(jp1Layout.createSequentialGroup()
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(lblqty)
                                .add(lblprice))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(tfprice, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                                .add(tfqty, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                .add(lblqtyfix, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                                .add(lblpricefix, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(btnAdd, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addContainerGap())
            jp1Layout.setVerticalGroup(
                jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jp1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(lbldate)
                        .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(cmbyear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(cmbdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(cmbmonth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(5, 5, 5)
                    .add(lblfixdate)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblitem)
                        .add(cmbitem, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(btnAdd))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jLabel1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblqty)
                        .add(tfqty, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(1, 1, 1)
                    .add(lblqtyfix)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblprice)
                        .add(tfprice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(lblpricefix)
                    .addContainerGap(41, Short.MAX_VALUE))
            lblname.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblname.setText("Name :");
            ta.setColumns(20);
            ta.setLineWrap(true);
            ta.setRows(5);
            jScrollPane1.setViewportView(ta);
            btnReport.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnReport.setText("Report");
            btnAddRecord.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnAddRecord.setText("Add New Expense");
            jLabel2.setFont(new java.awt.Font("Tahoma", 0, 10));
            jLabel2.setText("Comments :");
            cmbname.addFocusListener(new java.awt.event.FocusAdapter()
                public void focusGained(java.awt.event.FocusEvent evt)
                    cmbnameFocusGained(evt);
            btnAddname.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnAddname.setText("Add");
            btnAddname.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddnameActionPerformed(evt);
            menu.setText("File");
            menu1exit.setText("Exit");
            menu1exit.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    menu1exitActionPerformed(evt);
            menu.add(menu1exit);
            jMenuBar1.add(menu);
            setJMenuBar(jMenuBar1);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jp1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                            .add(10, 10, 10)
                            .add(btnReport, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(28, 28, 28)
                            .add(btnAddRecord, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(layout.createSequentialGroup()
                            .add(lblname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(15, 15, 15)
                            .add(cmbname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 194, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(btnAddname, 0, 0, Short.MAX_VALUE)
                            .add(28, 28, 28)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 253, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                            .add(39, 39, 39)
                            .add(jLabel2)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane1))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                            .add(20, 20, 20)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(lblname)
                                .add(cmbname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(btnAddname))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jp1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(btnReport)
                        .add(btnAddRecord))
                    .addContainerGap(15, Short.MAX_VALUE))
            pack();
        }// </editor-fold>                       
        private void cmbnameFocusGained(java.awt.event.FocusEvent evt)                                   
    // TODO add your handling code here:
           this.jp1.updateUI();
        public void loadNameCombo()
            doConnection();
            try{
                query ="select name from name_master";
                rs = stmt.executeQuery(query);
                while(rs.next())
                    cmbname.addItem(rs.getString("name"));
            }catch(Exception e){ e.printStackTrace(); }
             // this.repaint();    
        public void reloadComboName()
            cmbname.removeAllItems();
            loadNameCombo();
            this.repaint();
        public void loadItemCombo()
            doConnection();
            try{
                query ="select item_name from item_master";
                rs = stmt.executeQuery(query);
                while(rs.next())
                    cmbitem.addItem(rs.getString("item_name"));
            }catch(Exception e){ e.printStackTrace(); }
        private void btnAddnameActionPerformed(java.awt.event.ActionEvent evt)                                          
    // TODO add your handling code here:
            AddNewName n = new AddNewName();
            n.setVisible(true);
        private void btnAddActionPerformed(java.awt.event.ActionEvent evt)                                      
    // TODO add your handling code here:
            AddNewItem i = new AddNewItem();
            i.setVisible(true);
        private void menu1exitActionPerformed(java.awt.event.ActionEvent evt)                                         
            // TODO add your handling code here:
             System.out.println("Current :"+ day +":"+month+":"+year);
    }AddNewName.java
    * AddNewName.java
    * Created on October 13, 2007, 2:52 PM
    package app;
    import app.ExpTracker;
    import java.sql.*;
    import java.util.Vector;
    * @author  Administrator
    public class AddNewName extends javax.swing.JFrame
        /** Creates new form AddNewName */
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        String query;
        int status =0;
        String URL="jdbc:mysql://localhost:3306/exptracker";
        String DRIVER ="com.mysql.jdbc.Driver";
        public AddNewName()
            initComponents();
        public void doConnection()
            //make connection
            try
                Class.forName(DRIVER).newInstance();
            catch(Exception e)
            { System.out.println("driver not found"+e.getMessage());     }
            //making query
            try
                con = DriverManager.getConnection(URL, "root", "");
                stmt = con.createStatement();
            catch(Exception e)
            { System.out.println("Connection Failure !"+ e.getMessage());  }
        public void doInsert()
            String name2add = tfnameadd.getText().trim();
            query = "INSERT INTO name_master(name) VALUES ('"+name2add+"')";
            System.out.println("QUERY:"+query);
            try
               status = stmt.executeUpdate(query);
               //System.out.println("Query Status :"+status);
               //con.commit();
            } catch (SQLException ex)
                ex.printStackTrace();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jPanel1 = new javax.swing.JPanel();
            lblnewname = new javax.swing.JLabel();
            tfnameadd = new javax.swing.JTextField();
            btnaddname = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Add New Name"));
            lblnewname.setText("Enter Name :");
            tfnameadd.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnaddname.setText("Add Name");
            btnaddname.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnaddname.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnaddnameActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(btnaddname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 108, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jPanel1Layout.createSequentialGroup()
                            .add(lblnewname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(37, 37, 37)
                            .add(tfnameadd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 218, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(20, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblnewname)
                        .add(tfnameadd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(btnaddname, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                    .addContainerGap())
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        private void btnaddnameActionPerformed(java.awt.event.ActionEvent evt)                                          
    // TODO add your handling code here:
            ExpTracker et = new ExpTracker();
             doConnection();
             doInsert();
                if(status == 1)
                    javax.swing.JOptionPane.showMessageDialog(this,"Record Inserted Successfully.");
                    this.setVisible(false);
                    et.repaint();
                    et.reloadComboName();
                    //this.repaint();
                else
                    javax.swing.JOptionPane.showMessageDialog(this,"Record Failed to Insert.","Error",2);
         * @param args the command line arguments
        // Variables declaration - do not modify                    
        private javax.swing.JButton btnaddname;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JLabel lblnewname;
        private javax.swing.JTextField tfnameadd;
        // End of variables declaration                  
    }AddNewItem.java
    * AddNewItem.java
    * Created on October 13, 2007, 2:19 PM
    package app;
    import java.sql.*;
    import java.util.*;
    * @author  Administrator
    public class AddNewItem extends javax.swing.JFrame
        /** Creates new form AddNewItem */
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        String query;
        int status =0;
        String URL="jdbc:mysql://localhost:3306/exptracker";
        String DRIVER ="com.mysql.jdbc.Driver";
        public AddNewItem()
            super("Add New Item");
            initComponents();
        public void doConnection()
            //make connection
            try
                Class.forName(DRIVER).newInstance();
            catch(Exception e)
            { System.out.println("driver not found"+e.getMessage());     }
            //making query
            try
                con = DriverManager.getConnection(URL, "root", "");
                stmt = con.createStatement();
            catch(Exception e)
            { System.out.println("Connection Failure !"+ e.getMessage());  }
        public void doInsert()
            String item2add = tfadditem.getText().trim();
            query = "INSERT INTO item_master(item_name) VALUES ('"+item2add+"')";
            System.out.println("QUERY:"+query);
            try
               status = stmt.executeUpdate(query);
               //System.out.println("Query Status :"+status);
               //con.commit();
            } catch (SQLException ex)
                ex.printStackTrace();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jPanel1 = new javax.swing.JPanel();
            lblitemname = new javax.swing.JLabel();
            tfadditem = new javax.swing.JTextField();
            btnAddItem = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setAlwaysOnTop(true);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Add New Item"));
            lblitemname.setText("Item to add :");
            tfadditem.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnAddItem.setText("Add Item");
            btnAddItem.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnAddItem.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddItemActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .add(18, 18, 18)
                    .add(jPanel1Layout.createParallelGroup(org.jd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Window#toFront() does not activate JFrame

    Hello,
    I noticed that the method "Window#toFront()" is not enough to activate a JFrame that is hidden behind other windows/applications. So I imagined the following hack, but wonder if anyone knows about a better way:
    private Robot r;
            try {
                r = new Robot();
            } catch (AWTException ex) {
                ex.printStackTrace();
    private void activateWindow(JFrame frame) {
        frame.setAlwaysOnTop(true);
        frame.setAlwaysOnTop(false);
        Point location = MouseInfo.getPointerInfo().getLocation();
        Point locationOnScreen = frame.getLocationOnScreen();
        r.mouseMove(locationOnScreen.x+100, locationOnScreen.y+10);
        r.mousePress(InputEvent.BUTTON1_MASK);
        r.mouseRelease(InputEvent.BUTTON1_MASK);
        r.mouseMove(location.x, location.y);
    }The functionality is needed when clicking an icon in the notification area of the task bar. This should start the swing application only once. When the icon is clicked again, the started application should always activate its main window.
    Regards,
    André

    class SingleInstanceController {
        private boolean result = false;
        private File file = null;
        private ObjectOutputStream oos = null;
        private ObjectInputStream ois = null;
        private ServerSocket server = null;
        private Socket client = null;
        private ArrayList<ApplicationStartedListener> listener = null;
        private String appname = null;
        public SingleInstanceController(File file, String appname) {
            this.file = file;
            this.appname = appname;
            this.listener = new ArrayList<ApplicationStartedListener>();
        public SingleInstanceController(String appname) {
            this(new File(System.getProperty("java.io.tmpdir") + "/923jhakE53Kk9235b43.6m7"), appname);
        public void addApplicationStartedListener(ApplicationStartedListener asl) {
            this.listener.add(asl);
        public void removeApplicationStartedListener(ApplicationStartedListener asl) {
            this.listener.remove(asl);
        public boolean isOtherInstanceRunning() {
            if (!this.file.exists()) {
                return false;
            return sendMessageToRunningApplication(new ClassCheck(this.appname));
        public boolean sendMessageToRunningApplication(final Object obj) {
            this.result = false;
            try {
                this.client = new Socket("localhost", getPortNumber());
                // In einem neuen Thread kommunizieren, um einen Deadlock zu verhindern
                new Thread(new Runnable() {
                    public void run() {
                        try {
                            SingleInstanceController.this.oos = new ObjectOutputStream(SingleInstanceController.this.client.getOutputStream());
                            SingleInstanceController.this.ois = new ObjectInputStream(SingleInstanceController.this.client.getInputStream());
                            SingleInstanceController.this.oos.writeObject(obj);
                            SingleInstanceController.this.oos.flush();
                            SingleInstanceController.this.result = SingleInstanceController.this.ois.readBoolean();
                        } catch (IOException e) {
                            SingleInstanceController.this.result = false;
                }).start();
                for (int i = 0; i < 10; i++) {
                    if (this.result == true) {
                        break;
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                this.client.close();
                return this.result;
            } catch (IOException e) {
                return false;
        public boolean registerApplication() {
            try {
                if (!this.file.exists()) {
                    if (!this.file.getParentFile().mkdirs() && !this.file.getParentFile().exists()) {
                        return false;
                    if (!this.file.createNewFile()) {
                        return false;
                BufferedWriter wuffy = new BufferedWriter(new FileWriter(this.file));
                int port = getFreeServerSocket();
                if (port != -1) {
                    startServer();
                wuffy.write(String.valueOf(port));
                wuffy.close();
                return true;
            } catch (IOException e) {
                return false;
        protected void messageArrived(Object obj) {
            for (ApplicationStartedListener asl : this.listener) {
                asl.messageArrived(obj);
        protected void applicationStartet() {
            for (ApplicationStartedListener asl : this.listener) {
                asl.applicationStarted();
        protected void foreignApplicationStarted(String name) {
            for (ApplicationStartedListener asl : this.listener) {
                asl.foreignApplicationStarted(name);
        private int getPortNumber() {
            try {
                BufferedReader buffy = new BufferedReader(new FileReader(this.file));
                int port = Integer.parseInt(buffy.readLine().trim());
                buffy.close();
                return port;
            } catch (Exception e) {
                return -1;
        private void startServer() {
            new Thread(new Runnable() {
                public void run() {
                    while (true) {
                        try {
                            SingleInstanceController.this.client = SingleInstanceController.this.server.accept();
                            if (SingleInstanceController.this.client.getInetAddress().isLoopbackAddress()) {
                                new Thread(new Runnable() {
                                    public void run() {
                                        try {
                                            SingleInstanceController.this.oos = new ObjectOutputStream(SingleInstanceController.this.client.getOutputStream());
                                            SingleInstanceController.this.ois = new ObjectInputStream(SingleInstanceController.this.client.getInputStream());
                                            Object obj = SingleInstanceController.this.ois.readObject();
                                            if (obj instanceof ClassCheck) {
                                                if (obj.toString().equals(SingleInstanceController.this.appname)) {
                                                    SingleInstanceController.this.oos.writeBoolean(true);
                                                    applicationStartet();
                                                } else {
                                                    SingleInstanceController.this.oos.writeBoolean(false);
                                                    foreignApplicationStarted(obj.toString());
                                            } else {
                                                messageArrived(obj);
                                                SingleInstanceController.this.oos.writeBoolean(true);
                                            SingleInstanceController.this.oos.flush();
                                            SingleInstanceController.this.client.close();
                                        } catch (IOException e) {
                                            e.printStackTrace();
                                        } catch (ClassNotFoundException e) {
                                            e.printStackTrace();
                                }).start();
                        } catch (IOException e) {
                            e.printStackTrace();
            }).start();
        private int getFreeServerSocket() {
            for (int i = 2000; i < 10000; i++) {
                try {
                    this.server = new ServerSocket(i);
                    return i;
                } catch (IOException ignore) {
            return -1;
    }

  • Question about the result of calling JDialog.setAlwaysOnTop(true)

    Let's use these two small code snippets for reference.
    Sample 1
    JDialog d = new JDialog(myFrame, "Dialog Title");
    d.setModal(true);
    d.setAlwaysOnTop(true);
    d.setVisible(true);Sample 2
    JDialog d = new JDialog(myFrame, "Dialog Title");
    d.setModal(true);
    d.setVisible(true);Using #1 I get a modal dialog that is on top of ALL other windows, even things like Firefox and Thunderbird (two greats apps).
    Using #2 I get a modal dialog that is not on top of other apps when the other apps gain focus.
    I would like to avoid using #1 so I don't annoy my users with popup windows that are always on top of other app windows. However, if I use #2, sometimes the modal dialog can "fall behind" it's parent frame, making it very difficult to ever get back. Since the parent frame (myFrame) is waiting on a modal dialog to close, the frame is not movable or minimizable. The modal dialog is hidden behind the parent frame, which makes it hard to get unless I do something like Alt-Tab to cycle through the current open windows. I can't expect my users to know or use the Alt-Tab capability.
    Any suggestions?

    I found the problem. I wasn't passing in 'myFrame' as an argument. This resulted in a modal dialog that had no parent frame. That allows the dialog to fall behind the main application frame. So, as long as the parent frame is specified, the problem situation I described can't happen.

  • Issue expanding SIT files on MS Windows

    Some MS Windows users may be unable to decompress SIT files. Please post files as SITX or ZIP instead; and repost any existing SIT files as SITX or ZIP.
    Thanks!
    Adobe User to User forums.

    You can try to play with setAlwaysOnTop.
    Try something like:
    frame.setAlwaysOnTop(true);
    frame.setAlwaysOnTop(false);
    frame.toFront();

  • Window that cannot be minimized

    HI,
    I want to create a window that cannot be minimized, it should always be in focus.
    I tried setAlwaysOnTop(true), but user can minimize this using WINDOWS KEY + D.
    If window is deactivated/deiconified i want it to reactivate/iconify.
    I have few querries (OS Windows).
    1) Is it possible to disable/access system commands programmatically using Java?
    2) If window is inactive or has lost focus how can it be re-activated and gain focus.
    3) Is it possible to disable task manager programatically.
    If this cannot be accomplished using Java APIs, then is it possible to achieve my requirement using native methods,
    if this is the senerio plz provide some link to the required knowledge base.
    Thanks,
    Prashant

    d32 wrote:
    HI,
    I want to create a window that cannot be minimized, it should always be in focus.if it's a JDialog, you can use setModal(true)
    >
    I tried setAlwaysOnTop(true), but user can minimize this using WINDOWS KEY + D.
    If window is deactivated/deiconified i want it to reactivate/iconify.
    I have few querries (OS Windows).
    1) Is it possible to disable/access system commands programmatically using Java?try adding a keyListener that overrides windows keys. set WINDOWS KEY + D to bring your window to front.
    >
    2) If window is inactive or has lost focus how can it be re-activated and gain focus.i wouldn't want to do it, but add a focus listener on your window. if the window loses focus, give it focus again.

  • "Always on TOP"option for my window

    Hi All
    I am developing an application in which I wanted to develop a facility for enabling "always stay on top" to one of the windows .How can I do this.
    Thanks in advance
    Haritha

    I solved this problem using JNI, and I think that is the only way to allow the "Alwasy on Top" option. Here's how I did it.
    1. Create an extension of JFrame or JDialog or JWindow, whatever you want.
    2. Add the native method setAlwaysOnTop()
    import java.awt.*;
    import javax.swing.*;
    public class MyFrame extends JFrame {
    static { System.loadLibrary("MyFrame"); }
    public MyFrame() {
    super();
    public void setAlwaysOnTop(boolean b) {
    int hwnd = getNativeWindowHandle(this);
    seteAlwaysOnTop(hwnd, b);
    private native int getNativeWindowHandle(Window window);
    private native void setAlwaysOnTop(int hwnd, boolean flag);
    *NOTE the getNativeWindowHandle method is required to manipulate the frame in native code
    **NOTE I will take about the static { System.loadLibrary("MyFrame"); }
    at the end.
    3. Compile your code.
    4. Next you must create a c or c++ source file, name it whate every you want, and then define the setAlwaysOnTop method.
    Heres the code for the native file.
    #include <jni.h>
    #include <jawt.h>
    #include <afxwin.h>
    #include <windows.h>
    #include "MyFrame.h"
    #include "jawt_md.h"
    JNIEXPORT jint JNICALL
    Java_MyFrame_getNativeWindowHandle(JNIEnv *env, jobject jobj, jobject window)
    JAWT awt;
    awt.version = JAWT_VERSION_1_3;
    jboolean result = JAWT_GetAWT(env, &awt);
    if (result == JNI_FALSE)
    return 0;
    JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, window);
    if (ds == 0)
    return 0;
    jint lock = ds->Lock(ds);
    if ((lock & JAWT_LOCK_ERROR) != 0)
    return 0;
    JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
    if (dsi != 0)
    return 0;
    JAWT_Win32DrawingSurfaceInfo* dsiwin = (JAWT_Win32DrawingSurfaceInfo*) dsi->platformInfo;
    jint ret = reinterpret_cast<jint>(dsiwin->hwnd);
    ds->FreeDrawingSurfaceInfo(dsi);
    ds->Unlock(ds);
    awt.FreeDrawingSurface(ds);
    return ret;
    JNIEXPORT void JNICALL
    Java_MyFrame_windowAlwaysOnTop(JNIEnv *env, jobject jobj, jint hwnd, jboolean flag)
    if (flag)
    SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
    else
    SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
    *NOTE say your class MyFrame is in the package com.me.swing then the method prototype would look like this:
    JNIEXPORT void JNICALL
    Java_com_me_swing_MyFrame_windowAlwaysOnTop(JNIEnv *env, jobject jobj, jint hwnd, jboolean flag)
    5. you may have noticed the #include "MyFrame.h" line, well that is generated by the javah command. So, next run javah on your MyFrame.class file. you will have to look at the options to configure the command to do what you want, but essentially "javah MyFrame.class".
    6. Make sure your MyFrame.h file and MyFrame.c or MyFrame.cpp file is in the same directory and compile them into an object file. Now you will have to figure out how to do this on your own. First you must get a c++ compiler, I use Visual C++ form Microsoft. If you are using that then
    here is the command line
    cl -Ic:\j2sdk1.4.0\include -Ic:\j2sdk1.4.0\include\win32 /c -LD
    -IMyFrame.h MyFrame.cpp
    Execute this command from the directory where you MyFrame.h and MyFrame.cpp files are or you will have to specify their paths.
    the -Ic:\j2sdk1.4.0\include -Ic:\j2sdk1.4.0\include\win32 provide path information to include the jni.h and jawt.h files.
    7. Now you will have to link the object file with the jawt.lib file and create the final dll. Again you will have to figure how to do this, but with VC++ the command is.
    link /DLL MyFrame.obj c:\j2sdk1.4.0\lib\jawt.lib
    Now you should 8 have files
    MyFrame.java
    MyFrame.class
    MyFrame.h *created form javah
    MyFrame.cpp
    MyFrame.obj *created from compiling
    MyFrame.exp *created from compiling
    MyFrame.lib *created from compiling
    MyFrame.dll *created from linking
    You are done, now create a main class and instanciate and test your new frame.
    **REMEBER the static { System.loadLibrary("MyFrame"); } line in your MyFrame.java file. This loads your newly created dll into the system so you can access it.
    **IMPORTANT THE MyFrame.dll AND THE MyFrame.class FILE MUST BE IN THE SAME DIRECTORY, OR SPECIFY IT IN THE System.loadLibrary METHOD CALL.

  • DIsappearing window picture and folder content ?

    Hi,
    From time to time, I notice that some of my windows background picture is converted to a black coloured backgroun (in icon mode) and some of my folders (less than 50 files in total) in all view mode, become empty: viewing them using a3rd party sometimes reveal the files, or by disk utility as well.
    SOmetimes I restart and everything is back.
    I have just repaired permission using the OS X CD, shut down for good measure etc...
    Anybody with similar experience?
    I have 2 x attached firewire drives and lots of memory.
    Any idea?
    Thx,
    JP.

    I understand that I didn't set the tags to display my code properly - I'm sorry, I didn't know about it... But I don't quite understand what else I've done wrong. Let me rephrase my question:
    I'm trying to print a maze on screen using a JFrame object. Unfortunately, when I run the program (and quit it properly after each time), one of the following happens:
    a) The maze is printed correctly.
    b) The maze appears for less than a second, then disappears leaving a blank JFrame window.
    c) The JFrame window remains blank (which may be the same thing as b, only the maze flashes by too fast for me to notice).
    I've gone through a few JFrame tutorials, and I think I've followed the general guidelines. I tried looking for help at other sources - to see if anyone else had trouble with their Jframe content being displayed only sometimes. I even tried setting the Jframe object to always appear on top, but it didn't help. Since I've little experience with coding in Java, I was wondering if someone could please help me by telling me if I'm doing something wrong?
    Here's my code:
    public class Test extends JFrame
      public static void main(String argv[])
        JFrame test = new JFrame("nuts");
        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        test.setSize(700, 700);
        Container content = test.getContentPane();
        test.setVisible(true);
        test.setAlwaysOnTop(true);
        // create object called 'maze' here
        maze.paint(content.getGraphics());
    }I don't mean to be rude or anything; nor do I rightly understand what I've done wrong. I'm not trying to leech off anyone; I've honestly tried to figure this out, and I can't. So I'm really hoping someone can please help me. Thank you!

  • Disappearing Window Content - please help?

    Hi,
    I'm not very familiar with Java at all, but I have to use it for an assignment, part of which involves randomly generating a maze and displaying it on the screen. I use a JFrame object for displaying.
    However, sometimes when I run the program, the maze appears for less than a second, then disappears leaving a blank frame. At other times, the frame is completely empty. And sometimes, the maze is displayed the way it should be (this usually happens after a fresh recompiling). My code runs thus:
    public class Test
    public static void main(String argv[])
    JFrame test = new JFrame("nuts");
    test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    test.setSize(700, 700);
    Container content = test.getContentPane();
    test.setVisible(true);
    // creating maze object called 'maze' here
    maze.paint(content.getGraphics());
    Here is my paint method:
    public void paint (Graphics g) {
    int x, y;
    for (x = 1; x < 24; ++x)
    for (y = 1; y < 39; ++y) {
    if ((maze[x][y] & 1) != 0) /* This cell has a top wall */
    g.drawLine (x * 10, y * 10, x * 10 + 10, y * 10);
    if ((maze[x][y] & 2) != 0) /* This cell has a bottom wall */
    g.drawLine (x * 10, y * 10 + 10, x * 10 + 10, y * 10 + 10);
    if ((maze[x][y] & 4) != 0) /* This cell has a left wall */
    g.drawLine (x * 10, y * 10, x * 10, y * 10 + 10);
    if ((maze[x][y] & 8) != 0) /* This cell has a right wall */
    g.drawLine (x * 10 + 10, y * 10, x * 10 + 10, y * 10 + 10);
    Can anyone please explain to me why my content disappears at times, and is displayed at others? I am in sore need of help, and would be very grateful if someone could give me a hint... If I'm doing something stupid here, my apologies in advance.
    Thanks.
    MM.

    I understand that I didn't set the tags to display my code properly - I'm sorry, I didn't know about it... But I don't quite understand what else I've done wrong. Let me rephrase my question:
    I'm trying to print a maze on screen using a JFrame object. Unfortunately, when I run the program (and quit it properly after each time), one of the following happens:
    a) The maze is printed correctly.
    b) The maze appears for less than a second, then disappears leaving a blank JFrame window.
    c) The JFrame window remains blank (which may be the same thing as b, only the maze flashes by too fast for me to notice).
    I've gone through a few JFrame tutorials, and I think I've followed the general guidelines. I tried looking for help at other sources - to see if anyone else had trouble with their Jframe content being displayed only sometimes. I even tried setting the Jframe object to always appear on top, but it didn't help. Since I've little experience with coding in Java, I was wondering if someone could please help me by telling me if I'm doing something wrong?
    Here's my code:
    public class Test extends JFrame
      public static void main(String argv[])
        JFrame test = new JFrame("nuts");
        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        test.setSize(700, 700);
        Container content = test.getContentPane();
        test.setVisible(true);
        test.setAlwaysOnTop(true);
        // create object called 'maze' here
        maze.paint(content.getGraphics());
    }I don't mean to be rude or anything; nor do I rightly understand what I've done wrong. I'm not trying to leech off anyone; I've honestly tried to figure this out, and I can't. So I'm really hoping someone can please help me. Thank you!

  • How to setAlwaysOnTop for Dialog?

    Hi everybody,
    I cannot setAlwaysOnTop for Dialog. Dialog class extend from Window class and setAlwaysOntop() is method in Window class. Why is it not work? Who can help me to fix this problem? Or suggest other way for set the Dialog to alway on top.
    import java.awt.*;
    public class DialogAeh {
    public static void main(String[] args)      {
              Frame fr = new Frame("Event Demo");
              Dialog d = new Dialog(fr,"DialogTest",true);
              d.setBounds(0,400,600,200);
              d.setVisible(true);          
              fr.setAlwaysOnTop(true);          
    Thanks,
    Aeh.

    Gevaudan&Torgil,
    Thank you very much for your help.
    I have already found the bug in my code.
    Set visible should set after set always-on-top.
    d.setAlwaysOnTop(true);
    d.setVisible(true);
    Aeh.

Maybe you are looking for

  • Going to Australia and need help with Power converters

    Facts: US uses 110v on 60hz Australia 220v on 50hz Making sure I understood that correctly.  Devices I plan on bringing that will use power are PS3 Slim, MacBook Pro 2008 model, and WD 1TB External HDD.  My DS, and Cell are charging via USB to save t

  • Open item account line with flow type has to contain a partner

    Hi, I am getting the following error while doing periodic posting in flexible real estate management. " Open item account line with flow type Z240 has to contain a partner" " Open item account line with flow type Z820 has to contain a partner" Messag

  • Playlist on iPhone 6 plus disappeared

    For some reason, the other day I went to play some music on my playlists and they were all gone. These are playlists I created on my iPhone NOT on my computer in iTunes. Just directly on my phone. I have it backed up to iCloud. I tried restoring, no

  • CONVERSION LOGIC

    Hi Gurus, cau you help me how to write logic for below problem BOTTLEAMOUNT CAUFVD-MATNR  CHAR 18 BUT  LAST TWO DIGITS OF THE MATERIAL SHOULD BE CONVERTED TO A SINGLE DIGIT WHERE APPLICABLE AND CONCATENATED WITH A  "C" EX: 0986-03456-01 01 = 1C THEN

  • Can't empty trash on a few files. Permissions?

    Good Day. I am logged in as Admin (Only acct on this machine) and there are several files in the trash that will not allow me to empty. None of which are in use. Tells me I don't have the permission to empty/delete which I do. Can someone please advi