How to open a new window from the login window?

hi,
can someone tell me how to open a new window from an existing window, here by window i mean frame. The case is i hv two java files - oracle.java and FDoptions.java. The first frame is in the Login.java. The oracle.java file has a button "Login", when it is clicked, i want to open the next frame which is in the file FDoptions.java. Can some one help me with this? I m giving the code below -
oracle.java
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
* The application's main frame.
public class oracle {
    private JFrame frame;
    private JPanel logInPanel;
    private JButton clearButton;
    private JButton logInButton;
    private JButton newuserButton;
    private JButton forgotpasswordButton;
    private JTextField userNameTextField;
    private JPasswordField passwordTextField;
    public oracle() {
        initComponents();
    private final void initComponents() {
        JLabel userNameLabel = new JLabel("User name: ");
        JLabel passwordLabel = new JLabel("Password: ");
        userNameTextField = new JTextField();
        passwordTextField = new JPasswordField();
        JPanel userInputPanel = new JPanel(new GridLayout(2, 2, 5, 5));
        userInputPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
        userInputPanel.add(userNameLabel);
        userInputPanel.add(userNameTextField);
        userInputPanel.add(passwordLabel);
        userInputPanel.add(passwordTextField);
        logInButton = new JButton(new LogInAction());
        clearButton = new JButton(new ClearAction());
        newuserButton = new JButton(new NewUserAction());
        forgotpasswordButton = new JButton(new ForgotPassword());
        JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        JPanel buttonPanel1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttonPanel.add(logInButton);
        buttonPanel.add(clearButton);
        buttonPanel1.add(newuserButton);
        buttonPanel1.add(forgotpasswordButton);
        logInPanel = new JPanel(new BorderLayout());
        logInPanel.add(userInputPanel, BorderLayout.NORTH);
        logInPanel.add(buttonPanel, BorderLayout.CENTER);
        logInPanel.add(buttonPanel1,BorderLayout.SOUTH);
        frame = new JFrame("FD Tracker");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500, 500);
        frame.setContentPane(logInPanel);
        frame.pack();
        frame.setVisible(true);
    private void performLogIn() {
        // Log in the user
        System.out.println("Username: " + userNameTextField.getText());
        char[] password = passwordTextField.getPassword();
        System.out.print("Password: ");
        for(char c : password) {
            System.out.print(c);
        System.out.println();
    private void performClear() {
        // Clear the panel
        System.out.println("Clearing the panel");
        userNameTextField.setText("");
        passwordTextField.setText("");
    private final class LogInAction extends AbstractAction {
        public LogInAction() {
            super("Log in");
        @Override
        public void actionPerformed(ActionEvent e) {
            performLogIn();
    private final class ClearAction extends AbstractAction {
        public ClearAction() {
            super("Clear");
        @Override
        public void actionPerformed(ActionEvent e) {
            performClear();
    private final class NewUserAction extends AbstractAction{
         public NewUserAction(){
             super("New User");
         @Override
         public void actionPerformed(ActionEvent e){
             JFrame newuser = new JFrame("NewUser");
    private final class ForgotPassword extends AbstractAction{
        public ForgotPassword(){
            super("Forgot Password");
        @Override
        public void actionPerformed(ActionEvent e){
            JFrame forgotpassword = new JFrame("Forgot Password");
    public static void main(String args[]) {
        new oracle();
     FDoptions.java
import java.awt.FlowLayout;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Fdoptions{
    private JFrame fdoptions;
    private JPanel fdoptpanel;
    private JButton enterfdbutton;
    private JButton viewfdbutton;
    public Fdoptions() {
        initComponents();
    private final void initComponents(){
        fdoptpanel = new JPanel(new BorderLayout());
        fdoptpanel.setBorder(BorderFactory.createEmptyBorder(80,50,80,50));
        enterfdbutton = new JButton(new EnterFDAction());
        viewfdbutton = new JButton(new ViewFDAction());
       JPanel enterbuttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
       JPanel viewbuttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        enterbuttonpanel.add(enterfdbutton);
        viewbuttonpanel.add(viewfdbutton);
        fdoptpanel.add(enterbuttonpanel,BorderLayout.NORTH);
        fdoptpanel.add(viewbuttonpanel,BorderLayout.SOUTH);
        fdoptions = new JFrame("FD Options");
        fdoptions.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fdoptions.setSize(1000,1000);
        fdoptions.setContentPane(fdoptpanel);
        fdoptions.pack();
        fdoptions.setVisible(true);
    private void performEnter(){
    private void performView(){
    private final class EnterFDAction extends AbstractAction{
        public EnterFDAction(){
            super("Enter new FD");
        public void actionPerformed(ActionEvent e){
            performEnter();
    private final class ViewFDAction extends AbstractAction{
        public ViewFDAction(){
            super("View an existing FD");
        public void actionPerformed(ActionEvent e){
            performView();
    public static void main(String args[]){
        new Fdoptions();
}

nice day,
these lines..., despite the fact that this example is about something else, shows you two ways
1/ modal JDialog
2/ two JFrame
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
* Parent Modal Dialog. When in modal mode, this dialog
* will block inputs to the "parent Window" but will
* allow events to other components
* @see javax.swing.JDialog
public class PMDialog extends JDialog {
    private static final long serialVersionUID = 1L;
    protected boolean modal = false;
    private WindowAdapter parentWindowListener;
    private Window owner;
    private JFrame blockedFrame = new JFrame("No blocked frame");
    private JFrame noBlockedFrame = new JFrame("Blocked Frame");
    public PMDialog() {
        noBlockedFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        noBlockedFrame.getContentPane().add(new JButton(new AbstractAction("Test button") {
            private static final long serialVersionUID = 1L;
            @Override
            public void actionPerformed(ActionEvent evt) {
                System.out.println("Non blocked button pushed");
                blockedFrame.setVisible(true);
                noBlockedFrame.setVisible(false);
        noBlockedFrame.setSize(200, 200);
        noBlockedFrame.setVisible(true);
        blockedFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        blockedFrame.getContentPane().add(new JButton(new AbstractAction("Test Button") {
            private static final long serialVersionUID = 1L;
            @Override
            public void actionPerformed(ActionEvent evt) {
                final PMDialog pmd = new PMDialog(blockedFrame, "Partial Modal Dialog", true);
                pmd.setSize(200, 100);
                pmd.setLocationRelativeTo(blockedFrame);
                pmd.getContentPane().add(new JButton(new AbstractAction("Test button") {
                    private static final long serialVersionUID = 1L;
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        System.out.println("Blocked button pushed");
                        pmd.setVisible(false);
                        blockedFrame.setVisible(false);
                        noBlockedFrame.setVisible(true);
                pmd.setVisible(true);
                System.out.println("Returned from Dialog");
        blockedFrame.setSize(200, 200);
        blockedFrame.setLocation(300, 0);
        blockedFrame.setVisible(false);
    public PMDialog(Dialog parent, String title, boolean isModal) {
        super(parent, title, false);
        initDialog(parent, title, isModal);
    public PMDialog(Frame parent, String title, boolean isModal) {
        super(parent, title, false);
        initDialog(parent, title, isModal);
    private void initDialog(Window parent, String title, boolean isModal) {
        owner = parent;
        modal = isModal;
        parentWindowListener = new WindowAdapter() {
            @Override
            public void windowActivated(WindowEvent e) {
                if (isVisible()) {
                    System.out.println("Dialog.getFocusBack()");
                    getFocusBack();
    private void getFocusBack() {
        Toolkit.getDefaultToolkit().beep();
        super.setVisible(false);
        super.pack();
        super.setLocationRelativeTo(owner);
        super.setVisible(true);
        //super.toFront();
    @Override
    public void dispose() {
        owner.setEnabled(true);
        owner.setFocusableWindowState(true);
        super.dispose();
    @Override
    @SuppressWarnings("deprecation")
    public void hide() {
        owner.setEnabled(true);
        owner.setFocusableWindowState(true);
        super.hide();
    @Override
    public void setVisible(boolean visible) {
        boolean blockParent = (visible && modal);
        owner.setEnabled(!blockParent);
        owner.setFocusableWindowState(!blockParent);
        super.setVisible(visible);
        if (blockParent) {
            System.out.println("Adding listener to parent ...");
            owner.addWindowListener(parentWindowListener);
            try {
                if (SwingUtilities.isEventDispatchThread()) {
                    System.out.println("EventDispatchThread");
                    EventQueue theQueue = getToolkit().getSystemEventQueue();
                    while (isVisible()) {
                        AWTEvent event = theQueue.getNextEvent();
                        Object src = event.getSource();
                        if (event instanceof ActiveEvent) {
                            ((ActiveEvent) event).dispatch();
                        } else if (src instanceof Component) {
                            ((Component) src).dispatchEvent(event);
                } else {
                    System.out.println("OUTSIDE EventDispatchThread");
                    synchronized (getTreeLock()) {
                        while (isVisible()) {
                            try {
                                getTreeLock().wait();
                            } catch (InterruptedException e) {
                                break;
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("Error from EDT ... : " + ex);
        } else {
            System.out.println("Removing listener from parent ...");
            owner.removeWindowListener(parentWindowListener);
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
    @Override
    public void setModal(boolean modal) {
        this.modal = modal;
    public static void main(String args[]) {
        new PMDialog();
}

Similar Messages

  • How to open a new iView in the same window?

    Hi
      i want to open a new iview in the same window.How can i do that ?
    Thanks

    Hi,
    If u want to code in WDJ  ..
    Use following method
         WDPortalNavigation.navigateAbsolute(
         "ROLES://<PCD location>,
         WDPortalNavigationMode.SHOW_INPLACE,               WDPortalNavigationHistoryMode.ALLOW_DUPLICATIONS,
         (String) null  );
    SHOW_INPLACE is the key
    Cheers!!
    Ashutosh

  • How can I get a query in the search field to open in a new tab or new window from the current window?

    How can I get a query in the search field to open in a new tab or new window from the current window?

    If you are searching via the Search Bar on the Navigation Toolbar, this preference can be changed to have searches there open in a Tab.
    Type '''about:config''' in the Address Bar and hit Enter. Then answer "I'll be careful". Type this pref in the Search at the top.
    '''browser.search.openintab''' = double-click to toggle to '''true'''

  • How do you open a new document from the template chooser?

    Hi There,
    Since upgrading to Yosemite, I can't find the option to open a new document from the template chooser. When I type in "template" in the help box it shows it under "file" But when I click on "File" I don't see that option.
    Basically, I'm trying to ask how do you access the templates in the new pages?
    Thanks so much

    Check your preferences and make sure Show Template Chooser is selected:
    Then just choose New from the File menu.

  • My safari stopped letting me open a new tab in the same window. what happened and how can I get it back to normal?

    When I try and open a new tab in the same window, it wont open a new tab. It leaves the page I am on and goes to the "top sites page."

    Hi,
    If you have got to  Mountain Lion OS X 10.8.2 and therefore Messages version 7.0.1 then double click the individual chats.
    Once they are in separate windows you can chat like that  (That's the way I used to chat - I didn't even use the tabbed chat)
    It is impossible to create a separate Chat window each new chat (you have to separate them off from the main window which also keeps a "copy")
    New chats are added to the main window even if you have used the red button to hide it. (CMD + 0 from the Window menu brings it back)
    10:49 PM      Tuesday; November 20, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • I can only open one Firefox browser window. When I click the firefox icon from desktop or taskbar to open up another browser window it does not open. I am ablt to open up new tabs within the one window.

    I can only open one Firefox browser window. When I click the firefox icon from desktop or taskbar to open up another browser window it does not open. I am ablt to open up new tabs within the one window.

    Have you tried: click Firefox button > New Tab > New Window '''''OR''''' CTRL+N '''''OR''''' File > New Window (if using the Menu Bar)
    Once open, Firefox locks the Profile that is in use and you can not open another window with that Firefox version and Profile combination using the Windows Desktop icon or the Windows Programs list.

  • Every time I open a New File from the File Menu and I open it all of my desktop items are in it. What's up with that?

    Every time I open a New File from the File Menu and I open it all of my desktop items are in it. What's up with that?

    This is configured in Finder preferences under the General icon. You can make some changes to that behavior.

  • Why does ctrl+Left click a link open a new window? It should open a new tab in the current window.

    When I try to Ctrl+Left click to open a link in a new tab, it will open it in a new window instead. Then while in the new window if I Ctrl+Left click a link it will open a new tab in the second window. If I then go back to the first Firefox window and Ctrl+Left click a link the second firefox window will pop up and the new tab will be created there. Why won't the Ctrl+Left click work when only one window is open?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • How do I shut down from the login window in mountain lion using the keyboard

    how do I shut down/sleep/restart from the login window in mountain lion using the keyboard?

    Hi Thomas, thanks for your reply.
    Yes in standard start-up as it is and in recovery mode I still get the same message about Disk Utility being unable to repair the disk so I should back-up and restore.
    Some posters have said that booting into safe mode should unmount the installer and allow rebooting back into Lion, that would allow me to back-up the files properly, as my last back up was (as is often the way) not too recent.
    But I think your suggestion looks more likely to be he correct way to do it, and I'll take the hit on any data that I may lose.
    Thanks again.

  • How do I remove an iBook from the "Purchased" window of the iBooks store?  I have already deleted it from the "Library" but it still shows up as a purchased book.

    How do I remove an iBook from the "Purchased" window of the iBooks store?  I have already deleted it from the "Library" but it still shows up as a purchased book.

    You can't currently delete items from your Purchased page, all you can do is hide (and unhide) them : http://support.apple.com/kb/HT4919

  • "Open file location" option from the search window replaces the search window to open the file location

    After searching for  some files, when I right click on any file from the search window and click "open file location", the file location is opened in the same search window there by detroying my search. In Vista this option would open the file location in a separate window. This is really annoying if I want to open locations of several files from the search window.

    The more thorough explanation of how to do this is right-click the item then CTRL-Left Click "Open file Location". This will open it in a new window.
    I agree that Microsoft makes unnecessary changes to the operating system which cause it to behave less productively. The search is an important part of an operating system and Microsoft managed to make it the worst part.
    Bring back the XP search option. I'm very sad so see this terribly executed search is still the norm in Windows 8. 
    To put it bluntly, I don't use Windows by choice, it's my job to deal with it.

  • How to open a new tab with the same current directory in a terminal?

    I use the following script to open a new terminal with the same pwd.
    I'm wondering how to modify it to open a new tab with the same pwd.
    #!/bin/sh
    # Open a new terminal in the cwd
    CWD=`pwd`
    osascript<<END
    set thePath to "$CWD"
    set myPath to (POSIX file thePath as alias)
    try
    tell application "Terminal"
    activate
    do script with command "cd \"" & thePath & "\""
    end tell
    end try
    END

    bit of a hack, but the make command doesn't seem to work for tabs in terminal. replace what's currently in the 'try' block with this code:
    tell application "Terminal" to activate
    tell application "System Events"
    tell process "Terminal"
    keystroke "t" using command down
    end tell
    end tell
    tell application "Terminal"
    do script "cd " & (quoted form of thePath) in last tab of window 1
    end tell

  • Calling a Function in the Parent Window from the Child Window

    QUESTION: How do I call a function resident in the parent
    window from a child window?
    BACKGROUND
    I have a JavaScript function resident in the parent window
    that reformats information obtained from the Date object and writes
    the result to the parent window using the document.write( ) method.
    I would like to call this function from the child window and have
    it write to the child window instead. Is this possible? If not,
    must I rewrite the entire function and nest it in the below code?
    If so, what is the proper form of nesting?
    CODE: The code that creates and fills the child window is
    provided below. The highlighted area indicates where I would like
    to enter the information from the function resident in the parent
    window. I have tried every imaginable permutation of code that I
    can imagine and nearly destroyed my parent document in the process.
    I am very happy that I had a back-up copy!
    function openCitationWindow() {
    ciDow = window.open("", "", "width=450, height=175, top=300,
    left=300");
    ciDow.document.write("A proper way to cite a passage of text
    on this page:<br /><br />Stegemann, R. A. 2000.
    <cite>Imagine: Bridging a Historical Gap</cite>. " +
    document.title + ". [<a href='" + location.href + "'
    target='_blank'>online book</a>] &lt;" + location.href
    + "&gt; (");
    MISSING CODE;
    ciDow.document.write(").<br /><br /><input
    type='button' value='Close Window' onclick='window.close()'>");
    ciDow.focus();

    Never mind - I was doing something very stupid and wasn't
    calling the function as a method of a movie clip. I was simply
    calling checkTarget(event) rather than
    event.currentTarget.checkTarget(event); which seems to work.

  • On a Mac, how do I setup Firefox to use Command+Enter to open a new tab from the address bar? Safari and Chrome do this by default.

    I tried this extension (https://addons.mozilla.org/en-US/firefox/addon/customizable-shortcuts/), but it doesn't appear to support editing the current "Alt+Enter" to change to "Meta+Enter" where Meta = Command on a Mac.
    I want to switch to Firefox, but this is the one and only thing preventing me from doing so! I have a decade plus of muscle memory using the key next to the space bar + enter to open a new tab. Please help!

    There is an older extension named keyconfig (last updated in 2011) which might be able to do it. I haven't used it for quite a while so I'm not sure how well it works any more.
    http://forums.mozillazine.org/viewtopic.php?f=48&t=72994 (link in first post)

  • How do I make new tabs from a first window go behind instead of in front of the first window?

    I use the same version of Firefox at work & new tabs open "behind" the initial tab, I can't figure out how to make this happen on my home computer! At home, new tabs open "in front" of the initial tab & it's really frustrating!

    Extract code into methods, so that when an action is performed a method is called. That way you can reuse the method for purposes such as resetting textfields to their default values, scores to default values, etc.
    You can go one step further and seperate the GUI layer from the processing layer, by deriving classes that for example maintain and calculate a score.
    Mel

Maybe you are looking for