Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


#Actualwarnexus

Posted 07 May 2013 - 07:26 AM

Tell us what language you are using:

 

Note: You should use code that other people(programmers many years ago wrote so you do not wind up reinventing the wheel about how things should be done) You can think of it like this: "If you want to have your own form of transportation, would you want to build your own car?" You can sure...I guess if you have the knowledge. But is it worth it given the resources already established or realistic to do so?" Right? Why not just buy a car and use theirs? Same kind of idea. In your case, it would be should you write the internal implementation of what makes up a gui component from scratch if you do not have prior knowledge and experiences with GUI?

 

I will show you an example written a year ago by my professor that really puts the pieces and concepts of GUI together. It is written in Java. But the idea is that you can have GUI components such as labels or buttons that are layered on top of a panel. A GUI is just a lot of Panels layered on top of one container object(it can be a container or a panel). So you can think them like a stack of pancakes. The orientation of components added on the panel can be changed by setting a different layout for the panel.

 

Use other people's functionality if it is out there. It speeds up development. The important thing is learning how to put the pieces together.

 

If you have a Eclipse IDE, start pasting each code starting with the main method and see what behavior you are seeing and how the method call affect the GUI application.

 

 

 
import javax.swing.*;
import java.awt.*;
 
public class NestedPanels extends JFrame {
 
    private static final int FRAME_WIDTH    = 500;
    private static final int FRAME_HEIGHT   = 350;
    private static final int FRAME_X_ORIGIN = 150;
    private static final int FRAME_Y_ORIGIN = 250;
 
    public static void main(String[] args) {
        NestedPanels frame = new NestedPanels();
        frame.setVisible(true);
    }
 
    public NestedPanels() {
        Container         contentPane;
        JPanel      gamePanel;
        JPanel            controlPanel;
        JPanel            scorePanel;
 
        setSize      (FRAME_WIDTH, FRAME_HEIGHT);
        setTitle     ("My Nested Panels");
        setLocation  (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
        contentPane = getContentPane( );
        contentPane.setLayout(new BorderLayout());
 
        gamePanel = new JPanel();
        gamePanel.setBorder(BorderFactory.createLoweredBevelBorder());
        controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout( ));
 
        contentPane.add(gamePanel, BorderLayout.CENTER);
        gamePanel.setBackground(Color.PINK);
        controlPanel.setBackground(Color.BLUE);
        
        contentPane.add(controlPanel, BorderLayout.EAST);
 
        scorePanel = new JPanel();
        scorePanel.setBorder( BorderFactory.createTitledBorder("Scores:"));
        scorePanel.setLayout(new GridLayout(2, 2));
        scorePanel.add(new JLabel("Player 1:"));
        scorePanel.add(new JLabel("     0"));
        scorePanel.add(new JLabel("Player 2:"));
        scorePanel.add(new JLabel("     0"));
 
        controlPanel.add(scorePanel,BorderLayout.NORTH);
        controlPanel.add(new JButton("New Game"), BorderLayout.SOUTH);
 
        setDefaultCloseOperation( EXIT_ON_CLOSE );
    }
 
}


#6warnexus

Posted 07 May 2013 - 07:18 AM

Tell us what language you are using:

 

Note: You should use code that other people(programmers many years ago wrote so you do not wind up reinventing the wheel about how things should be done) You can think of it like this: "If you want to have you own form of transportation, would you want to build your own car?" You can sure...I guess but is it worth it given the resources already established?" Right? Why not just buy one and use theirs? In your case, it would be should you write the internal implementation of what makes up a gui component?

 

I will show you an example written a year ago by my professor that really puts the pieces and concepts of GUI together. It is written in Java. But the idea is that you can have GUI components such as labels or buttons that are layered on top of a panel. A GUI is just a lot of Panels layered on top of one container object(it can be a container or a panel). So you can think them like a stack of pancakes. The orientation of components added on the panel can be changed by setting a different layout for the panel.

 

Use other people's functionality if it is out there. It speeds up development. The important thing is learning how to put the pieces together.

 

If you have a Eclipse IDE, start pasting each code starting with the main method and see what behavior you are seeing and how the method call affect the GUI application.

 

 

 
import javax.swing.*;
import java.awt.*;
 
public class NestedPanels extends JFrame {
 
    private static final int FRAME_WIDTH    = 500;
    private static final int FRAME_HEIGHT   = 350;
    private static final int FRAME_X_ORIGIN = 150;
    private static final int FRAME_Y_ORIGIN = 250;
 
