Java Code Examples for javax.swing.SpringLayout

The following examples show how to use javax.swing.SpringLayout. These examples are extracted from open source projects. 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 Project: PacketProxy   Source File: GUIServerNamePanel.java    License: Apache License 2.0 6 votes vote down vote up
public GUIServerNamePanel() {
	setPreferredSize(new Dimension(100, 24));
	setMinimumSize(new Dimension(10, 24));
	setMaximumSize(new Dimension(1000, 24));
	SpringLayout layout = new SpringLayout();
	setLayout(layout);

	client_label = new JLabel(" ");
	client_label.setHorizontalAlignment(JLabel.LEFT);
	client_label.setVerticalAlignment(JLabel.TOP);
	layout.putConstraint(SpringLayout.WEST, client_label, 10, SpringLayout.WEST, this);
	layout.putConstraint(SpringLayout.NORTH, client_label, 4, SpringLayout.NORTH, this);
	add(client_label);

	server_label = new JLabel(" ");
	server_label.setHorizontalAlignment(JLabel.LEFT);
	server_label.setVerticalAlignment(JLabel.TOP);
	layout.putConstraint(SpringLayout.WEST, server_label, 0, SpringLayout.EAST, client_label);
	layout.putConstraint(SpringLayout.NORTH, server_label, 4, SpringLayout.NORTH, this);
	add(server_label);
}
 
Example 2
Source Project: JavaMainRepo   Source File: MainMenuFrame.java    License: Apache License 2.0 6 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 3
Source Project: JavaMainRepo   Source File: EmployeeFrame.java    License: Apache License 2.0 6 votes vote down vote up
public EmployeeFrame(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);

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

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);
}
 
Example 4
Source Project: JavaMainRepo   Source File: AddFrame.java    License: Apache License 2.0 6 votes vote down vote up
public AddFrame(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);

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

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

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);
}
 
Example 5
@Override
protected JPanel createPatternsPanel() {
    JPanel patternsPanel = new JPanel(new SpringLayout());
    TitledBorder titledBorder = BorderFactory.createTitledBorder(Bundle.CTL_Panel_OutputPattern_Border_TitleText());
    titledBorder.setTitleJustification(TitledBorder.CENTER);
    patternsPanel.setBorder(titledBorder);

    TextFieldEditor textEditor = new TextFieldEditor();
    addTextField(patternsPanel, textEditor, Bundle.CTL_Label_ProgressPattern(),
                 ToolAdapterConstants.PROGRESS_PATTERN, false, null);
    propertyContainer.getDescriptor(ToolAdapterConstants.PROGRESS_PATTERN)
            .setValidator(new RegexFieldValidator());
    addTextField(patternsPanel, textEditor, Bundle.CTL_Label_StepPattern(),
                 ToolAdapterConstants.STEP_PATTERN, false, null);
    propertyContainer.getDescriptor(ToolAdapterConstants.STEP_PATTERN)
            .setValidator(new RegexFieldValidator());
    addTextField(patternsPanel, textEditor, Bundle.CTL_Label_ErrorPattern(),
                 ToolAdapterConstants.ERROR_PATTERN, false, null);
    propertyContainer.getDescriptor(ToolAdapterConstants.ERROR_PATTERN)
            .setValidator(new RegexFieldValidator());

    SpringUtilities.makeCompactGrid(patternsPanel, 3, 2,
                                    DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    return patternsPanel;
}
 
Example 6
/**
 * Constructor.
 *
 * @param model model used by this view
 */
public ObjectPropertiesView(ObjectPropertiesModel model)
{
   SpringLayout springLayout = new SpringLayout();
   setLayout(springLayout);

   JTable table = new JTable();
   JScrollPane scrollPane = new JScrollPane(table);
   springLayout.putConstraint(SpringLayout.NORTH, scrollPane, 0, SpringLayout.NORTH, this);
   springLayout.putConstraint(SpringLayout.WEST, scrollPane, 0, SpringLayout.WEST, this);
   springLayout.putConstraint(SpringLayout.SOUTH, scrollPane, 0, SpringLayout.SOUTH, this);
   springLayout.putConstraint(SpringLayout.EAST, scrollPane, 0, SpringLayout.EAST, this);
   add(scrollPane);

   PropertyConnector.connect(table, "model", model, "tableModel");
}
 
Example 7
Source Project: JavaMainRepo   Source File: EmployeeFrame.java    License: Apache License 2.0 6 votes vote down vote up
public EmployeeFrame(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);

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

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);
}
 
