Jframe on top

how to make my jframe always on top and active window
pl help us

This question is asked weekly. Learn how to search the forum before posting questions. A good place to start is to search for the phrase "always on top".

Similar Messages

  • Putting my Seconf JFrame on Top of First ...

    hi
    my application has a main JFrame and once a button on that JFrame is clicked ... another JFRame is opened ...
    My problem is that i want my second JFrame on top of the first JFrame .. but what is happeining is that the seconf JFrame goes on the background .. I have to minimize the first JFrame and then the second JFrame becomes visible ..
    Plz help me out so that my second JFrame automatically comes on top of the first JFrame,

    But i m doind a lot of Database stuff retrieving values and updating DB from there in second JFrame ..
    n i have to use the JFrame as it has 6 buttons, 4 combos, 5 JTextFields,,,,,
    i have gone through the docs but did not find any property which will set THe second JFrame on top ..

  • How to keep Allways JFrame on top of JApplet?

    I have Japplet runs on the client side. after pressing buton on the applet
    a jframe pops up. but if i click on the japplet it hides under japplet.
    Any ways to keep this jframe on the top ? if i use jframe.keep always on the top will thought security exception. I know applets have some security issue to access local OS resources or permission. just need to know any possibitly to achive this somehow?
    thnx

    I don't think this is possible. Others feel free to correct me. Perhaps try signing the applet or setting the permissions in the policy file.
    You can use a JInternalFrame to keep the frame within the JApplet.

  • Keeping a Jframe on top of an applet on a webserver.

    Hi
    I am developing an applet, which must display a Jframe, when somebody clicks on a JPanel. The JFrame must always be on top of the applet. I've tried to use both the .setAlwaysOnTop and .toFront when the window is deactivated.
    The applet is running on a boa webserver, which is running on a PowerPc with uClibc. When I click on the JPanel the JFrame does not display. The Java console issues a Java.security exception saying that setAlwaysOnTop is not allowed.
    I think I need to sign the applet. When I do this is can run the applet locally giving no problems, but when I do it on the web server I get the exception again. What am I doing wrong? Should I pass something along with the applet, like a cerficate or something?
    Hope that anyone can help me...
    Regards Lars

    1) Have you gone through the Sun Swing tutorials on how to create and show JFrames?
    2) Usually when an app shows another window, that second window is a dialog such as a JDialog. Once you get your code working, you may wish to consider this.
    3) If your app isn't too large, you may wish to post your code here -- with code tags of course. If it is too large, then you would do well to whittle it down to a smaller size, enough to compile and show your problem.
    4) If you are using NetBeans to generate your Swing code, I advise you to not do this, to first learn how to code Swing before trying to use this tool.
    Good luck.

  • JFrame on top - PROBLEM with parent FRAME

    Hello,
    I have tried every possible way to keep a JFrame or JDialog on top of my Main JFrame and it works.The problem is that the Main panel has limited functionality.For example I can change the tabs but I cannot press a button.It looks like it selects the button but the action never happens.
    I tried the "Thread- toFront()" way and the window "Deactivated-toFront()" way.
    I should mention that the new Frame is constructed and shown not from my MainFrame but in a custom ActionListener for a popup menu on a JTree.
    The code is extremly big to post it and I don't know which part could help you because there is no ecxeption or something like that.
    I don't see any people complaining,is it only me with that problem?
    ANY IDEAS??

    This works for me:
    CommandPanel d = new CommandPanel(this, "Command Panel", false);
    d.pack();
    d.show();
    That only works though when I use a button form my main Frame.So i pass the "this" parent and averything is ok.BUT what I have do is:
    I Have my main Frame, I have a tree in my main frame,I have a custom mouse listener on the tree to pop up a menu.If the user selects the last option "Show command Panel" then the menuAction class,which is a custom actionListener as follows
    class MenuAction implements java.awt.event.ActionListener {
    public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Show Commands Panel")){
    CommandPanel d = new CommandPanel(this, "Command Panel", false);//Error here."this" is not a Frame.Only a class that implements an ActionListener.
    d.pack();
    d.show();
    System.out.println("Clicked "+ e.getActionCommand());
    How can from inside the MenuAction class construct my commandPanel and pass in the constructor the main Frame??

  • Call method after closing JFrame

    Hi everyone,
    I'm opening a JFrame in another JFrame.
    Here is the code and beneath is the question.
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    public class ContactsInterface extends JFrame implements ActionListener
         JList contactList;
         private DefaultListModel listModel;
         JPanel buttonPanel;
         JPanel detailsPanel;
         JButton addButton, updateButton, deleteButton, refreshButton;
         JLabel companyLabel;
         JTextField companyField;
         public ContactsInterface()
              super("ContactList");
              listModel = new DefaultListModel();
              contactList = new JList(listModel);
              buttonPanel = new JPanel();
              detailsPanel = new JPanel();
              addButton = new JButton("Add Record");
              addButton.addActionListener(this);
              updateButton = new JButton("Update Record");
              updateButton.addActionListener(this);
              deleteButton = new JButton("Delete Record");
              deleteButton.addActionListener(this);
              refreshButton = new JButton("Refresh");
              refreshButton.addActionListener(this);
              companyLabel = new JLabel(" Company:");
              companyField = new JTextField(10);
              companyField.setEditable(false);
              buttonPanel.setLayout(new FlowLayout());
              detailsPanel.setLayout(new GridLayout(6,2,10,10));
              buttonPanel.add(addButton);
              buttonPanel.add(updateButton);
              buttonPanel.add(deleteButton);
              buttonPanel.add(refreshButton);
              detailsPanel.add(companyLabel);
              detailsPanel.add(companyField);
              setLayout(new BorderLayout());
              JScrollPane contactJScroll = new JScrollPane();
              contactJScroll.setPreferredSize(new Dimension(100,80));
              contactJScroll.getViewport().setView(contactList);
              add(contactJScroll, BorderLayout.WEST);
              add(buttonPanel, BorderLayout.SOUTH);
              add(detailsPanel, BorderLayout.CENTER);
         public void actionPerformed(ActionEvent e)
              String args = e.getActionCommand();
              if(args.equals("Add Record"))
                   openAddRecord();
         public static void main(String args[])   //main method of the ContactsInterface
              ContactsInterface CInterface = new ContactsInterface();
              CInterface.setJMenuBar(CInterface.createMenuBar());
              CInterface.setDefaultCloseOperation(EXIT_ON_CLOSE);
              CInterface.setSize(500,300);
              CInterface.setVisible(true);
              CInterface.setResizable(false);
         public void openAddRecord() // The method being called when clicking Add record which in turn opens another JFrame on top of the ContactsInterface  JFrame
              record = new AddRecord();
              record.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              record.setVisible(true);
              record.setResizable(false);
              record.setSize(400,300);
         public void refreshList(String company)  //The method that needs to be called when disposing of the openAddRecord JFrame
              listModel.addElement(company);
              int index;
              index = contactList.getLastVisibleIndex();
              index++;
              contactList.setSelectedIndex(index);
              contactList.ensureIndexIsVisible(index);
         }The "openAddRecord Frame" opens fine, in the "openAddRecord JFrame" I add a company name.
    How can I when I click on the "Save" button in the "openAddRecord JFrame" and then dispose(); of the "openAddRecord JFrame" let it call a method in the "ContactsInterface JFrame" which was the parent of "openAddRecord JFrame" / were the "openAddRecord JFrame" was opened in, to refresh the JList by calling the "refreshList" method.

    Don't use multiple JFrames.
    A typical application will only ever have a single JFrame. If you need a second window you would use a JDialog. If you want to stop execution until the dialog is closed then you would use a "modal" JDialog.

  • Making JFrame active

    I have a JFrame and I bring it toFront with native code because else it didn't work. But the JFrame is not active if the Programm which started my Application loses the Focus before my window is being displayed. I also tried the native C++ function CWnd::SetActiveWindow and other members of CWnd but the don't activate the window, although it's on top.
    Please help me!

    All these things make it just flashing in the taskbar.
    I now used the C++ function ::GetCursorPos(LPPOINT) to
    find out the mouse position via JNI and then I used
    java.awt.Robot to click on my JFrame and then move the mouse back.
    So all what I needed was JNI, no java method was invoked besides
    the java.awt.Robot's mouseMove/Press/Release. Everything
    is now done by JNI. First the window is brought to top:
    SetWindowPos(... topmost)
    SetWindowPos(... nottopmost)
    then
    GetCursorPos gets the mouse coordinates
    then the Robot clicks on the window
    Now I can have the JFrame on top and active whenever I want it to, but
    it is platformdependent and the Robot could raise AWTExceptions.
    So, If someone knows a working platformindependet solution that
    is "errorsave" please
    post it and you'll get all the remaining duke dollars.
    Thanks in advance!

  • Please help really urgent

    I have a small JFrame on top of another JFrame which covers the
    entire comp screen. In the smaller JFrame I have a JMenuBar;
    once u click on the JMenu I would like for the menu to open and
    diplay itself completely without having to resize the frame.
    Something which im unable to do now the menu ends at the boundaries of the JFrame and the user would have to resize the screen. Can someone help please im really stuck

    A wild guess: Are you mixing Swing and AWT? I experienced exactly what you describe when I had a JFrame containing AWT components.

  • Problem in refreshing JTree inside Jscrollpane on Button click

    hi sir,
    i have problem in refreshing JTree on Button click inside JscrollPane
    Actually I am removing scrollPane from panel and then again creating tree inside scrollpane and adding it to Jpanel but the tree is not shown inside scrollpane. here is the dummy code.
    please help me.
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.tree.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    public class Test
    public static void main(String[] args)
         JFrame jf=new TestTreeRefresh();
         jf.addWindowListener( new
         WindowAdapter()
         public void windowClosing(WindowEvent e )
         System.exit(0);
         jf.setVisible(true);
    class TestTreeRefresh extends JFrame
         DefaultMutableTreeNode top;
    JTree tree;
         JScrollPane treeView;
         JPanel jp=new JPanel();
         JButton jb= new JButton("Refresh");
    TestTreeRefresh()
    setTitle("TestTree");
    setSize(500,500);
    getContentPane().setLayout(null);
    jp.setBounds(new Rectangle(1,1,490,490));
    jp.setLayout(null);
    top =new DefaultMutableTreeNode("The Java Series");
    createNodes(top);
    tree = new JTree(top);
    treeView = new JScrollPane(tree);
    treeView.setBounds(new Rectangle(50,50,200,200));
    jb.setBounds(new Rectangle(50,300,100,50));
    jb.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
              jp.remove(treeView);
              top =new DefaultMutableTreeNode("The Java ");
    createNodes(top);
              tree = new JTree(top);
                   treeView = new JScrollPane(tree);
                   treeView.setBounds(new Rectangle(50,50,200,200));
                   jp.add(treeView);     
                   jp.repaint();     
    jp.add(jb);     
    jp.add(treeView);
    getContentPane().add(jp);
    private void createNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode category = null;
    DefaultMutableTreeNode book = null;
    category = new DefaultMutableTreeNode("Books for Java Programmers");
    top.add(category);
    book = new DefaultMutableTreeNode("The Java Tutorial: A Short Course on the Basics");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Tutorial Continued: The Rest of the JDK");
    category.add(book);
    book = new DefaultMutableTreeNode("The JFC Swing Tutorial: A Guide to Constructing GUIs");
    category.add(book);
    book = new DefaultMutableTreeNode("Effective Java Programming Language Guide");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Programming Language");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Developers Almanac");
    category.add(book);
    category = new DefaultMutableTreeNode("Books for Java Implementers");
    top.add(category);
    book = new DefaultMutableTreeNode("The Java Virtual Machine Specification");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Language Specification");
    category.add(book);
    }

    hi sir ,
    thaks for u'r suggession.Its working fine but the
    properties of the previous tree were not working
    after setModel() property .like action at leaf node
    is not working,I'm sorry but I don't understand. I think you are saying that the problem is solved but I can read it to mean that you still have a problem.
    If you still have a problem then please post some code (using the [code] tags of course).

  • My question about second INTERFACE DESIGN

    i create one interface( main interface created by JFRAME)
    in main interface i want to click button
    then create second interface.
    i should use which class to build second interface?
    i tried JFrame but it doesnot work
    JFrame is top cotainer .and it need main() also
    thanks in advance
    please give some hints

    i tried JFrame but it doesnot work - JFrame is top cotainer .and it need main() alsoThat's not true - you can create a JFrame instance without it having its own main() method.
    When the user clicks the button, do this:JFrame secondFrame = new JFrame("Second Frame");
    secondFrame.add(....whatever you need to add to it - JPanels etc...);
    secondFrame.setBounds(100,100,400,300);
    secondFrame.show();

  • Drawing window borders swing look and feel

    Does anyone know how to change the frame window border from being drawn in the windows look and feel? I want them to be drawn as a swing application. Can anyone help?

    Frames (and JFrames) are top-level containers that are not subject to rendering by the Look-and-Feel manager (they are actually "heavy-weight" native components). However, in 1.4 it is possible to use an undecorated frame (using Frame.setUndecorated(true)) which you could paint to look like a JInternalFrame. However, I think you lose the automatic handling of resizing, moving, iconifying, maximizing, closing, etc.

  • JTree stored as XML

    Portion of my java source code based on Jtree is given below.
    public class myMutableTreeNode extends DefaultMutableTreeNode
    // tree nodes rendered as JTable
    public myWin extends Jframe()
    // constructor
    top = new myMutableTreeNode();
    jTree1=new JTree(top);
    // nodes are added to tree and rendered as jtable
    // On �save� menu option, I want to save this Jtree1 using XML and later retrieve on �open� command.
    if (e.getActionCommand() == "Save")
    XMLEncoder encoder = new XMLEncoder( new BufferedOutputStream(new FileOutputStream( "sample.xml" ) ));
    DefaultTreeModel c = (DefaultTreeModel)jTree1.getModel();
    encoder.writeObject(c);
    encoder.close();
    But it did not work as I expected. Will anybody say what I am doing wrong and help to solve this problem?
    Thanks.

    Well, if you can't be bothered to post syntactically correct code, I'd be surprised if anyone takes the trouble to give a good response.
    In fact, to get better help sooner, post a SSCCE that clearly demonstrates your problem.
    To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    db

  • How to make a jframe or jdialog on top of all other applications

    I just want to know if there a way to make a jframe or jdialog on top of an application like games?
    Thanks in advance...

    Try searching the forum?

  • Forcing a JFrame to the top of the WIndows Desktop

    How do I force a JFrame to be displyed on top of everything else on the Windows desktop, i.e., a Java program running in the background needs to "pop-up" an error JFrame arbitrarily on top of anything else that is displayed.

    I'd search the forums, but I think the only way that this can truly be accomplished is through JNI. If you search for "always on top"+"JNI", I think a couple of people actually created some C classes that will do this.
    James

  • JDialog on top of full screen JFrame disappears

    I have a problem with a JDialog on top of a full screen JFrame, namely the JDialog kind of disappears when displayed (it bleeds through). I use JRE 1.6.0_03 on Windows. This does not happen under the same version on Linux. I'm attaching the code below.
    Test.java:
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class Test extends JFrame {
         public Test() {
              final Test frame = this;
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              JButton button = new JButton("Open dialog");
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent arg0) {
                        new TestDialog(frame);
              add(button);
              if (!isDisplayable()) {
                   setUndecorated(true);
              pack();
              setVisible(true);
         private static void createAndShowGui() {
              GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
              gd.setFullScreenWindow(new Test());
         public static void main(String[] args) throws Exception {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGui();
    }And TestDialog.java:
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    public class TestDialog extends JDialog {
         public TestDialog(JFrame frame) {
              super(frame);
              add(new JTextField("test"));
              setModal(true);
              pack();
              setVisible(true);
    }Any ideas why this is happening and how can I solve it? Thanks.

    I dont know if it works for you but, changing the createAndShowGui function
    (and so changing the way we make it fullscreen) as:
    private static void createAndShowGui() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Test testFrame = new Test();
    testFrame .setBounds(0,0,screenSize.width, screenSize.height);
    }worked for me.
    (java.awt.Dimension and java.awt.Toolkit must be imported for this by the way.)
    I tried also decreasing the hardware acceleration and it worked, too.
    Edited by: Kaan_Ceylan on Nov 16, 2008 5:33 PM

Maybe you are looking for

  • To get Current Page No. at Report 6i Runtime

    Hi to everybody, I wish to know how can i get the current pageno at runtime in report 6i , i want to display data at end page of the report on a condition that it is the last page of the report. i can get the last page but not the current page no at

  • ACE 4710 - Internet Explorer cannot display the webpage randomly

    We have a ACE 4710 with a basic config, (see below). When clicking on a tab from a window within Interent explorer we occasionally get an issue with it returning: "Internet Explorer cannot display the webpage" The details show "Access is denied" acce

  • [SOLVED] Package-Query build error

    I'm trying to get my new Arch system setup, and I'm having trouble getting Yaourt installed. I can't seem to get package-query to build successfully. I have base-devel installed, and I've followed the instructions in the wiki on installing AUR packag

  • Weird Langugue Issue

    Hello. I have a very strange problem that came out of no where. My computer is running fine but, when I select "about this mac" to get system info there is a strange language issue. It only happens when I select "more info". The text switched to Japa

  • Which CS4 preset handles 720p60 best?

    The footage was shot on a Panasonic HVX-200p camera at 720p60. Which preset or customized sequence settings will handle this footage best in PP? The clips come in from OnLocation at 960x720. Final output desired is a 16:9 DVD.