Java Code Examples for javax.swing.SpringLayout#putConstraint()

The following examples show how to use javax.swing.SpringLayout#putConstraint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListFrame.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param title
 *            The title of the frame.
 */
public ListFrame(final String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 1, 0, 0));
	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);
	Animal = new JButton("Animal");
	slPanel.putConstraint(SpringLayout.NORTH, Animal, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Animal, 0, SpringLayout.WEST, pan);
	pan.add(Animal);
	Employee = new JButton("Employee");
	slPanel.putConstraint(SpringLayout.NORTH, Employee, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Employee, 78, SpringLayout.WEST, pan);
	pan.add(Employee);
	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
}
 
Example 2
Source File: EmployeeFrame.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param title
 *            The title of the frame.
 */
public EmployeeFrame(final String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 1, 0, 0));
	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);
	Caretaker = new JButton("Caretaker");
	slPanel.putConstraint(SpringLayout.NORTH, Caretaker, 180, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Caretaker, 280, SpringLayout.WEST, pan);
	pan.add(Caretaker);
	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
}
 
Example 3
Source File: MammalFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public MammalFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	cowButton = new JButton("Cow");
	slPanel.putConstraint(SpringLayout.NORTH, cowButton, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, cowButton, 93, SpringLayout.WEST, pan);
	pan.add(cowButton);
	
	tigerButton = new JButton("Tiger");
	slPanel.putConstraint(SpringLayout.NORTH, tigerButton, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, tigerButton, 93, SpringLayout.WEST, pan);
	pan.add(tigerButton);

	monkeyButton = new JButton("Monkey");
	slPanel.putConstraint(SpringLayout.NORTH, monkeyButton, 135, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, monkeyButton, 93, SpringLayout.WEST, pan);
	pan.add(monkeyButton);
	
	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);

}
 
Example 4
Source File: SpringUtils.java    From swift-k with Apache License 2.0 5 votes vote down vote up
public static void gridLayout(JComponent c, int rows, int cols, int gap, boolean n, boolean s, boolean w, boolean e) {
    SpringLayout sl = new SpringLayout();
    c.setLayout(sl);
    for (int row = 0; row < rows; row++) {
        if (n) {
            if (row == 0) {
                sl.putConstraint(SpringLayout.NORTH, c.getComponent(0), 0, 
                    SpringLayout.NORTH, c);
            }
        }
        if (row != 0) {
            sl.putConstraint(SpringLayout.NORTH, c.getComponent(cols * row), gap, 
                SpringLayout.SOUTH, c.getComponent(cols * row - cols));
        }
        if (w) {
            sl.putConstraint(SpringLayout.WEST, c.getComponent(cols * row), 0, 
                SpringLayout.WEST, c);
        }
        for (int col = 1; col < cols; col++) {
            sl.putConstraint(SpringLayout.WEST, c.getComponent(cols * row + col), gap,
                SpringLayout.EAST, c.getComponent(cols * row + col - 1));
            sl.putConstraint(SpringLayout.SOUTH, c.getComponent(cols * row + col), 0,
                SpringLayout.SOUTH, c.getComponent(cols * row + col - 1));
            if (row != 0) {
                sl.putConstraint(SpringLayout.WEST, c.getComponent(cols * row + col), 0,
                SpringLayout.WEST, c.getComponent(cols * (row - 1) + col));
            }
        }
        if (e) {
            sl.putConstraint(SpringLayout.EAST, c.getComponent(cols * row + cols - 1), 0, 
                SpringLayout.EAST, c);
        }
        if (s) {
            if (row == rows - 1) {
                sl.putConstraint(SpringLayout.SOUTH, c.getComponent(cols * row), 0, 
                    SpringLayout.SOUTH, c);
            }
        }
    }
}
 
Example 5
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public AddFrame(String title) {
	super(title);
	
	contentPanel.setLayout(new GridLayout(1,1,0,0));
	JPanel panSelect = new JPanel();
	
	contentPanel.add(panSelect);
	SpringLayout slPanel = new SpringLayout();
	panSelect.setLayout(slPanel);
	
	JLabel entityTypeLabel = new JLabel("Type of entity that will be added: \n");
	slPanel.putConstraint(SpringLayout.NORTH, entityTypeLabel, 8, SpringLayout.NORTH, panSelect);
	slPanel.putConstraint(SpringLayout.WEST, entityTypeLabel, 5, SpringLayout.WEST, panSelect);
	
	cBoxSpecies = new JComboBox<String>(Constants.Arrays.Species);
	cBoxSpecies.setSelectedIndex(0);
	slPanel.putConstraint(SpringLayout.NORTH, cBoxSpecies, 5, SpringLayout.NORTH, panSelect);
	slPanel.putConstraint(SpringLayout.WEST, cBoxSpecies, 200, SpringLayout.WEST, panSelect);
	
	cBoxAnimal = new JComboBox<String>(Constants.Arrays.Aquatics);
	cBoxAnimal.setSelectedIndex(0);
	slPanel.putConstraint(SpringLayout.NORTH, cBoxAnimal, 5, SpringLayout.NORTH, panSelect);
	slPanel.putConstraint(SpringLayout.WEST, cBoxAnimal, 300, SpringLayout.WEST, panSelect);
	
	btnNext = new JButton("Next");
	btnNext.setPreferredSize(new Dimension(150, 100));
	slPanel.putConstraint(SpringLayout.NORTH, btnNext, 60, SpringLayout.NORTH, panSelect);
	slPanel.putConstraint(SpringLayout.WEST, btnNext, 175, SpringLayout.WEST, panSelect);
	
	panSelect.add(entityTypeLabel);
	panSelect.add(cBoxSpecies);
	panSelect.add(cBoxAnimal);
	panSelect.add(btnNext);
	
	setVisible(true);
}
 
