Лабараторная работа №4 1
This commit is contained in:
parent
e021aac7e7
commit
8404340fc4
@ -6,10 +6,7 @@ import DrawingShip.DrawingWarmlyShip;
|
|||||||
import Entities.EntityShip;
|
import Entities.EntityShip;
|
||||||
import Entities.EntityWarmlyShip;
|
import Entities.EntityWarmlyShip;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AdditionalCollections <T extends EntityShip, U extends IDifferentDecks>{
|
public class AdditionalCollections <T extends EntityShip, U extends IDifferentDecks>{
|
||||||
|
@ -18,7 +18,7 @@ public abstract class AbstractCompany {
|
|||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = collection;
|
_collection = collection;
|
||||||
_collection.SetMaxCount(GetMaxCount(), (Class) DrawingShip.class);
|
_collection.SetMaxCount(GetMaxCount());
|
||||||
}
|
}
|
||||||
//перегрузка операторов в джаве не возможна
|
//перегрузка операторов в джаве не возможна
|
||||||
public DrawingShip GetRandomObject()
|
public DrawingShip GetRandomObject()
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package CollectionGenericObjects;
|
||||||
|
|
||||||
|
public enum CollectionType {
|
||||||
|
None,
|
||||||
|
Massive,
|
||||||
|
List
|
||||||
|
}
|
@ -3,10 +3,8 @@ package CollectionGenericObjects;
|
|||||||
public interface ICollectionGenericObjects<T>
|
public interface ICollectionGenericObjects<T>
|
||||||
{
|
{
|
||||||
int getCount();
|
int getCount();
|
||||||
void SetMaxCount(int count, Class<T> type);
|
void SetMaxCount(int count);
|
||||||
int Insert(T obj);
|
int Insert(T obj);
|
||||||
//подумать что делать с этим методом
|
|
||||||
int Insert(T obj, int position);
|
|
||||||
T Remove(int position);
|
T Remove(int position);
|
||||||
T Get(int position);
|
T Get(int position);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package CollectionGenericObjects;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
public class ListGenericObjects<T> implements ICollectionGenericObjects<T> {
|
||||||
|
private List<T> _collection;
|
||||||
|
private int _maxCount;
|
||||||
|
public int getCount() {
|
||||||
|
return _collection.size();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void SetMaxCount(int size) {
|
||||||
|
if (size > 0) {
|
||||||
|
_maxCount = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ListGenericObjects() {
|
||||||
|
_collection = new ArrayList<T>();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public T Get(int position)
|
||||||
|
{
|
||||||
|
if (position >= getCount() || position < 0) return null;
|
||||||
|
return _collection.get(position);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
if (getCount() == _maxCount) return -1;
|
||||||
|
_collection.add(obj);
|
||||||
|
return getCount();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public T Remove(int position)
|
||||||
|
{
|
||||||
|
if (position >= getCount() || position < 0) return null;
|
||||||
|
T obj = _collection.get(position);
|
||||||
|
_collection.remove(position);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
package CollectionGenericObjects;
|
package CollectionGenericObjects;
|
||||||
|
|
||||||
|
import DrawingShip.DrawingShip;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>{
|
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>{
|
||||||
private T[] _collection;
|
private T[] _collection = null;
|
||||||
private int Count;
|
private int Count;
|
||||||
public void SetMaxCount(int size, Class<T> type) {
|
@Override
|
||||||
|
public void SetMaxCount(int size) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
_collection = (T[]) Array.newInstance(type, size);
|
if (_collection == null) {
|
||||||
Count = size;
|
_collection = (T[]) Array.newInstance((Class) DrawingShip.class, size);
|
||||||
|
Count = size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -32,36 +35,6 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>{
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int Insert(T obj, int position) {
|
|
||||||
if (position >= getCount() || position < 0)
|
|
||||||
return -1;
|
|
||||||
if (_collection[position] == null) {
|
|
||||||
_collection[position] = obj;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
int index = position + 1;
|
|
||||||
while (index < getCount())
|
|
||||||
{
|
|
||||||
if (_collection[index] == null)
|
|
||||||
{
|
|
||||||
_collection[index] = obj;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
index = position - 1;
|
|
||||||
while (index >= 0)
|
|
||||||
{
|
|
||||||
if (_collection[index] == null)
|
|
||||||
{
|
|
||||||
_collection[index] = obj;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
--index;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public T Remove(int position) {
|
public T Remove(int position) {
|
||||||
if (position >= getCount() || position < 0)
|
if (position >= getCount() || position < 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package CollectionGenericObjects;
|
||||||
|
|
||||||
|
import DrawingShip.DrawingShip;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class StorageCollection<T> {
|
||||||
|
private Map<String, ICollectionGenericObjects<T>> _storages;
|
||||||
|
public StorageCollection()
|
||||||
|
{
|
||||||
|
_storages = new HashMap<String, ICollectionGenericObjects<T>>();
|
||||||
|
}
|
||||||
|
public Set<String> Keys() {
|
||||||
|
Set<String> keys = _storages.keySet();
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
public void AddCollection(String name, CollectionType collectionType)
|
||||||
|
{
|
||||||
|
if (_storages.containsKey(name)) return;
|
||||||
|
if (collectionType == CollectionType.None) return;
|
||||||
|
else if (collectionType == CollectionType.Massive)
|
||||||
|
_storages.put(name, new MassiveGenericObjects<T>());
|
||||||
|
else if (collectionType == CollectionType.List)
|
||||||
|
_storages.put(name, new ListGenericObjects<T>());
|
||||||
|
}
|
||||||
|
public void DelCollection(String name)
|
||||||
|
{
|
||||||
|
if (_storages.containsKey(name))
|
||||||
|
_storages.remove(name);
|
||||||
|
}
|
||||||
|
// в джаве отсутствуют индикаторы
|
||||||
|
public ICollectionGenericObjects<T> getCollectionObject(String name) {
|
||||||
|
if (_storages.containsKey(name))
|
||||||
|
return _storages.get(name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//дополнительное задание номер 1
|
||||||
|
public T Get(String name, int position){
|
||||||
|
if(_storages.containsKey(name))
|
||||||
|
return _storages.get(name).Remove(position);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,12 @@
|
|||||||
package DrawingShip;
|
package DrawingShip;
|
||||||
|
|
||||||
import CollectionGenericObjects.AbstractCompany;
|
import CollectionGenericObjects.AbstractCompany;
|
||||||
import CollectionGenericObjects.ICollectionGenericObjects;
|
|
||||||
import CollectionGenericObjects.MassiveGenericObjects;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class CanvasFormShipCollection<T> extends JComponent
|
public class CanvasFormShipCollection<T> extends JComponent
|
||||||
{
|
{
|
||||||
//неиспользуемые методы
|
|
||||||
public ICollectionGenericObjects<T> collection = new MassiveGenericObjects<T>();
|
|
||||||
public AbstractCompany company = null;
|
public AbstractCompany company = null;
|
||||||
public void SetCollectionToCanvas(AbstractCompany company) {
|
public void SetCollectionToCanvas(AbstractCompany company) {
|
||||||
this.company = company;
|
this.company = company;
|
||||||
|
@ -35,7 +35,6 @@ public class FormAdditionalCollection extends JFrame {
|
|||||||
buttonGenerate.addActionListener(new ActionListener() {
|
buttonGenerate.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
drawingShip = additionalCollection.CreateAdditionalCollectionShip();
|
drawingShip = additionalCollection.CreateAdditionalCollectionShip();
|
||||||
drawingShip.SetPictureSize(getWidth(), getHeight());
|
drawingShip.SetPictureSize(getWidth(), getHeight());
|
||||||
drawingShip.SetPosition(50,50);
|
drawingShip.SetPosition(50,50);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import CollectionGenericObjects.AbstractCompany;
|
import CollectionGenericObjects.*;
|
||||||
import CollectionGenericObjects.MassiveGenericObjects;
|
|
||||||
import CollectionGenericObjects.ShipPortService;
|
|
||||||
import DrawingShip.CanvasFormShipCollection;
|
import DrawingShip.CanvasFormShipCollection;
|
||||||
import DrawingShip.DrawingShip;
|
import DrawingShip.DrawingShip;
|
||||||
import DrawingShip.DrawingWarmlyShip;
|
import DrawingShip.DrawingWarmlyShip;
|
||||||
|
import Entities.EntityShip;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.text.MaskFormatter;
|
import javax.swing.text.MaskFormatter;
|
||||||
@ -14,6 +13,7 @@ import java.awt.event.ComponentAdapter;
|
|||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
import static java.lang.Integer.parseInt;
|
import static java.lang.Integer.parseInt;
|
||||||
|
|
||||||
@ -22,11 +22,21 @@ public class FormShipCollection extends JFrame{
|
|||||||
private Dimension dimension;
|
private Dimension dimension;
|
||||||
public static CanvasFormShipCollection<DrawingShip> _canvasWarmlyShip = new CanvasFormShipCollection<DrawingShip>();
|
public static CanvasFormShipCollection<DrawingShip> _canvasWarmlyShip = new CanvasFormShipCollection<DrawingShip>();
|
||||||
private static AbstractCompany _company = null;
|
private static AbstractCompany _company = null;
|
||||||
|
private Stack<DrawingShip> _collectionRemoveObjects = new Stack<DrawingShip>();
|
||||||
|
private StorageCollection<DrawingShip> _storageCollection = new StorageCollection<DrawingShip>();
|
||||||
|
private JTextField textBoxCollection = new JTextField();
|
||||||
|
private JRadioButton radioButtonMassive = new JRadioButton("Massive");
|
||||||
|
private JRadioButton radioButtonList = new JRadioButton("List");
|
||||||
|
private JButton buttonAddCollection = new JButton("Add");
|
||||||
|
private JList listBoxCollection = new JList();
|
||||||
|
private JButton buttonRemoveCollection = new JButton("Remove");
|
||||||
|
private JButton buttonCreateCompany = new JButton("Create company");
|
||||||
private JButton CreateButton = new JButton("Create warmlyship");;
|
private JButton CreateButton = new JButton("Create warmlyship");;
|
||||||
private JButton CreateShipButton = new JButton("Create ship");
|
private JButton CreateShipButton = new JButton("Create ship");
|
||||||
private JButton RemoveButton = new JButton("Remove");
|
private JButton RemoveButton = new JButton("Remove");
|
||||||
private JButton GoToCheckButton = new JButton("Check");
|
private JButton GoToCheckButton = new JButton("Check");
|
||||||
private JButton RandomButton = new JButton("RandomShip");
|
private JButton RandomButton = new JButton("RandomShip");
|
||||||
|
private JButton RemoveObjectsButton = new JButton("Show remove");
|
||||||
private JButton RefreshButton = new JButton("Refresh");
|
private JButton RefreshButton = new JButton("Refresh");
|
||||||
private JComboBox ComboBoxCollections = new JComboBox(new String[]{"", "Хранилище"});
|
private JComboBox ComboBoxCollections = new JComboBox(new String[]{"", "Хранилище"});
|
||||||
private JFormattedTextField MaskedTextField;
|
private JFormattedTextField MaskedTextField;
|
||||||
@ -57,7 +67,7 @@ public class FormShipCollection extends JFrame{
|
|||||||
break;
|
break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
if (_company._collection.Insert(drawingShip, 0) != -1) {
|
if (_company._collection.Insert(drawingShip) != -1) {
|
||||||
JOptionPane.showMessageDialog(null, "Объект добавлен");
|
JOptionPane.showMessageDialog(null, "Объект добавлен");
|
||||||
canvasShow();
|
canvasShow();
|
||||||
}
|
}
|
||||||
@ -85,22 +95,9 @@ public class FormShipCollection extends JFrame{
|
|||||||
|
|
||||||
MaskedTextField = new JFormattedTextField(mask);
|
MaskedTextField = new JFormattedTextField(mask);
|
||||||
|
|
||||||
ComboBoxCollections.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
switch (ComboBoxCollections.getSelectedItem().toString()) {
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new ShipPortService(getWidth()-200, getHeight()-70, new MassiveGenericObjects<DrawingShip>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CreateShipButton.addActionListener(new ActionListener() {
|
CreateShipButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) { CreateObject("DrawingShip"); }
|
||||||
CreateObject("DrawingShip");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
CreateButton.addActionListener(new ActionListener() {
|
CreateButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -112,7 +109,8 @@ public class FormShipCollection extends JFrame{
|
|||||||
RemoveButton.addActionListener(new ActionListener() {
|
RemoveButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (_company == null || MaskedTextField.getText() == null) {
|
if (_company == null || MaskedTextField.getText() == null ||
|
||||||
|
listBoxCollection.getSelectedValue().toString() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = parseInt(MaskedTextField.getText());
|
int pos = parseInt(MaskedTextField.getText());
|
||||||
@ -120,8 +118,11 @@ public class FormShipCollection extends JFrame{
|
|||||||
"Удалить", "Удаление",
|
"Удалить", "Удаление",
|
||||||
JOptionPane.YES_NO_OPTION);
|
JOptionPane.YES_NO_OPTION);
|
||||||
if (resultConfirmDialog == JOptionPane.NO_OPTION) return;
|
if (resultConfirmDialog == JOptionPane.NO_OPTION) return;
|
||||||
if (_company._collection.Remove(pos) != null) {
|
DrawingShip obj = _storageCollection.Get(
|
||||||
|
listBoxCollection.getSelectedValue().toString(), pos);
|
||||||
|
if (obj != null) {
|
||||||
JOptionPane.showMessageDialog(null, "Объект удален");
|
JOptionPane.showMessageDialog(null, "Объект удален");
|
||||||
|
_collectionRemoveObjects.push(obj);
|
||||||
canvasShow();
|
canvasShow();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -180,41 +181,140 @@ public class FormShipCollection extends JFrame{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttonAddCollection.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (textBoxCollection.getText().isEmpty() || (!radioButtonMassive.isSelected()
|
||||||
|
&& !radioButtonList.isSelected())) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Не все данные заполнены");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CollectionType collectionType = CollectionType.None;
|
||||||
|
if (radioButtonMassive.isSelected())
|
||||||
|
{
|
||||||
|
collectionType = CollectionType.Massive;
|
||||||
|
}
|
||||||
|
else if (radioButtonList.isSelected())
|
||||||
|
{
|
||||||
|
collectionType = CollectionType.List;
|
||||||
|
}
|
||||||
|
_storageCollection.AddCollection(textBoxCollection.getText(), collectionType);
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonRemoveCollection.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (listBoxCollection.getSelectedIndex() < 0 || listBoxCollection.getSelectedValue() == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int resultConfirmDialog = JOptionPane.showConfirmDialog(null,
|
||||||
|
"Удалить", "Удаление",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
if (resultConfirmDialog == JOptionPane.NO_OPTION) return;
|
||||||
|
_storageCollection.DelCollection(listBoxCollection.getSelectedValue().toString());
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonCreateCompany.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (listBoxCollection.getSelectedIndex() < 0 || listBoxCollection.getSelectedValue() == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICollectionGenericObjects<DrawingShip> collection =
|
||||||
|
_storageCollection.getCollectionObject(listBoxCollection.getSelectedValue().toString());
|
||||||
|
if (collection == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция не проинициализирована");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (ComboBoxCollections.getSelectedItem().toString()) {
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new ShipPortService(getWidth()-200, getHeight()-70,
|
||||||
|
collection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
RemoveObjectsButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (_collectionRemoveObjects.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DrawingShip ship = null;
|
||||||
|
ship = _collectionRemoveObjects.pop();
|
||||||
|
if (ship == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FormWarmlyShip form = new FormWarmlyShip("Теплоход", new Dimension(900,565));
|
||||||
|
form.Init(ship);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JLabel labelCollectionName = new JLabel("Название коллекции");
|
||||||
|
ButtonGroup radiobuttonsGroup = new ButtonGroup();
|
||||||
|
radiobuttonsGroup.add(radioButtonMassive);
|
||||||
|
radiobuttonsGroup.add(radioButtonList);
|
||||||
|
|
||||||
_canvasWarmlyShip.setBounds(0, 0, getWidth()-200, getHeight());
|
_canvasWarmlyShip.setBounds(0, 0, getWidth()-200, getHeight());
|
||||||
ComboBoxCollections.setBounds(getWidth()-190, 10, 150, 20);
|
labelCollectionName.setBounds(getWidth()-190, 10, 150, 20);
|
||||||
CreateShipButton.setBounds(getWidth()-190, 60, 150, 30);
|
textBoxCollection.setBounds(getWidth()-190, 32, 150, 25);
|
||||||
CreateButton.setBounds(getWidth()-190, 100, 150, 30);
|
radioButtonMassive.setBounds(getWidth()-190, 60, 75, 20);
|
||||||
MaskedTextField.setBounds(getWidth()-190,200,150,30);
|
radioButtonList.setBounds(getWidth()-105, 60, 50, 20);
|
||||||
RemoveButton.setBounds(getWidth()-190, 240, 150, 30);
|
buttonAddCollection.setBounds(getWidth()-190, 85, 150, 20);
|
||||||
GoToCheckButton.setBounds(getWidth()-190, 280, 150, 30);
|
listBoxCollection.setBounds(getWidth()-190, 115, 150, 70);
|
||||||
RandomButton.setBounds(getWidth()-190, 320, 150, 30);
|
buttonRemoveCollection.setBounds(getWidth()-190, 195, 150, 20);
|
||||||
|
ComboBoxCollections.setBounds(getWidth()-190, 235, 150, 20);
|
||||||
|
buttonCreateCompany.setBounds(getWidth()-190, 260, 150, 20);
|
||||||
|
CreateShipButton.setBounds(getWidth()-190, 295, 150, 30);
|
||||||
|
CreateButton.setBounds(getWidth()-190, 330, 150, 30);
|
||||||
|
MaskedTextField.setBounds(getWidth()-190,365,150,30);
|
||||||
|
RemoveButton.setBounds(getWidth()-190, 400, 150, 30);
|
||||||
|
GoToCheckButton.setBounds(getWidth()-190, 435, 150, 30);
|
||||||
|
RandomButton.setBounds(getWidth()-190, 470, 150, 30);
|
||||||
|
RemoveObjectsButton.setBounds(getWidth()-190, 505, 150, 30);
|
||||||
RefreshButton.setBounds(getWidth()-190, getHeight()-90, 150, 30);
|
RefreshButton.setBounds(getWidth()-190, getHeight()-90, 150, 30);
|
||||||
|
|
||||||
setSize(dimension.width,dimension.height);
|
setSize(dimension.width,dimension.height);
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
add(_canvasWarmlyShip);
|
add(_canvasWarmlyShip);
|
||||||
|
add(labelCollectionName);
|
||||||
|
add(textBoxCollection);
|
||||||
|
add(radioButtonMassive);
|
||||||
|
add(radioButtonList);
|
||||||
|
add(buttonAddCollection);
|
||||||
|
add(listBoxCollection);
|
||||||
|
add(buttonRemoveCollection);
|
||||||
add(ComboBoxCollections);
|
add(ComboBoxCollections);
|
||||||
|
add(buttonCreateCompany);
|
||||||
add(CreateShipButton);
|
add(CreateShipButton);
|
||||||
add(CreateButton);
|
add(CreateButton);
|
||||||
add(MaskedTextField);
|
add(MaskedTextField);
|
||||||
add(RemoveButton);
|
add(RemoveButton);
|
||||||
add(GoToCheckButton);
|
add(GoToCheckButton);
|
||||||
add(RandomButton);
|
add(RandomButton);
|
||||||
|
add(RemoveObjectsButton);
|
||||||
add(RefreshButton);
|
add(RefreshButton);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
}
|
||||||
addComponentListener(new ComponentAdapter() {
|
private void RerfreshListBoxItems()
|
||||||
public void componentResized(ComponentEvent e) {
|
{
|
||||||
_canvasWarmlyShip.setBounds(0, 0, getWidth()-200, getHeight()-70);
|
DefaultListModel<String> list = new DefaultListModel<String>();
|
||||||
ComboBoxCollections.setBounds(getWidth()-190, 10, 150, 20);
|
for (String name : _storageCollection.Keys()) {
|
||||||
CreateShipButton.setBounds(getWidth()-190, 60, 150, 30);
|
if (name != "")
|
||||||
CreateButton.setBounds(getWidth()-190, 100, 150, 30);
|
{
|
||||||
MaskedTextField.setBounds(getWidth()-190,200,150,30);
|
list.addElement(name);
|
||||||
RemoveButton.setBounds(getWidth()-190, 240, 150, 30);
|
|
||||||
GoToCheckButton.setBounds(getWidth()-190, 280, 150, 30);
|
|
||||||
RandomButton.setBounds(getWidth()-190, 320, 150, 30);
|
|
||||||
RefreshButton.setBounds(getWidth()-190, getHeight()-90, 150, 30);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
listBoxCollection.setModel(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import DrawingShip.CanvasFormShipCollection;
|
|
||||||
import DrawingShip.CanvasWarmlyShip;
|
import DrawingShip.CanvasWarmlyShip;
|
||||||
import DrawingShip.DirectionType;
|
import DrawingShip.DirectionType;
|
||||||
import DrawingShip.DrawingShip;
|
import DrawingShip.DrawingShip;
|
||||||
@ -30,7 +29,6 @@ public class FormWarmlyShip extends JFrame {
|
|||||||
public void Init(DrawingShip ship) {
|
public void Init(DrawingShip ship) {
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
setMinimumSize(dimension);
|
setMinimumSize(dimension);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
|
|
||||||
Width = getWidth() - 10;
|
Width = getWidth() - 10;
|
||||||
Height = getHeight() - 34;
|
Height = getHeight() - 34;
|
||||||
|
Loading…
Reference in New Issue
Block a user