    public static void main(String[] args) {
        NestedPanels frame = new NestedPanels();
        frame.setVisible(true);
    }
 
    public NestedPanels() {
        Container         contentPane;
        JPanel      gamePanel;
        JPanel            controlPanel;
        JPanel            scorePanel;
 
        setSize      (FRAME_WIDTH, FRAME_HEIGHT);
        setTitle     ("My Nested Panels");
        setLocation  (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
        contentPane = getContentPane( );
        contentPane.setLayout(new BorderLayout());
 
        gamePanel = new JPanel();
        gamePanel.setBorder(BorderFactory.createLoweredBevelBorder());
        controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout( ));
 
        contentPane.add(gamePanel, BorderLayout.CENTER);
        gamePanel.setBackground(Color.PINK);
        controlPanel.setBackground(Color.BLUE);
        
        contentPane.add(controlPanel, BorderLayout.EAST);
 
        scorePanel = new JPanel();
        scorePanel.setBorder( BorderFactory.createTitledBorder("Scores:"));
        scorePanel.setLayout(new GridLayout(2, 2));
        scorePanel.add(new JLabel("Player 1:"));
        scorePanel.add(new JLabel("     0"));
        scorePanel.add(new JLabel("Player 2:"));
        scorePanel.add(new JLabel("     0"));
 
        controlPanel.add(scorePanel,BorderLayout.NORTH);
        controlPanel.add(new JButton("New Game"), BorderLayout.SOUTH);
 
        setDefaultCloseOperation( EXIT_ON_CLOSE );
    }
 
}


#5warnexus

Posted 07 May 2013 - 07:17 AM

Tell us what language you are using:

 

Note: You should use code that other people(programmers many years ago wrote so you do not wind up reinventing the wheel about how things should be done) You can think of it like this: "If you want to have you own form of transportation, would you want to build your own car?" You can sure...I guess but is it worth it given the resources already established?" Right? Why not just buy one and use theirs? In your case, it would be should you write the internal implementation of what makes up a gui component?

 

I will show you an example written a year ago by my professor that really puts the pieces and concepts of GUI together. It is in Java. But the idea is that you can have GUI components such as labels or buttons that are layered on top of a panel. A GUI is just a lot of Panels layered on top of one container object(it can be a container or a panel). So you can think them like a stack of pancakes. The orientation of components added on the panel can be changed by setting a different layout for the panel.

 

Use other people's functionality if it is out there. It speeds up development. The important thing is learning how to put the pieces together.

 

If you have a Eclipse IDE, start pasting each code starting with the main method and see what behavior you are seeing and how the method call affect the GUI application.

 

 

 
import javax.swing.*;
import java.awt.*;
 
public class NestedPanels extends JFrame {
 
    private static final int FRAME_WIDTH    = 500;
    private static final int FRAME_HEIGHT   = 350;
    private static final int FRAME_X_ORIGIN = 150;
    private static final int FRAME_Y_ORIGIN = 250;
 
    public static void main(String[] args) {
        NestedPanels frame = new NestedPanels();
        frame.setVisible(true);
    }
 
    public NestedPanels() {
        Container         contentPane;
        JPanel      gamePanel;
        JPanel            controlPanel;
        JPanel            scorePanel;
 
        setSize      (FRAME_WIDTH, FRAME_HEIGHT);
        setTitle     ("My Nested Panels");
        setLocation  (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
        contentPane = getContentPane( );
        contentPane.setLayout(new BorderLayout());
 
        gamePanel = new JPanel();
        gamePanel.setBorder(BorderFactory.createLoweredBevelBorder());
        controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout( ));
 
        contentPane.add(gamePanel, BorderLayout.CENTER);
        gamePanel.setBackground(Color.PINK);
        controlPanel.setBackground(Color.BLUE);
        
        contentPane.add(controlPanel, BorderLayout.EAST);
 
        scorePanel = new JPanel();
        scorePanel.setBorder( BorderFactory.createTitledBorder("Scores:"));
        scorePanel.setLayout(new GridLayout(2, 2));
        scorePanel.add(new JLabel("Player 1:"));
        scorePanel.add(new JLabel("     0"));
        scorePanel.add(new JLabel("Player 2:"));
        scorePanel.add(new JLabel("     0"));
 
        controlPanel.add(scorePanel,BorderLayout.NORTH);
        controlPanel.add(new JButton("New Game"), BorderLayout.SOUTH);
 
        setDefaultCloseOperation( EXIT_ON_CLOSE );
    }
 
}


#4warnexus

Posted 07 May 2013 - 07:15 AM

Tell us what language you are using:

 

Note: You should use code that other people(programmers many years ago wrote so you do not wind up reinventing the wheel about how things should be done) You can think of it like this: "If you want to have you own form of transportation, would you want to build your own car?" You can sure...I guess but is it worth it given the resources already established?" Right? Why not just buy one and use theirs?

 

I will show you an example written a year ago by my professor that really puts the pieces and concepts of GUI together. It is in Java. But the idea is that you can have GUI components such as labels or buttons that are layered on top of a panel. A GUI is just a lot of Panels layered on top of one container object(it can be a container or a panel). So you can think them like a stack of pancakes. The orientation of components added on the panel can be changed by setting a different layout for the panel.

 

Use other people's work. It speeds up development. The important thing is learning how to put the pieces together.

 

If you have a Eclipse IDE, start pasting each code starting with the main method and see what behavior you are seeing and how the method call affect the GUI application.

 

 

 
import javax.swing.*;
import java.awt.*;
 
public class NestedPanels extends JFrame {
 
    private static final int FRAME_WIDTH    = 500;
    private static final int FRAME_HEIGHT   = 350;
    private static final int FRAME_X_ORIGIN = 150;
    private static final int FRAME_Y_ORIGIN = 250;
 
    public static void main(String[] args) {
        NestedPanels frame = new NestedPanels();
        frame.setVisible(true);
    }
 
    public NestedPanels() {
        Container         contentPane;
        JPanel      gamePanel;
        JPanel            controlPanel;
        JPanel            scorePanel;
 
        setSize      (FRAME_WIDTH, FRAME_HEIGHT);
        setTitle     ("My Nested Panels");
        setLocation  (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
        contentPane = getContentPane( );
        contentPane.setLayout(new BorderLayout());
 
        gamePanel = new JPanel();
        gamePanel.setBorder(BorderFactory.createLoweredBevelBorder());
        controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout( ));
 
        contentPane.add(gamePanel, BorderLayout.CENTER);
        gamePanel.setBackground(Color.PINK);
        controlPanel.setBackground(Color.BLUE);
        
        contentPane.add(controlPanel, BorderLayout.EAST);
 
        scorePanel = new JPanel();
        scorePanel.setBorder( BorderFactory.createTitledBorder("Scores:"));
        scorePanel.setLayout(new GridLayout(2, 2));
        scorePanel.add(new JLabel("Player 1:"));
        scorePanel.add(new JLabel("     0"));
        scorePanel.add(new JLabel("Player 2:"));
        scorePanel.add(new JLabel("     0"));
 
        controlPanel.add(scorePanel,BorderLayout.NORTH);
        controlPanel.add(new JButton("New Game"), BorderLayout.SOUTH);
 
        setDefaultCloseOperation( EXIT_ON_CLOSE );
    }
 
}


#3warnexus

Posted 07 May 2013 - 07:12 AM

Tell us what language you are using:

 

Note: You should use code that other people(programmers many years ago wrote so you do not wind up reinventing the wheel about how things should be done) You can think of it like this: "If you want to have you own form of transportation, would you want to build your own car?" You can sure...I guess but is it worth it given the resources already established?" Right? Why not just buy one and use theirs?

 

I will show you an example I learned a year that really puts the pieces and concepts of GUI together. It is in Java. But the idea is that you can have GUI components such as labels or buttons that are layered on top of a panel. A GUI is just a lot of Panels layered on top of one container object(it can be a container or a panel). So you can think them like a stack of pancakes. The orientation of components added on the panel can be changed by setting a different layout for the panel.

 

If you have a Eclipse IDE, start pasting each code starting with the main method and see what behavior you are seeing and how the method call affect the GUI application.

 

 

 
import javax.swing.*;
import java.awt.*;
 
public class NestedPanels extends JFrame {
 
    private static final int FRAME_WIDTH    = 500;
    private static final int FRAME_HEIGHT   = 350;
    private static final int FRAME_X_ORIGIN = 150;
    private static final int FRAME_Y_ORIGIN = 250;
 
    public static void main(String[] args) {
        NestedPanels frame = new NestedPanels();
        frame.setVisible(true);
    }
 
    public NestedPanels() {
        Container         contentPane;
        JPanel      gamePanel;
        JPanel            controlPanel;
        JPanel            scorePanel;
 
        setSize      (FRAME_WIDTH, FRAME_HEIGHT);
        setTitle     ("My Nested Panels");
        setLocation  (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
        contentPane = getContentPane( );
        contentPane.setLayout(new BorderLayout());
 
        gamePanel = new JPanel();
        gamePanel.setBorder(BorderFactory.createLoweredBevelBorder());
        controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout( ));
 
        contentPane.add(gamePanel, BorderLayout.CENTER);
        gamePanel.setBackground(Color.PINK);
        controlPanel.setBackground(Color.BLUE);
        
        contentPane.add(controlPanel, BorderLayout.EAST);
 
        scorePanel = new JPanel();
        scorePanel.setBorder( BorderFactory.createTitledBorder("Scores:"));
        scorePanel.setLayout(new GridLayout(2, 2));
        scorePanel.add(new JLabel("Player 1:"));
        scorePanel.add(new JLabel("     0"));
        scorePanel.add(new JLabel("Player 2:"));
        scorePanel.add(new JLabel("     0"));
 
        controlPanel.add(scorePanel,BorderLayout.NORTH);
        controlPanel.add(new JButton("New Game"), BorderLayout.SOUTH);
 
        setDefaultCloseOperation( EXIT_ON_CLOSE );
    }
 
}


#2warnexus

Posted 07 May 2013 - 07:11 AM

Tell us what language you are using:

 

Note: You should use code that other people(programmers many years ago wrote so you do not wind up reinventing the wheel about how things should be done) You can think of it like this: "If you want to have you own form of transportation, would you want to build your own car?" You can sure...I guess but is it worth it given the resources already established?" Right? Why not just buy one and use theirs?

 

I will show you an example I learned a year that really puts the pieces and concepts of GUI together. It is in Java. But the idea is that you can have GUI components such as labels or buttons that are layered on top of a panel. A GUI is just a lot of Panels layered on top of one container object(it can be a container or a panel). So you can think them like a stack of pancakes. The orientation of components added on the panel can be changed by setting a different layout for the panel.

 

If you have a Eclipse IDE, start pasting each code starting with the main method and see what behavior you are seeing and how the method call affect the GUI application.

 

 

 
import javax.swing.*;
import java.awt.*;
 
public class NestedPanels extends JFrame {
 
    private static final int FRAME_WIDTH    = 500;
    private static final int FRAME_HEIGHT   = 350;
    private static final int FRAME_X_ORIGIN = 150;
    private static final int FRAME_Y_ORIGIN = 250;
 
    public static void main(String[] args) {
        NestedPanels frame = new NestedPanels();
        frame.setVisible(true);
    }
 
    public NestedPanels() {
        Container         contentPane;
        JPanel      gamePanel;
        JPanel            controlPanel;
        JPanel            scorePanel;
 
        setSize      (FRAME_WIDTH, FRAME_HEIGHT);
        setTitle     ("My Nested Panels");
        setLocation  (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
        contentPane = getContentPane( );
        contentPane.setLayout(new BorderLayout());
 
        gamePanel = new JPanel();
        gamePanel.setBorder(BorderFactory.createLoweredBevelBorder());
        controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout( ));
 
        contentPane.add(gamePanel, BorderLayout.CENTER);
        gamePanel.setBackground(Color.PINK);
        controlPanel.setBackground(Color.BLUE);
        
        contentPane.add(controlPanel, BorderLayout.EAST);
 
        scorePanel = new JPanel();
        scorePanel.setBorder( BorderFactory.createTitledBorder("Scores:"));
        scorePanel.setLayout(new GridLayout(2, 2));
        scorePanel.add(new JLabel("Player 1:"));
        scorePanel.add(new JLabel("     0"));
        scorePanel.add(new JLabel("Player 2:"));
        scorePanel.add(new JLabel("     0"));
 
        controlPanel.add(scorePanel,BorderLayout.NORTH);
        controlPanel.add(new JButton("New Game"), BorderLayout.SOUTH);
 
        setDefaultCloseOperation( EXIT_ON_CLOSE );
    }
 
}

 
import javax.swing.*;
 
public class JFrameSubclass extends JFrame{
 
private static final int FRAME_WIDTH = 300;
private static final int FRAME_HEIGHT = 200;
private static final int FRAME_X_ORIGIN = 150;
private static final int FRAME_Y_ORIGIN = 250;
 
public JFrameSubclass() {
setTitle("My first subclass");
setSize(FRAME_WIDTH, FRAME_HEIGHT);
setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
 
setDefaultCloseOperation( EXIT_ON_CLOSE );
}
}

PARTNERS