Example 6
Source File: MainMenuFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public MainMenuFrame(String title) {
	super(title);
	
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
	JPanel panel = new JPanel();
	
	// adding empty panel to fill grid layout
	
	contentPanel.add(panel);
	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);
	
	btnAdd = new JButton("Add");
	slPanel.putConstraint(SpringLayout.NORTH, btnAdd, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, btnAdd, 93, SpringLayout.WEST, pan);
	pan.add(btnAdd);
	
	btnList = new JButton("List");
	slPanel.putConstraint(SpringLayout.NORTH, btnList, 150, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, btnList, 94, SpringLayout.WEST, pan);
	pan.add(btnList);
	
	btnSaveAndExit = new JButton("Save and Exit");
	slPanel.putConstraint(SpringLayout.NORTH, btnSaveAndExit, 264, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, btnSaveAndExit, 69, SpringLayout.WEST, pan);
	pan.add(btnSaveAndExit);
	
	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
}
 
Example 7
Source File: BirdFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public BirdFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	flamingoButton = new JButton("Flamingo");
	slPanel.putConstraint(SpringLayout.NORTH, flamingoButton, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, flamingoButton, 93, SpringLayout.WEST, pan);
	pan.add(flamingoButton);

	hummingbirdButton = new JButton("Hummingbird");
	slPanel.putConstraint(SpringLayout.NORTH, hummingbirdButton, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, hummingbirdButton, 93, SpringLayout.WEST, pan);
	pan.add(hummingbirdButton);

	owlButton = new JButton("Owl");
	slPanel.putConstraint(SpringLayout.NORTH, owlButton, 135, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, owlButton, 93, SpringLayout.WEST, pan);
	pan.add(owlButton);

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);

}
 
Example 8
Source File: AnimalFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param title
 *            The title of the frame.
 */
public AnimalFrame(final String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 1, 0, 0));
	// JPanel panel = new JPanel();
	// contentPanel.add(panel);
	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);
	Aquatic = new JButton("Aquatic");
	slPanel.putConstraint(SpringLayout.NORTH, Aquatic, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Aquatic, 0, SpringLayout.WEST, pan);
	pan.add(Aquatic);
	Bird = new JButton("Bird");
	slPanel.putConstraint(SpringLayout.NORTH, Bird, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Bird, 78, SpringLayout.WEST, pan);
	pan.add(Bird);
	Insect = new JButton("Insect");
	slPanel.putConstraint(SpringLayout.NORTH, Insect, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Insect, 136, SpringLayout.WEST, pan);
	pan.add(Insect);
	Mammal = new JButton("Mammal");
	slPanel.putConstraint(SpringLayout.NORTH, Mammal, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Mammal, 206, SpringLayout.WEST, pan);
	pan.add(Mammal);
	Reptile = new JButton("Reptile");
	slPanel.putConstraint(SpringLayout.NORTH, Reptile, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Reptile, 290, SpringLayout.WEST, pan);
	pan.add(Reptile);
	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
}
 
Example 9
Source File: MainMenuFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public MainMenuFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	btnAdd = new JButton("Add");
	slPanel.putConstraint(SpringLayout.NORTH, btnAdd, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, btnAdd, 93, SpringLayout.WEST, pan);
	pan.add(btnAdd);

	btnList = new JButton("List");
	slPanel.putConstraint(SpringLayout.NORTH, btnList, 150, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, btnList, 94, SpringLayout.WEST, pan);
	pan.add(btnList);

	btnSaveAndExit = new JButton("Save and Exit");
	slPanel.putConstraint(SpringLayout.NORTH, btnSaveAndExit, 264, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, btnSaveAndExit, 69, SpringLayout.WEST, pan);
	pan.add(btnSaveAndExit);

	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
}
 
Example 10
Source File: TooltipAndTargetPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Layout all inner components.
 */
public void layoutComponents() {
  final int basicIndent = 0;
  final int verticalGap = 2;
  final int horizontalGap = 4;

  setLayout( new GridLayout( 1, 2 ) );

  JPanel tgPanel = new JPanel();
  JPanel ttPanel = new JPanel();
  add( tgPanel );
  add( ttPanel );

  SpringLayout targetLayout = new SpringLayout();
  tgPanel.setLayout( targetLayout );
  tgPanel.add( targetLabel );
  targetLayout.putConstraint( SpringLayout.NORTH, targetLabel, basicIndent, SpringLayout.NORTH, tgPanel );
  targetLayout.putConstraint( SpringLayout.EAST, targetLabel, -horizontalGap, SpringLayout.EAST, tgPanel );
  targetLayout.putConstraint( SpringLayout.WEST, targetLabel, basicIndent, SpringLayout.WEST, tgPanel );
  tgPanel.add( targetComboBox );
  targetLayout.putConstraint( SpringLayout.NORTH, targetComboBox, verticalGap, SpringLayout.SOUTH, targetLabel );
  targetLayout.putConstraint( SpringLayout.EAST, targetComboBox, -horizontalGap, SpringLayout.EAST, tgPanel );
  targetLayout.putConstraint( SpringLayout.WEST, targetComboBox, basicIndent, SpringLayout.WEST, tgPanel );
  targetLayout.putConstraint( SpringLayout.SOUTH, tgPanel, basicIndent, SpringLayout.SOUTH, targetComboBox ); // Order is important! --Kaa

  SpringLayout tooltipLayout = new SpringLayout();
  ttPanel.setLayout( tooltipLayout );
  ttPanel.add( tooltipLabel );
  tooltipLayout.putConstraint( SpringLayout.NORTH, tooltipLabel, basicIndent, SpringLayout.NORTH, ttPanel );
  tooltipLayout.putConstraint( SpringLayout.EAST, tooltipLabel, basicIndent, SpringLayout.EAST, ttPanel );
  tooltipLayout.putConstraint( SpringLayout.WEST, tooltipLabel, 0, SpringLayout.WEST, ttPanel );
  ttPanel.add( tooltipPanel );
  tooltipLayout.putConstraint( SpringLayout.NORTH, tooltipPanel, verticalGap, SpringLayout.SOUTH, tooltipLabel );
  tooltipLayout.putConstraint( SpringLayout.EAST, tooltipPanel, basicIndent, SpringLayout.EAST, ttPanel );
  tooltipLayout.putConstraint( SpringLayout.WEST, tooltipPanel, 0, SpringLayout.WEST, ttPanel );
  tooltipLayout.putConstraint( SpringLayout.SOUTH, ttPanel, basicIndent, SpringLayout.SOUTH, tooltipPanel ); // Order is important! --Kaa
}
 
Example 11
Source File: InsectFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public InsectFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	beeButton = new JButton("Bee");
	slPanel.putConstraint(SpringLayout.NORTH, beeButton, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, beeButton, 93, SpringLayout.WEST, pan);
	pan.add(beeButton);

	beetleButton = new JButton("Beetle");
	slPanel.putConstraint(SpringLayout.NORTH, beetleButton, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, beetleButton, 93, SpringLayout.WEST, pan);
	pan.add(beetleButton);

	butterflyButton = new JButton("Butterfly");
	slPanel.putConstraint(SpringLayout.NORTH, butterflyButton, 135, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, butterflyButton, 93, SpringLayout.WEST, pan);
	pan.add(butterflyButton);

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);

}
 
Example 12
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public AddFrame(String title) {
	super(title);

	contentPanel.setLayout(new GridLayout(0, 1, 1, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	SpringLayout slPanel = new SpringLayout();
	panel.setLayout(slPanel);

	/** ANIMALS **/
	animalsButton = new JButton("Animals");
	slPanel.putConstraint(SpringLayout.NORTH, animalsButton, 60, SpringLayout.NORTH, panel);
	slPanel.putConstraint(SpringLayout.WEST, animalsButton, 200, SpringLayout.WEST, panel);
	panel.add(animalsButton);

	// creating buttons with types of animals
	String animalNames[] = Species.getAllConstants();
	int count = 0;
	for (String typeOfAnimal : animalNames) {
		JButton typeOfAnimalButton = new JButton(typeOfAnimal);
		typesOfAnimalsButtons.add(typeOfAnimalButton);
		slPanel.putConstraint(SpringLayout.NORTH, typeOfAnimalButton, 100 + count * 40, SpringLayout.NORTH, panel);
		slPanel.putConstraint(SpringLayout.WEST, typeOfAnimalButton, 250, SpringLayout.WEST, panel);
		panel.add(typeOfAnimalButton);
		count++;
	}
	animalsButtonVisibility = false;
	addMouseListener(animalsButton, typesOfAnimalsButtons, animalsButtonVisibility);

	/** EMPLOYEES **/
	employeesButton = new JButton("Employees");
	slPanel.putConstraint(SpringLayout.NORTH, employeesButton, 60, SpringLayout.NORTH, panel);
	slPanel.putConstraint(SpringLayout.WEST, employeesButton, 350, SpringLayout.WEST, panel);
	panel.add(employeesButton);

	// creating buttons with types of employees
	String employeeTypes[] = EmployeesType.getAllConstants();
	count = 0;
	for (String typeOfEmployee : employeeTypes) {
		JButton typeOfEmployeeButton = new JButton(typeOfEmployee);
		typesOfEmployeesButtons.add(typeOfEmployeeButton);
		slPanel.putConstraint(SpringLayout.NORTH, typeOfEmployeeButton, 100 + count * 40, SpringLayout.NORTH,
				panel);
		slPanel.putConstraint(SpringLayout.WEST, typeOfEmployeeButton, 400, SpringLayout.WEST, panel);
		panel.add(typeOfEmployeeButton);
		count++;
	}
	employeesButtonVisibility = false;
	addMouseListener(employeesButton, typesOfEmployeesButtons, employeesButtonVisibility);

	setVisible(true);
}
 
Example 13
Source File: SummaryPanel.java    From swift-k with Apache License 2.0 4 votes vote down vote up
private void makeProgressBars(SpringLayout l) {
    JComponent prevLabel = null, prevBar = null;
    bars = new JProgressBar[SummaryItem.STATES.length];
    
    SpringLayout ls = new SpringLayout();
    JPanel appSummary = new JPanel();
    appSummary.setBorder(BorderFactory.createTitledBorder(
        BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "App Summary"));
    add(appSummary);
    l.putConstraint(SpringLayout.WEST, appSummary, 5, SpringLayout.WEST, this);
    l.putConstraint(SpringLayout.EAST, appSummary, -5, SpringLayout.EAST, this);
    l.putConstraint(SpringLayout.NORTH, appSummary, 25, SpringLayout.NORTH, this);
    
    appSummary.setLayout(ls);
    
    
    for (int i = 0; i < SummaryItem.STATES.length; i++) {
        JLabel label = new JLabel(SummaryItem.STATES[i] + ":");
        appSummary.add(label);
        
        JProgressBar lb = new JProgressBar();
        bars[i] = lb;
        lb.setString("0");
        lb.setStringPainted(true);
        appSummary.add(lb);
    
        fixEdges(ls, label, lb, appSummary);
        if (prevLabel == null) {
            ls.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, appSummary);
        }
        else {
            ls.putConstraint(SpringLayout.NORTH, label, 10, SpringLayout.SOUTH, prevLabel);
        }
        prevLabel = label;
        prevBar = lb;
    }
    
    JLabel hl = new JLabel("Heap:");
    memory = makeProgress(l, hl);
    
    l.putConstraint(SpringLayout.SOUTH, appSummary, -25, SpringLayout.NORTH, hl);
    l.putConstraint(SpringLayout.SOUTH, hl, -25, SpringLayout.SOUTH, this);
    
    Spring maxW = Spring.constant(0);
    
    for (int i = 0; i < SummaryItem.STATES.length; i++) {
        maxW = Spring.max(maxW, ls.getConstraints(appSummary.getComponent(i * 2)).getWidth());
    }
    
    for (int i = 0; i < SummaryItem.STATES.length; i++) {
        SpringLayout.Constraints c = ls.getConstraints(appSummary.getComponent(i * 2));
        c.setWidth(maxW);
    }
}
 
Example 14
Source File: CaretakerFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public CaretakerFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
	
	JPanel panel = new JPanel(); 
	// adding empty panel to fill grid layout
	contentPanel.add(panel);

	pan = new JPanel();
	contentPanel.add(pan);
	slPanel = new SpringLayout();
	pan.setLayout(slPanel);
	
	JLabel text1 = new JLabel("First of all, choose caretaker attributes");
	slPanel.putConstraint(SpringLayout.NORTH, text1, 20, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, text1, 0, SpringLayout.WEST, pan);
	pan.add(text1);	
	
	
	/** TEXT FIELDS for RETRIEVING ATTRIBUTES **/
	//for name	
	JLabel nameLabel = new JLabel("Name:");
	slPanel.putConstraint(SpringLayout.NORTH, nameLabel, 40, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, nameLabel, 90, SpringLayout.WEST, pan);
	pan.add(nameLabel);	
	nameTextField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, nameTextField, 60, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, nameTextField, 90, SpringLayout.WEST, pan);
	pan.add(nameTextField);
	
	//for nr of legs
	JLabel idLabel = new JLabel("Id:");
	slPanel.putConstraint(SpringLayout.NORTH, idLabel, 80, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, idLabel, 90, SpringLayout.WEST, pan);
	pan.add(idLabel);
	idTextField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH,idTextField, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, idTextField, 90, SpringLayout.WEST, pan);
	pan.add(idTextField);
	
	JLabel salaryLabel = new JLabel("Salary:");
	slPanel.putConstraint(SpringLayout.NORTH, salaryLabel, 120, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST,salaryLabel, 90, SpringLayout.WEST, pan);
	pan.add(salaryLabel);
	salaryTextField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH,salaryTextField, 140, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST,salaryTextField, 90, SpringLayout.WEST, pan);
	pan.add(salaryTextField);
	
	JLabel workingHoursLabel = new JLabel("Working hours:");
	slPanel.putConstraint(SpringLayout.NORTH, workingHoursLabel, 160, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST,workingHoursLabel, 90, SpringLayout.WEST, pan);
	pan.add(workingHoursLabel);
	workingHoursTextField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH,workingHoursTextField, 180, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST,workingHoursTextField, 90, SpringLayout.WEST, pan);
	pan.add(workingHoursTextField);
	
	JLabel isDeadLabel = new JLabel("Is he/she dead?");
	slPanel.putConstraint(SpringLayout.NORTH, isDeadLabel, 200, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, isDeadLabel, 90, SpringLayout.WEST, pan);
	pan.add(isDeadLabel);
	isDeadYesCheckBox = new JCheckBox("Yes");
	slPanel.putConstraint(SpringLayout.NORTH,isDeadYesCheckBox, 220, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, isDeadYesCheckBox, 90, SpringLayout.WEST, pan);
	pan.add(isDeadYesCheckBox);
	isDeadNoCheckBox = new JCheckBox("No");
	slPanel.putConstraint(SpringLayout.NORTH,isDeadNoCheckBox, 240, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, isDeadNoCheckBox, 90, SpringLayout.WEST, pan);
	pan.add(isDeadNoCheckBox);
	
	addButton = new JButton("Add");
	slPanel.putConstraint(SpringLayout.NORTH, addButton, 280, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, addButton, 90, SpringLayout.WEST, pan);
	pan.add(addButton);
	
	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
	
}
 
Example 15
Source File: AnimalFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public AnimalFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	mammalButton = new JButton("Mammal");
	slPanel.putConstraint(SpringLayout.NORTH, mammalButton, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, mammalButton, 93, SpringLayout.WEST, pan);
	pan.add(mammalButton);

	birdButton = new JButton("     Bird    ");
	slPanel.putConstraint(SpringLayout.NORTH, birdButton, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, birdButton, 93, SpringLayout.WEST, pan);
	pan.add(birdButton);

	aquaticButton = new JButton(" Aquatic ");
	slPanel.putConstraint(SpringLayout.NORTH, aquaticButton, 135, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, aquaticButton, 93, SpringLayout.WEST, pan);
	pan.add(aquaticButton);

	reptileButton = new JButton(" Reptile  ");
	slPanel.putConstraint(SpringLayout.NORTH, reptileButton, 170, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, reptileButton, 93, SpringLayout.WEST, pan);
	pan.add(reptileButton);

	insectButton = new JButton("  Insect   ");
	slPanel.putConstraint(SpringLayout.NORTH, insectButton, 205, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, insectButton, 93, SpringLayout.WEST, pan);
	pan.add(insectButton);

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);
}
 
Example 16
Source File: CreateRFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param title
 */
public CreateRFrame(final String title) {
	super(title);

	// Sets up the view and adds the components
	contentPanel.setLayout(new GridLayout(2, 7, 0, 0));
	JPanel calcPanel = new JPanel();
	contentPanel.add(calcPanel);
	SpringLayout slPanel = new SpringLayout();
	calcPanel.setLayout(slPanel);
	JLabel l = new JLabel("Name:", JLabel.TRAILING);
	calcPanel.add(l);
	slPanel.putConstraint(SpringLayout.NORTH, l, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l, 0, SpringLayout.WEST, calcPanel);
	l.setLabelFor(name);
	calcPanel.add(name);
	slPanel.putConstraint(SpringLayout.NORTH, name, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, name, 120, SpringLayout.WEST, calcPanel);
	JLabel l1 = new JLabel("Number of legs:", JLabel.TRAILING);
	calcPanel.add(l1);
	l1.setLabelFor(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, l1, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l1, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, nrOfLegs, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, nrOfLegs, 120, SpringLayout.WEST, calcPanel);
	JLabel l4 = new JLabel("Danger percentage:", JLabel.TRAILING);
	calcPanel.add(l4);
	l4.setLabelFor(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, l4, 90, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l4, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, dangerPerc, 90, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, dangerPerc, 120, SpringLayout.WEST, calcPanel);
	JLabel l5 = new JLabel("Maintenance cost:", JLabel.TRAILING);
	calcPanel.add(l5);
	l5.setLabelFor(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, l5, 110, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l5, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, maintenanceCost, 110, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, maintenanceCost, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(createButton);
	slPanel.putConstraint(SpringLayout.NORTH, createButton, 130, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, createButton, 160, SpringLayout.WEST, calcPanel);
	JLabel l3 = new JLabel("Lays eggs?:", JLabel.TRAILING);
	calcPanel.add(l3);
	l3.setLabelFor(layEggsT);

	slPanel.putConstraint(SpringLayout.NORTH, l3, 64, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l3, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(layEggsT);
	slPanel.putConstraint(SpringLayout.NORTH, layEggsT, 64, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, layEggsT, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(layEggsF);
	slPanel.putConstraint(SpringLayout.NORTH, layEggsF, 64, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, layEggsF, 170, SpringLayout.WEST, calcPanel);
	ButtonGroup group1 = new ButtonGroup();
	group1.add(layEggsT);
	group1.add(layEggsF);

	JLabel l6 = new JLabel("Choose reptile:", JLabel.TRAILING);
	calcPanel.add(l6);
	l6.setLabelFor(boomslang);

	slPanel.putConstraint(SpringLayout.NORTH, l6, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l6, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(boomslang);
	slPanel.putConstraint(SpringLayout.NORTH, boomslang, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, boomslang, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(tuatara);
	slPanel.putConstraint(SpringLayout.NORTH, tuatara, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, tuatara, 210, SpringLayout.WEST, calcPanel);
	calcPanel.add(turtle);
	slPanel.putConstraint(SpringLayout.NORTH, turtle, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, turtle, 280, SpringLayout.WEST, calcPanel);
	ButtonGroup group = new ButtonGroup();
	group.add(boomslang);
	group.add(tuatara);
	group.add(turtle);

}
 
Example 17
Source File: CreateMFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param title
 *            Title of the frame.
 */
public CreateMFrame(final String title) {
	super(title);

	// Sets up the view and adds the components
	contentPanel.setLayout(new GridLayout(2, 7, 0, 0));
	JPanel calcPanel = new JPanel();
	contentPanel.add(calcPanel);
	SpringLayout slPanel = new SpringLayout();
	calcPanel.setLayout(slPanel);
	JLabel l = new JLabel("Name:", JLabel.TRAILING);
	calcPanel.add(l);
	slPanel.putConstraint(SpringLayout.NORTH, l, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l, 0, SpringLayout.WEST, calcPanel);
	l.setLabelFor(name);
	calcPanel.add(name);
	slPanel.putConstraint(SpringLayout.NORTH, name, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, name, 130, SpringLayout.WEST, calcPanel);
	JLabel l1 = new JLabel("Number of legs:", JLabel.TRAILING);
	calcPanel.add(l1);
	l1.setLabelFor(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, l1, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l1, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, nrOfLegs, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, nrOfLegs, 130, SpringLayout.WEST, calcPanel);
	JLabel l2 = new JLabel("Percentage body hair:", JLabel.TRAILING);
	calcPanel.add(l2);
	l2.setLabelFor(percBodyHair);
	slPanel.putConstraint(SpringLayout.NORTH, l2, 65, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l2, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(percBodyHair);
	slPanel.putConstraint(SpringLayout.NORTH, percBodyHair, 65, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, percBodyHair, 130, SpringLayout.WEST, calcPanel);
	JLabel l3 = new JLabel("Normal body temp:", JLabel.TRAILING);
	calcPanel.add(l3);
	slPanel.putConstraint(SpringLayout.NORTH, l3, 85, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l3, 0, SpringLayout.WEST, calcPanel);
	l3.setLabelFor(normalBodyTemp);
	calcPanel.add(normalBodyTemp);
	slPanel.putConstraint(SpringLayout.NORTH, normalBodyTemp, 85, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, normalBodyTemp, 130, SpringLayout.WEST, calcPanel);
	JLabel l4 = new JLabel("Danger percentage:", JLabel.TRAILING);
	calcPanel.add(l4);
	l4.setLabelFor(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, l4, 105, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l4, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, dangerPerc, 105, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, dangerPerc, 130, SpringLayout.WEST, calcPanel);
	JLabel l5 = new JLabel("Maintenance cost:", JLabel.TRAILING);
	calcPanel.add(l5);
	l5.setLabelFor(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, l5, 125, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l5, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, maintenanceCost, 125, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, maintenanceCost, 130, SpringLayout.WEST, calcPanel);
	calcPanel.add(createButton);
	slPanel.putConstraint(SpringLayout.NORTH, createButton, 165, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, createButton, 150, SpringLayout.WEST, calcPanel);
	JLabel l6 = new JLabel("Choose mammal:", JLabel.TRAILING);
	calcPanel.add(l6);
	l6.setLabelFor(cow);

	slPanel.putConstraint(SpringLayout.NORTH, l6, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l6, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(cow);
	slPanel.putConstraint(SpringLayout.NORTH, cow, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, cow, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(monkey);
	slPanel.putConstraint(SpringLayout.NORTH, monkey, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, monkey, 180, SpringLayout.WEST, calcPanel);
	calcPanel.add(tiger);
	slPanel.putConstraint(SpringLayout.NORTH, tiger, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, tiger, 250, SpringLayout.WEST, calcPanel);
	ButtonGroup group = new ButtonGroup();
	group.add(cow);
	group.add(monkey);
	group.add(tiger);

}
 
Example 18
Source File: CreateBFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param title
 *            Title of the frame.
 */
public CreateBFrame(final String title) {
	super(title);

	// Sets up the view and adds the components
	contentPanel.setLayout(new GridLayout(2, 7, 0, 0));
	JPanel calcPanel = new JPanel();
	contentPanel.add(calcPanel);
	SpringLayout slPanel = new SpringLayout();
	calcPanel.setLayout(slPanel);
	JLabel l = new JLabel("Name:", JLabel.TRAILING);
	calcPanel.add(l);
	slPanel.putConstraint(SpringLayout.NORTH, l, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l, 0, SpringLayout.WEST, calcPanel);
	l.setLabelFor(name);
	calcPanel.add(name);
	slPanel.putConstraint(SpringLayout.NORTH, name, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, name, 127, SpringLayout.WEST, calcPanel);
	JLabel l1 = new JLabel("Number of legs:", JLabel.TRAILING);
	calcPanel.add(l1);
	l1.setLabelFor(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, l1, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l1, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, nrOfLegs, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, nrOfLegs, 127, SpringLayout.WEST, calcPanel);
	JLabel l2 = new JLabel("Average flight altitude:", JLabel.TRAILING);
	calcPanel.add(l2);
	l2.setLabelFor(avgFlightAltitude);
	slPanel.putConstraint(SpringLayout.NORTH, l2, 65, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l2, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(avgFlightAltitude);
	slPanel.putConstraint(SpringLayout.NORTH, avgFlightAltitude, 65, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, avgFlightAltitude, 127, SpringLayout.WEST, calcPanel);
	JLabel l4 = new JLabel("Danger percentage:", JLabel.TRAILING);
	calcPanel.add(l4);
	l4.setLabelFor(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, l4, 107, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l4, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, dangerPerc, 110, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, dangerPerc, 127, SpringLayout.WEST, calcPanel);
	JLabel l5 = new JLabel("Maintenance cost:", JLabel.TRAILING);
	calcPanel.add(l5);
	l5.setLabelFor(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, l5, 127, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l5, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, maintenanceCost, 127, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, maintenanceCost, 127, SpringLayout.WEST, calcPanel);
	calcPanel.add(createButton);
	slPanel.putConstraint(SpringLayout.NORTH, createButton, 155, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, createButton, 160, SpringLayout.WEST, calcPanel);
	JLabel l3 = new JLabel("Migrates:", JLabel.TRAILING);
	calcPanel.add(l3);
	l3.setLabelFor(migratesT);

	slPanel.putConstraint(SpringLayout.NORTH, l3, 85, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l3, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(migratesT);
	slPanel.putConstraint(SpringLayout.NORTH, migratesT, 85, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, migratesT, 127, SpringLayout.WEST, calcPanel);
	slPanel.putConstraint(SpringLayout.NORTH, migratesF, 85, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, migratesF, 187, SpringLayout.WEST, calcPanel);
	calcPanel.add(migratesF);
	ButtonGroup group = new ButtonGroup();
	group.add(migratesT);
	group.add(migratesF);
	JLabel l6 = new JLabel("Choose bird:", JLabel.TRAILING);
	calcPanel.add(l6);
	l6.setLabelFor(pelican);

	slPanel.putConstraint(SpringLayout.NORTH, l6, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l6, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(pelican);
	slPanel.putConstraint(SpringLayout.NORTH, pelican, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, pelican, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(whitestork);
	slPanel.putConstraint(SpringLayout.NORTH, whitestork, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, whitestork, 190, SpringLayout.WEST, calcPanel);
	calcPanel.add(eagle);
	slPanel.putConstraint(SpringLayout.NORTH, eagle, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, eagle, 280, SpringLayout.WEST, calcPanel);
	ButtonGroup group1 = new ButtonGroup();
	group1.add(pelican);
	group1.add(whitestork);
	group1.add(eagle);
}
 
Example 19
Source File: CreateAFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param title
 *            The title of the frame.
 */
public CreateAFrame(final String title) {
	super(title);

	// Sets up the view and adds the components
	contentPanel.setLayout(new GridLayout(2, 7, 0, 0));
	JPanel calcPanel = new JPanel();
	contentPanel.add(calcPanel);
	SpringLayout slPanel = new SpringLayout();
	calcPanel.setLayout(slPanel);
	JLabel l = new JLabel("Name:", JLabel.TRAILING);
	calcPanel.add(l);
	slPanel.putConstraint(SpringLayout.NORTH, l, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l, 0, SpringLayout.WEST, calcPanel);
	l.setLabelFor(name);
	calcPanel.add(name);
	slPanel.putConstraint(SpringLayout.NORTH, name, 25, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, name, 120, SpringLayout.WEST, calcPanel);
	JLabel l1 = new JLabel("Number of legs:", JLabel.TRAILING);
	calcPanel.add(l1);
	l1.setLabelFor(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, l1, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l1, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(nrOfLegs);
	slPanel.putConstraint(SpringLayout.NORTH, nrOfLegs, 45, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, nrOfLegs, 120, SpringLayout.WEST, calcPanel);
	JLabel l2 = new JLabel("Average swim depth:", JLabel.TRAILING);
	calcPanel.add(l2);
	l2.setLabelFor(avgSwimDepth);
	slPanel.putConstraint(SpringLayout.NORTH, l2, 65, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l2, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(avgSwimDepth);
	slPanel.putConstraint(SpringLayout.NORTH, avgSwimDepth, 65, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, avgSwimDepth, 120, SpringLayout.WEST, calcPanel);
	JLabel l3 = new JLabel("Water type:", JLabel.TRAILING);
	calcPanel.add(l3);
	slPanel.putConstraint(SpringLayout.NORTH, l3, 89, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l3, 0, SpringLayout.WEST, calcPanel);
	l3.setLabelFor(fwater);
	calcPanel.add(fwater);
	slPanel.putConstraint(SpringLayout.NORTH, fwater, 87, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, fwater, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(swater);
	slPanel.putConstraint(SpringLayout.NORTH, swater, 87, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, swater, 220, SpringLayout.WEST, calcPanel);
	ButtonGroup group = new ButtonGroup();
	group.add(fwater);
	group.add(swater);
	JLabel l4 = new JLabel("Danger percentage:", JLabel.TRAILING);
	calcPanel.add(l4);
	l4.setLabelFor(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, l4, 115, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l4, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(dangerPerc);
	slPanel.putConstraint(SpringLayout.NORTH, dangerPerc, 115, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, dangerPerc, 120, SpringLayout.WEST, calcPanel);
	JLabel l5 = new JLabel("Maintenance cost:", JLabel.TRAILING);
	calcPanel.add(l5);
	l5.setLabelFor(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, l5, 135, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l5, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(maintenanceCost);
	slPanel.putConstraint(SpringLayout.NORTH, maintenanceCost, 135, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, maintenanceCost, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(createButton);
	slPanel.putConstraint(SpringLayout.NORTH, createButton, 160, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, createButton, 150, SpringLayout.WEST, calcPanel);
	JLabel l6 = new JLabel("Choose aquatic:", JLabel.TRAILING);
	calcPanel.add(l6);
	l6.setLabelFor(shark);

	slPanel.putConstraint(SpringLayout.NORTH, l6, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, l6, 0, SpringLayout.WEST, calcPanel);
	calcPanel.add(shark);
	slPanel.putConstraint(SpringLayout.NORTH, shark, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, shark, 120, SpringLayout.WEST, calcPanel);
	calcPanel.add(northernPike);
	slPanel.putConstraint(SpringLayout.NORTH, northernPike, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, northernPike, 183, SpringLayout.WEST, calcPanel);
	calcPanel.add(tuna);
	slPanel.putConstraint(SpringLayout.NORTH, tuna, 0, SpringLayout.NORTH, calcPanel);
	slPanel.putConstraint(SpringLayout.WEST, tuna, 280, SpringLayout.WEST, calcPanel);
	ButtonGroup group1 = new ButtonGroup();
	group1.add(shark);
	group1.add(northernPike);
	group1.add(tuna);

}
 
Example 20
Source File: AquaticFormFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public AquaticFormFrame(String title) {
	super(title);

	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));

	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);

	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	nameLabel = new JLabel("Name: ");
	slPanel.putConstraint(SpringLayout.NORTH, nameLabel, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, nameLabel, 93, SpringLayout.WEST, pan);
	pan.add(nameLabel);

	swimLabel = new JLabel("Avgerage swim depth: ");
	slPanel.putConstraint(SpringLayout.NORTH, swimLabel, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, swimLabel, 93, SpringLayout.WEST, pan);
	pan.add(swimLabel);

	dangerPercLabel = new JLabel("Danger percentage: ");
	slPanel.putConstraint(SpringLayout.NORTH, dangerPercLabel, 135, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, dangerPercLabel, 93, SpringLayout.WEST, pan);
	pan.add(dangerPercLabel);

	legsLabel = new JLabel("Number of legs: ");
	slPanel.putConstraint(SpringLayout.NORTH, legsLabel, 170, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, legsLabel, 93, SpringLayout.WEST, pan);
	pan.add(legsLabel);

	maintCostLabel = new JLabel("Maintenance cost: ");
	slPanel.putConstraint(SpringLayout.NORTH, maintCostLabel, 205, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, maintCostLabel, 93, SpringLayout.WEST, pan);
	pan.add(maintCostLabel);

	takenCareOfLabel = new JLabel("Taken care of: ");
	slPanel.putConstraint(SpringLayout.NORTH, takenCareOfLabel, 240, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, takenCareOfLabel, 93, SpringLayout.WEST, pan);
	pan.add(takenCareOfLabel);

	isDangerousLabel = new JLabel("Is dangerous: ");
	slPanel.putConstraint(SpringLayout.NORTH, isDangerousLabel, 275, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, isDangerousLabel, 93, SpringLayout.WEST, pan);
	pan.add(isDangerousLabel);

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);

	rightPanel.setLayout(slPanel);

	nameField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, nameField, 65, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, nameField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(nameField);

	swimField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, swimField, 100, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, swimField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(swimField);

	dangerPercField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, dangerPercField, 135, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, dangerPercField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(dangerPercField);

	legsField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, legsField, 170, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, legsField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(legsField);

	maintCostField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, maintCostField, 205, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, maintCostField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(maintCostField);

	takenCareOfField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, takenCareOfField, 240, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, takenCareOfField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(takenCareOfField);

	isDangerousField = new JTextField(10);
	slPanel.putConstraint(SpringLayout.NORTH, isDangerousField, 275, SpringLayout.NORTH, rightPanel);
	slPanel.putConstraint(SpringLayout.WEST, isDangerousField, 93, SpringLayout.WEST, rightPanel);
	rightPanel.add(isDangerousField);

	EnterKeyActionListener enterK = new EnterKeyActionListener();
	nameField.addActionListener(enterK);
	swimField.addActionListener(enterK);
	dangerPercField.addActionListener(enterK);
	legsField.addActionListener(enterK);
	maintCostField.addActionListener(enterK);
	takenCareOfField.addActionListener(enterK);
	isDangerousField.addActionListener(enterK);
}