Example 8
Source Project: JavaMainRepo   Source File: EmployeeFrame.java    License: 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 9
Source Project: JavaMainRepo   Source File: ListFrame.java    License: 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 10
Source Project: jdal   Source File: SpringUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private static SpringLayout.Constraints getConstraintsForCell(
                                            int row, int col,
                                            Container parent,
                                            int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
 
Example 11
Source Project: swift-k   Source File: SummaryPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void fixEdges(SpringLayout l, JLabel label, JComponent c, JComponent container) {
    if (label == null) {
        l.putConstraint(SpringLayout.WEST, c, 5, SpringLayout.WEST, container);
        l.putConstraint(SpringLayout.EAST, c, -5, SpringLayout.EAST, container);
    }
    else {
        l.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, container);
        l.putConstraint(SpringLayout.WEST, c, 5, SpringLayout.EAST, label);
        l.putConstraint(SpringLayout.EAST, c, -5, SpringLayout.EAST, container);
        l.putConstraint(SpringLayout.NORTH, c, 0, SpringLayout.NORTH, label);
    }
}
 
Example 12
private static SpringLayout.Constraints getConstraintsForCell(
                                            int row, int col,
                                            Container parent,
                                            int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
 
Example 13
Source Project: swift-k   Source File: SpringUtils.java    License: 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 14
Source Project: iBioSim   Source File: SpringUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private static SpringLayout.Constraints getConstraintsForCell(
                                            int row, int col,
                                            Container parent,
                                            int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
 
Example 15
Source Project: swift-k   Source File: SummaryPanel.java    License: Apache License 2.0 5 votes vote down vote up
public SummaryPanel(SystemState state) {
    this.state = state;
    this.start = state.getCurrentTime();
    SpringLayout l = new SpringLayout();
    setLayout(l);
    
    makeProgressBars(l);
    
    GlobalTimer.getTimer().schedule(new TimerTask() {
        public void run() {
            update();
        }
    }, 1000, 1000);
}
 
Example 16
Source Project: Astrosoft   Source File: SpringUtilities.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static SpringLayout.Constraints getConstraintsForCell(
                                            int row, int col,
                                            Container parent,
                                            int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
 
Example 17
@Override
protected JPanel createBundlePanel() {
    JPanel bundlePanel = new JPanel(new SpringLayout());
    int rows = 0;
    bundleForm = new BundleForm(this.context,
                                newOperatorDescriptor.getWindowsBundle(),
                                newOperatorDescriptor.getLinuxBundle(),
                                newOperatorDescriptor.getMacosxBundle(),
                                newOperatorDescriptor.getVariables());
    bundlePanel.add(bundleForm);
    rows++;
    org.esa.snap.core.gpf.descriptor.dependency.Bundle currentBundle = newOperatorDescriptor.getBundle();
    JButton button = renderInstallButton(currentBundle, bundlePanel);
    JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.setMaximumSize(new Dimension(buttonPanel.getWidth(), controlHeight));
    buttonPanel.add(button, BorderLayout.EAST);
    bundlePanel.add(buttonPanel);
    bundleForm.setPropertyChangeListener(evt -> {
        org.esa.snap.core.gpf.descriptor.dependency.Bundle bundle =
                (org.esa.snap.core.gpf.descriptor.dependency.Bundle) evt.getSource();
        button.setText((bundle.getLocation() == BundleLocation.REMOTE ?
                "Download and " :
                "") + "Install Now");
        button.setToolTipText(bundle.getLocation() == BundleLocation.REMOTE ?
                                      bundle.getDownloadURL() :
                                      bundle.getSource() != null ?
                                              bundle.getSource().toString() : "");
        button.setMaximumSize(button.getPreferredSize());
        button.setVisible(canInstall(bundle));
    });
    rows++;
    SpringUtilities.makeCompactGrid(bundlePanel, rows, 1,
                                    DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);
    return bundlePanel;
}
 
Example 18
Source Project: mars-sim   Source File: SpringUtilities.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static SpringLayout.Constraints getConstraintsForCell(
                                            int row, int col,
                                            Container parent,
                                            int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
 
Example 19
Source Project: pcgen   Source File: GameModePanel.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc)
{
	panel.setLayout(layout);
	JLabel introLabel = new JLabel("Please select the Game Mode to Convert:");
	panel.add(introLabel);
	layout.putConstraint(SpringLayout.NORTH, introLabel, 50, SpringLayout.NORTH, panel);
	layout.putConstraint(SpringLayout.WEST, introLabel, 25, SpringLayout.WEST, panel);

	List<GameMode> games = SystemCollections.getUnmodifiableGameModeList();
	gameModeCombo = new JComboBox<>(games.toArray());
	gameModeCombo.addActionListener(arg0 -> {
		getSelection(pc);
		saveGameMode(pc);
	});
	PCGenSettings context = PCGenSettings.getInstance();
	SettingsHandler
		.setGame(context.initProperty(PCGenSettings.CONVERT_GAMEMODE, SettingsHandler.getGameAsProperty().get().getName()));
	GameMode currGame = SettingsHandler.getGameAsProperty().get();
	if (pc.get(ObjectKey.GAME_MODE) != null)
	{
		currGame = pc.get(ObjectKey.GAME_MODE);
	}
	gameModeCombo.setSelectedItem(currGame);
	getSelection(pc);
	saveGameMode(pc);

	panel.add(gameModeCombo);
	layout.putConstraint(SpringLayout.NORTH, gameModeCombo, 20, SpringLayout.SOUTH, introLabel);
	layout.putConstraint(SpringLayout.WEST, gameModeCombo, 25, SpringLayout.WEST, panel);
}
 
Example 20
Source Project: Astrosoft   Source File: FileChooserPanel.java    License: GNU General Public License v2.0 5 votes vote down vote up
public FileChooserPanel(Dimension size, String defaultPath, String title, FileOps.FileDialogMode mode, AstrosoftFileFilter fileFilter){
	
	this.defaultPath = defaultPath;
	this.title = title;
	this.mode = mode;
	this.fileFilter = fileFilter;
	setLayout(new SpringLayout());
	setPreferredSize(size);
	addComponents();
}
 
Example 21
public JComponent getComponent() {
  if (myPanel == null) {
    SpringLayout topPanelLayout = new SpringLayout();
    JPanel topPanel = new JPanel(topPanelLayout);

    JComponent depsComponent = myList.getTableComponent();
    JComponent titleComponent = new JLabel(myList.getTitle());
    JComponent actionsComponent = myList.getActionsComponent();
    topPanel.add(titleComponent);
    topPanel.add(actionsComponent);

    topPanelLayout.putConstraint(SpringLayout.WEST, titleComponent, 0, SpringLayout.WEST, topPanel);
    topPanelLayout.putConstraint(SpringLayout.NORTH, titleComponent, 0, SpringLayout.NORTH, topPanel);

    topPanelLayout.putConstraint(SpringLayout.NORTH, actionsComponent, 2, SpringLayout.SOUTH, titleComponent);
    topPanelLayout.putConstraint(SpringLayout.SOUTH, topPanel, 2, SpringLayout.SOUTH, actionsComponent);
    topPanelLayout.putConstraint(SpringLayout.WEST, actionsComponent, 0, SpringLayout.WEST, topPanel);

    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(depsComponent, BorderLayout.CENTER);

    myFields.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
    centerPanel.add(myFields, BorderLayout.EAST);

    myPanel = Box.createVerticalBox();
    myPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    myPanel.add(topPanel);
    myPanel.add(Box.createVerticalStrut(5));
    myPanel.add(centerPanel);
  }
  return myPanel;
}
 
Example 22
@Override
protected JPanel createPreProcessingPanel() {
    final JPanel preProcessingPanel = new JPanel(new SpringLayout());

    PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor("preprocessorExternalTool");
    PropertyEditor editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    JComponent editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    preProcessingPanel.add(createCheckboxComponent("preprocessTool", editorComponent, newOperatorDescriptor.getPreprocessTool()));
    preProcessingPanel.add(new JLabel(Bundle.CTL_Label_PreprocessingTool_Text()));
    preProcessingPanel.add(editorComponent);

    propertyDescriptor = propertyContainer.getDescriptor("processingWriter");
    editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    JComponent writeComponent = createCheckboxComponent("writeForProcessing", editorComponent, newOperatorDescriptor.shouldWriteBeforeProcessing());

    preProcessingPanel.add(writeComponent);
    preProcessingPanel.add(new JLabel(Bundle.CTL_Label_WriteBefore_Text()));
    preProcessingPanel.add(editorComponent);

    TitledBorder title = BorderFactory.createTitledBorder(Bundle.CTL_Panel_PreProcessing_Border_TitleText());
    preProcessingPanel.setBorder(title);

    SpringUtilities.makeCompactGrid(preProcessingPanel, 2, 3, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    return preProcessingPanel;
}
 
Example 23
JComponent createSeparatorSettingsPanel() {
  JPanel result = new JPanel(new SpringLayout());
  result.add(new JLabel(language.getText("textSeparator")));
  cbTextSeparator = new JComboBox(getCsvOptions().getSeparatedTextChars());
  result.add(cbTextSeparator);

  result.add(new JLabel(language.getText("separatedFields")));
  myFieldSeparatorCombo = new JComboBox(new String[] { language.getText("fixedWidth"), language.getText("doubledot"),
      language.getText("dotComa"), language.getText("coma") });
  myFieldSeparatorCombo.setEditable(false);
  result.add(myFieldSeparatorCombo);
  SpringUtilities.makeCompactGrid(result, 2, 2, 0, 0, 3, 3);
  UIUtil.createTitle(result, language.getText("optionPage.impex.csv.group.csv.label"));
  return result;
}
 
Example 24
Source Project: pcgen   Source File: GameModePanel.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc)
{
	panel.setLayout(layout);
	JLabel introLabel = new JLabel("Please select the Game Mode to Convert:");
	panel.add(introLabel);
	layout.putConstraint(SpringLayout.NORTH, introLabel, 50, SpringLayout.NORTH, panel);
	layout.putConstraint(SpringLayout.WEST, introLabel, 25, SpringLayout.WEST, panel);

	List<GameMode> games = SystemCollections.getUnmodifiableGameModeList();
	gameModeCombo = new JComboBox<>(games.toArray());
	gameModeCombo.addActionListener(arg0 -> {
		getSelection(pc);
		saveGameMode(pc);
	});
	PCGenSettings context = PCGenSettings.getInstance();
	SettingsHandler
		.setGame(context.initProperty(PCGenSettings.CONVERT_GAMEMODE, SettingsHandler.getGameAsProperty().get().getName()));
	GameMode currGame = SettingsHandler.getGameAsProperty().get();
	if (pc.get(ObjectKey.GAME_MODE) != null)
	{
		currGame = pc.get(ObjectKey.GAME_MODE);
	}
	gameModeCombo.setSelectedItem(currGame);
	getSelection(pc);
	saveGameMode(pc);

	panel.add(gameModeCombo);
	layout.putConstraint(SpringLayout.NORTH, gameModeCombo, 20, SpringLayout.SOUTH, introLabel);
	layout.putConstraint(SpringLayout.WEST, gameModeCombo, 25, SpringLayout.WEST, panel);
}
 
Example 25
Source Project: JavaMainRepo   Source File: MainMenuFrame.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param title
 *            The title of the frame.
 */
public MainMenuFrame(final String title) {
	super(title);
	JPanel pan = new JPanel();
	SpringLayout slPanel = new SpringLayout();
	JLabel background = new JLabel(new ImageIcon("C:/Users/Bolo/Desktop/Zoo.png"));
	slPanel.putConstraint(SpringLayout.NORTH, background, 0, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, background, 0, SpringLayout.WEST, pan);
	pan.add(background);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
	JPanel panel = new JPanel();
	// adding empty panel to fill grid layout
	contentPanel.add(panel);
	contentPanel.add(pan);
	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 26
Source Project: JavaMainRepo   Source File: MainMenuFrame.java    License: 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 27
Source Project: JavaMainRepo   Source File: MainMenuFrame.java    License: 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 28
Source Project: JavaMainRepo   Source File: MainMenuFrame.java    License: 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 29
Source Project: JavaMainRepo   Source File: MainMenuFrame.java    License: 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 30
Source Project: JavaMainRepo   Source File: AddFrame.java    License: 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);
}