Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
Like Tree1Likes

Thread: Why is my class not opening as a window?

  1. #21
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    983
    Rep Power
    2

    Default Re: Why is my class not opening as a window?

    For future readers: this post looks wierd without source code, post #8 contained his source code. It was deleted by the OP after everything was suddenly somehow our fault.

  2. #22
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,406
    Rep Power
    20

    Default Re: Why is my class not opening as a window?

    Quote Originally Posted by SurfMan View Post
    post #8 contained his source code. It was deleted by the OP
    Here it is:

    Quote Originally Posted by 9a3iqa View Post
    Java Code:
     
     public class GUI extends JPanel implements ActionListener {
    
     public static void main(String[] args) {
     JFrame gui = new JFrame("Q-HOLIDAY Login");
     gui.setPreferredSize(new Dimension(950, 570));
     gui.setMinimumSize(new Dimension(950, 570));
     gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
     GUI panel = new GUI();
     gui.getContentPane().add(panel);
    
     gui.setVisible(true);
     }
    
     public GUI(){
    
     setLayout(new BorderLayout());
     add(west(), BorderLayout.WEST);
    
     }
    
     public JPanel west(){
    
     GridBagLayout gridBag = new GridBagLayout();
     GridBagConstraints con = new GridBagConstraints();
     con.insets = new Insets(5, 5, 5, 5);
     JPanel panel = new JPanel();
     panel.setBackground(Color.lightGray);
     panel.setSize(100, 100);
    
     panel.setLayout(gridBag);
     this.username = new JLabel("Enter Username");
     con.gridx = 0;
     con.gridy = 0; 
     panel.add(username, con);
    
     this.userfield = new JTextField(10);
     con.gridx = 1;
     con.gridy = 0; 
     panel.add(userfield,con);
    
    
     this.password = new JLabel("Enter Password");
     con.gridx = 0;
     con.gridy = 2; 
     panel.add(password,con);
    
     this.passfield = new JPasswordField(10);
     con.gridx = 1;
     con.gridy = 2; 
     panel.add(passfield,con);
    
     this.login = new JButton("Login");
     con.gridx = 0;
     con.gridy = 3;
     panel.add(login,con);
    
     this.register = new JButton("Register");
     con.gridx = 1;
     con.gridy = 3;
     panel.add(register,con);
    
    
     return panel;
     }
    
     public void actionPerformed(ActionEvent e) {
     if (e.getSource() == register){
     Home one = new Home();
     one.setVisible(true);
     }
     }
     }
    
    
    
    
    
    
    
    
     public class Home extends JPanel implements ActionListener{
    
     public static void main(String[] args) {
     JFrame home = new JFrame("Home");
     home.setPreferredSize(new Dimension(950, 570));
     home.setMinimumSize(new Dimension(950, 570));
     home.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
     Home panel = new Home();
     home.getContentPane().add(panel);
     home.setVisible(true);
     }
    
     public Home() {
    
     setLayout(new BorderLayout());
    
    
    
     add(top(), BorderLayout.NORTH);
     }
    
     public JPanel top() {
    
    
     GridBagLayout gridBag = new GridBagLayout();
     GridBagConstraints con = new GridBagConstraints();
     JPanel panel = new JPanel();
     panel.setBackground(Color.LIGHT_GRAY);
     panel.setSize(100, 100);
    
     con.insets = new Insets(5, 5, 5, 5);
    
     panel.setLayout(gridBag);
    
    
     this.loggedinas = new JLabel("Logged In As:");
     con.gridx = 3;
     con.gridy = 0; 
     panel.add(loggedinas, con);
    
     this.quicksearch = new JLabel("Quick Search:");
     con.gridx = 0;
     con.gridy = 0; 
     panel.add(quicksearch, con);
    
     this.search = new JTextField(10);
     search.setSize(5, 5);
     con.gridx = 2;
     con.gridy = 0; 
     panel.add(search, con);
    
     this.searchbutton = new JButton("Search");
     con.gridx = 0;
     con.gridy = 1;
     panel.add(searchbutton,con);
    
     this.logout = new JButton("LogOut");
     con.gridx = 3;
     con.gridy = 1;
     panel.add(logout, con);
    
     this.viewaccount = new JButton("View Account");
     con.gridx = 3;
     con.gridy = 2;
     panel.add(viewaccount, con);
    
    
     return panel;
    
     }
     }
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #23
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,406
    Rep Power
    20

    Default Re: Why is my class not opening as a window?

    thread closed
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #24
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Why is my class not opening as a window?

    Quote Originally Posted by SurfMan View Post
    Just so you know, when you post a reply, the content of your reply is sent to the users subscribed to this thread. Editing the post afterwards doesn't change what I find in my mailbox. So writing this makes me very angry:



    <rant>
    I find this highly offensive. Programmers in this forum are people that spent their valuable time helping you with your coding issues. We don't *need* to do this. You should be a bit more (read: a whole lot more) appreciative to the ones that solve your petty problems.

    I hope a moderator reads this and swings his banstick, or at least give you an official warning.
    </rant>
    Quote Originally Posted by 9a3iqa View Post
    I don't care if your angry, I gave you positive rep for attempting to help me and it wasn't even directed at you. Maybe I shouldn't have bothered with an attitude like yours.
    His rudeness is not a banning offence just yet, I think, but I doubt anyone will want to help him in the future.
    DarrylBurke likes this.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Restriction about opening multiple window [SOLVED]
    By UJJAL DHAR in forum New To Java
    Replies: 3
    Last Post: 06-29-2012, 05:52 AM
  2. How to set Default opening window in Swing?
    By asifzbaig in forum AWT / Swing
    Replies: 0
    Last Post: 02-09-2012, 07:06 PM
  3. opening applet in seperate window vs in the page.
    By bentley4 in forum Java Applets
    Replies: 5
    Last Post: 01-21-2012, 05:43 AM
  4. Oracle Forms Opening in single Java window
    By jav786 in forum Java Applets
    Replies: 0
    Last Post: 03-31-2011, 10:53 AM
  5. opening default browser window in invisible mode
    By robby14 in forum Advanced Java
    Replies: 1
    Last Post: 02-20-2010, 01:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •