List of usage examples for java.awt BorderLayout EAST
String EAST
To view the source code for java.awt BorderLayout EAST.
Click Source Link
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();//from w w w . j av a 2 s . c o m initComponents(); this.stackPanel = new JPanel(); this.stackPanel.setFocusable(false); this.stackPanel.setOpaque(false); this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32)); this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS)); final JPanel glassPanel = (JPanel) this.getGlassPane(); glassPanel.setOpaque(false); this.setGlassPane(glassPanel); glassPanel.setLayout(new BorderLayout(8, 8)); glassPanel.add(Box.createGlue(), BorderLayout.CENTER); final JPanel ppanel = new JPanel(new BorderLayout(0, 0)); ppanel.setFocusable(false); ppanel.setOpaque(false); ppanel.setCursor(null); ppanel.add(this.stackPanel, BorderLayout.SOUTH); glassPanel.add(ppanel, BorderLayout.EAST); this.stackPanel.add(Box.createGlue()); glassPanel.setVisible(false); this.setTitle("Scia Reto"); setIconImage(UiUtils.loadImage("logo256x256.png")); this.stateless = args.length > 0; final MainFrame theInstance = this; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (doClosing()) { dispose(); } } }); this.tabPane = new EditorTabPane(this); this.explorerTree = new ExplorerTree(this); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setResizeWeight(0.0d); splitPane.setLeftComponent(this.explorerTree); splitPane.setRightComponent(this.tabPane); add(splitPane, BorderLayout.CENTER); this.menuOpenRecentProject.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects(); if (lastOpenedProjects.length > 0) { for (final File folder : lastOpenedProjects) { final JMenuItem item = new JMenuItem(folder.getName()); item.setToolTipText(folder.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openProject(folder, false); } }); menuOpenRecentProject.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentProject.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); this.menuOpenRecentFile.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles(); if (lastOpenedFiles.length > 0) { for (final File file : lastOpenedFiles) { final JMenuItem item = new JMenuItem(file.getName()); item.setToolTipText(file.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFileAsTab(file); } }); menuOpenRecentFile.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentFile.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); if (!this.stateless) { restoreState(); } else { boolean openedProject = false; for (final String filePath : args) { final File file = new File(filePath); if (file.isDirectory()) { openedProject = true; openProject(file, true); } else if (file.isFile()) { openFileAsTab(file); } } if (!openedProject) { //TODO try to hide project panel! } } final LookAndFeel current = UIManager.getLookAndFeel(); final ButtonGroup lfGroup = new ButtonGroup(); final String currentLFClassName = current.getClass().getName(); for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName()); lfGroup.add(menuItem); if (currentLFClassName.equals(info.getClassName())) { menuItem.setSelected(true); } menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(theInstance); PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL, info.getClassName()); PreferencesManager.getInstance().flush(); } catch (Exception ex) { LOGGER.error("Can't change LF", ex); } } }); this.menuLookAndFeel.add(menuItem); } }
From source file:org.rivalry.swingui.SortTablePanel.java
/** * @param tableModel Table model.//ww w .j av a 2 s. co m * @param centerComponent Center component. (optional) * * @return a new bottom panel. */ private JPanel createSouthPanel(final TableModel tableModel, final JComponent centerComponent) { final int hgap = 20; final int vgap = 0; final JPanel answer = new JPanel(new BorderLayout(hgap, vgap)); final int top = 5; final int left = top; final int bottom = top; final int right = top; answer.setBorder(BorderFactory.createEmptyBorder(top, left, bottom, right)); answer.add(_rowCountUI, BorderLayout.WEST); if (centerComponent != null) { answer.add(centerComponent, BorderLayout.CENTER); } if (_createDateUI != null) { answer.add(_createDateUI, BorderLayout.EAST); } return answer; }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
public StandaloneFrame() { setTitle("zeromeaner " + Version.getBuildVersion()); if (!Version.getBuildRevision().isEmpty()) setTitle(getTitle() + " rev " + Version.getBuildRevision()); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); add(toolbar = createToolbar(), BorderLayout.EAST); add(content = new JPanel(contentCards = new CardLayout()), BorderLayout.CENTER); netLobby = new KNetPanel(Session.getUser(), false); netLobby.setPreferredSize(new Dimension(800, 250)); netLobby.addKNetPanelListener(new KNetPanelAdapter() { @Override//from w ww . j av a 2 s . com public void knetPanelShutdown(KNetPanelEvent e) { content.remove(netLobby); content.revalidate(); content.repaint(); } @Override public void knetPanelJoined(KNetPanelEvent e) { if (e.getChannel().getId() != KNetChannelInfo.LOBBY_CHANNEL_ID && e.getSource().getClient().getCurrentChannel() != null) { startNewGame(e.getChannel().getRule().resourceName, null, e.getChannel().getMode(), e); gamePanel.displayWindow(); } } @Override public void knetPanelParted(KNetPanelEvent e) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ex) { } } }); gamePanel = new StandaloneGamePanel(this); createCards(); setMinimumSize(new Dimension(900, 550)); }
From source file:com.googlecode.vfsjfilechooser2.accessories.bookmarks.BookmarksManagerPanel.java
public BookmarksManagerPanel(BookmarksDialog parentDialog, VFSJFileChooser chooser) { this.parentDialog = parentDialog; this.chooser = chooser; model = new Bookmarks(); table = new JTable(model); scrollPane = new JScrollPane(table); table.setPreferredScrollableViewportSize(tableSize); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); bCancel = new JButton(VFSResources.getMessage("VFSJFileChooser.closeButtonText")); bOpen = new JButton(VFSResources.getMessage("VFSJFileChooser.openButtonText")); bOpen.setIcon(new ImageIcon( getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/document-open.png"))); bOpen.setHorizontalAlignment(SwingConstants.LEFT); bAdd = new JButton(VFSResources.getMessage("VFSJFileChooser.addButtonText")); bAdd.setIcon(//from w w w . j a va 2 s . c o m new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/list-add.png"))); bAdd.setHorizontalAlignment(SwingConstants.LEFT); bEdit = new JButton(VFSResources.getMessage("VFSJFileChooser.editButtonText")); bEdit.setIcon( new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/book_edit.png"))); bEdit.setHorizontalAlignment(SwingConstants.LEFT); bDelete = new JButton(VFSResources.getMessage("VFSJFileChooser.deleteButtonText")); bDelete.setIcon(new ImageIcon( getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/list-remove.png"))); bDelete.setHorizontalAlignment(SwingConstants.LEFT); bMoveUp = new JButton(VFSResources.getMessage("VFSJFileChooser.moveUpButtonText")); bMoveUp.setIcon( new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/go-up.png"))); bMoveUp.setHorizontalAlignment(SwingConstants.LEFT); bMoveDown = new JButton(VFSResources.getMessage("VFSJFileChooser.moveDownButtonText")); bMoveDown.setIcon( new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/go-down.png"))); bMoveDown.setHorizontalAlignment(SwingConstants.LEFT); final ActionHandler ah = new ActionHandler(); bOpen.addActionListener(ah); bCancel.addActionListener(ah); bEdit.addActionListener(ah); bAdd.addActionListener(ah); bDelete.addActionListener(ah); bMoveUp.addActionListener(ah); bMoveDown.addActionListener(ah); final Box south = Box.createHorizontalBox(); south.add(Box.createHorizontalGlue()); south.add(bCancel); south.add(Box.createHorizontalGlue()); final JPanel buttons = new JPanel(new GridLayout(0, 1, 5, 5)); buttons.add(bAdd); buttons.add(bEdit); buttons.add(bDelete); buttons.add(bOpen); buttons.add(Box.createVerticalStrut(10)); buttons.add(bMoveUp); buttons.add(bMoveDown); JPanel east = new JPanel(); east.add(buttons, BorderLayout.NORTH); east.add(new JPanel(), BorderLayout.CENTER); // don't ask setLayout(new BorderLayout(10, 10)); add(scrollPane, BorderLayout.CENTER); add(south, BorderLayout.SOUTH); add(east, BorderLayout.EAST); setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, UIManager.getColor("Panel.background"))); }
From source file:au.org.ala.delta.intkey.ui.FindInCharactersDialog.java
public FindInCharactersDialog(Intkey intkeyApp, IntkeyContext context) { super(intkeyApp.getMainFrame(), false); setResizable(false);// w ww . j a v a2s . c o m ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(FindInCharactersDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedCharacters = 0; _currentMatchedCharacter = -1; _findAction = actionMap.get("findCharacters"); _nextAction = actionMap.get("nextCharacter"); this.setTitle(windowTitle); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _pnlMainTop.add(_textField); _textField.setColumns(10); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainBottom = new JPanel(); _pnlMainBottom.setBorder(new EmptyBorder(20, 0, 0, 0)); _pnlMain.add(_pnlMainBottom, BorderLayout.CENTER); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchStates = new JCheckBox(searchStatesCaption); _chckbxSearchStates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchStates); _chckbxSearchUsedCharacters = new JCheckBox(searchUsedCharactersCaption); _chckbxSearchUsedCharacters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchUsedCharacters); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl__pnlInnerButtons = new GridBagLayout(); gbl__pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl__pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl__pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl__pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl__pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc__btnFindNext = new GridBagConstraints(); gbc__btnFindNext.fill = GridBagConstraints.HORIZONTAL; gbc__btnFindNext.insets = new Insets(0, 0, 5, 0); gbc__btnFindNext.gridx = 0; gbc__btnFindNext.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc__btnFindNext); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousCharacter")); _btnPrevious.setEnabled(false); GridBagConstraints gbc__btnPrevious = new GridBagConstraints(); gbc__btnPrevious.insets = new Insets(0, 0, 5, 0); gbc__btnPrevious.gridx = 0; gbc__btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc__btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findCharactersDone")); GridBagConstraints gbc__btnDone = new GridBagConstraints(); gbc__btnDone.fill = GridBagConstraints.HORIZONTAL; gbc__btnDone.gridx = 0; gbc__btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc__btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }
From source file:net.pandoragames.far.ui.swing.FileListPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BorderLayout()); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); tableModel = componentRepository.getTableModel(); componentRepository.getResetDispatcher().addResetable(tableModel); componentRepository.getSearchBaseListener().addResetable(tableModel); componentRepository.getUndoListener().setTableModel(tableModel); JTable fileListTable = componentRepository.getFileSetTable(); int totalWidth = fileListTable.getPreferredSize().width; fileListTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); fileListTable.setColumnSelectionAllowed(true); fileListTable.getTableHeader().addMouseListener(new TableHeaderMouseListener()); fileListTable.getTableHeader().getColumnModel().getColumn(0) .setHeaderRenderer(new TableHeaderCheckBoxColumnRenderer()); fileListPopupMenu = new FileListPopupMenu(fileListTable, tableModel, componentRepository, config); fileListTable.setComponentPopupMenu(fileListPopupMenu); fileListTable.addMouseListener(new FileViewOpener(fileListTable, componentRepository.getRootWindow(), config, componentRepository)); fileListTable.getColumnModel().getColumn(0).setPreferredWidth(20); fileListTable.getColumnModel().getColumn(0).setMaxWidth(20); fileListTable.getColumnModel().getColumn(1).setCellRenderer(new TargetFileListTableCellRenderer()); fileListTable.getColumnModel().getColumn(1).setPreferredWidth(2 * totalWidth / 5); fileListTable.getColumnModel().getColumn(2).setCellRenderer(new PathColumnRenderer()); fileListTable.getColumnModel().getColumn(3).setCellRenderer(new InfoColumnRenderer(config)); JScrollPane scrollPane = new JScrollPane(fileListTable); this.add(scrollPane, BorderLayout.CENTER); SelectCounter fileCounter = new SelectCounter(); fileCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); fileCounter.setForeground(Color.GRAY); ErrorCounter errorCounter = new ErrorCounter(); errorCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); JPanel counterLine = new JPanel(); counterLine.setLayout(new BorderLayout()); counterLine.add(fileCounter, BorderLayout.WEST); counterLine.add(errorCounter, BorderLayout.EAST); JProgressBar progressBar = new JProgressBar(); progressBar.setEnabled(false);//from www. j a v a2 s. c o m progressBar.setMaximumSize(new Dimension(100, 20)); progressBar.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); componentRepository.getProgressBarUpdater().setProgressBar(progressBar); JPanel progressBarPanel = new JPanel(); progressBarPanel.add(progressBar); counterLine.add(progressBarPanel, BorderLayout.CENTER); counterLine.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); this.add(counterLine, BorderLayout.SOUTH); tableModel.addTableModelListener(new ColumnCountListener(fileCounter)); tableModel.addTableModelListener(errorCounter); componentRepository.getResetDispatcher().addResetable(fileCounter); componentRepository.getSearchBaseListener().addResetable(fileCounter); componentRepository.getOperationCallBackListener().addComponentStartReseted(fileCounter, OperationType.FIND); componentRepository.getResetDispatcher().addResetable(errorCounter); componentRepository.getSearchBaseListener().addResetable(errorCounter); viewAction = new ActionView(componentRepository, config); }
From source file:playground.sergioo.workplaceCapacities2012.gui.ClustersWindow.java
public ClustersWindow(String title, List<CentroidCluster<PointPerson>> clusters) { setTitle(title);//from ww w . j ava 2 s . c o m setDefaultCloseOperation(HIDE_ON_CLOSE); this.setLocation(0, 0); this.setLayout(new BorderLayout()); layersPanels.put(PanelIds.ONE, new ClustersPanel(this, clusters)); this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER); option = Options.ZOOM; JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new GridLayout(Options.values().length, 1)); for (Options option : Options.values()) { JButton optionButton = new JButton(option.getCaption()); optionButton.setActionCommand(option.getCaption()); optionButton.addActionListener(this); buttonsPanel.add(optionButton); } this.add(buttonsPanel, BorderLayout.EAST); JPanel infoPanel = new JPanel(); infoPanel.setLayout(new BorderLayout()); readyButton = new JButton("Ready to exit"); readyButton.addActionListener(this); readyButton.setActionCommand(READY_TO_EXIT); infoPanel.add(readyButton, BorderLayout.WEST); JPanel labelsPanel = new JPanel(); labelsPanel.setLayout(new GridLayout(1, Labels.values().length)); labelsPanel.setBorder(new TitledBorder("Information")); labels = new JTextField[Labels.values().length]; for (int i = 0; i < Labels.values().length; i++) { labels[i] = new JTextField(""); labels[i].setEditable(false); labels[i].setBackground(null); labels[i].setBorder(null); labelsPanel.add(labels[i]); } infoPanel.add(labelsPanel, BorderLayout.CENTER); JPanel coordsPanel = new JPanel(); coordsPanel.setLayout(new GridLayout(1, 2)); coordsPanel.setBorder(new TitledBorder("Coordinates")); coordsPanel.add(lblCoords[0]); coordsPanel.add(lblCoords[1]); infoPanel.add(coordsPanel, BorderLayout.EAST); this.add(infoPanel, BorderLayout.SOUTH); pack(); }
From source file:org.ecoinformatics.seek.ecogrid.RegistrySearchDialog.java
private void initMainPanel() { JPanel selectionPanel = new JPanel(); selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.X_AXIS)); initOptions();// w w w. j a v a 2s . co m optionList = new JComboBox(options); optionList.setEditable(false); optionList.addItemListener(new TextFieldEnableController()); selectionPanel.add(optionList); selectionPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.GAP)); JLabel label = new JLabel(CONTAINS); selectionPanel.add(label); selectionPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.GAP)); inputField.setEnabled(false); selectionPanel.add(inputField); selectionPanel.add(Box.createHorizontalGlue()); mainPanel.setLayout(new BorderLayout()); mainPanel.add(selectionPanel, BorderLayout.NORTH); mainPanel.add(Box.createVerticalGlue(), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); JPanel rightButtonPanel = new JPanel(); rightButtonPanel.setLayout(new BoxLayout(rightButtonPanel, BoxLayout.X_AXIS)); /*searchButton = new JButton(new SearchRegistryAction("Search", this, parent, parent.getLocation())); searchButton.setPreferredSize(ServicesDisplayFrame.BUTTONDIMENSION); searchButton.setMaximumSize(ServicesDisplayFrame.BUTTONDIMENSION); rightButtonPanel.add(searchButton);*/ rightButtonPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.MARGINGSIZE)); cancelButton = new JButton(new CancelSearchAction("Cancel", this, parent)); cancelButton.setPreferredSize(EcogridPreferencesTab.BUTTONDIMENSION); cancelButton.setMaximumSize(EcogridPreferencesTab.BUTTONDIMENSION); rightButtonPanel.add(cancelButton); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(Box.createHorizontalGlue(), BorderLayout.CENTER); buttonPanel.add(rightButtonPanel, BorderLayout.EAST); mainPanel.add(buttonPanel, BorderLayout.SOUTH); }
From source file:playground.sergioo.facilitiesGenerator2012.gui.ClustersWindow.java
public ClustersWindow(String title, List<CentroidCluster<PointPerson>> clusters, int numTotalPoints) { setTitle(title);/*ww w. java 2 s. c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLocation(0, 0); this.setLayout(new BorderLayout()); layersPanels.put(PanelIds.ONE, new ClustersPanel(this, clusters, numTotalPoints)); this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER); option = Options.ZOOM; JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new GridLayout(Options.values().length, 1)); for (Options option : Options.values()) { JButton optionButton = new JButton(option.getCaption()); optionButton.setActionCommand(option.getCaption()); optionButton.addActionListener(this); buttonsPanel.add(optionButton); } this.add(buttonsPanel, BorderLayout.EAST); JPanel infoPanel = new JPanel(); infoPanel.setLayout(new BorderLayout()); readyButton = new JButton("Ready to exit"); readyButton.addActionListener(this); readyButton.setActionCommand(READY_TO_EXIT); infoPanel.add(readyButton, BorderLayout.WEST); JPanel labelsPanel = new JPanel(); labelsPanel.setLayout(new GridLayout(1, Labels.values().length)); labelsPanel.setBorder(new TitledBorder("Information")); labels = new JTextField[Labels.values().length]; for (int i = 0; i < Labels.values().length; i++) { labels[i] = new JTextField(""); labels[i].setEditable(false); labels[i].setBackground(null); labels[i].setBorder(null); labelsPanel.add(labels[i]); } infoPanel.add(labelsPanel, BorderLayout.CENTER); JPanel coordsPanel = new JPanel(); coordsPanel.setLayout(new GridLayout(1, 2)); coordsPanel.setBorder(new TitledBorder("Coordinates")); coordsPanel.add(lblCoords[0]); coordsPanel.add(lblCoords[1]); infoPanel.add(coordsPanel, BorderLayout.EAST); this.add(infoPanel, BorderLayout.SOUTH); pack(); }
From source file:rita.ui.component.DialogSelectEnemies.java
/** * Initialize the contents of the frame. * // www . j av a2s .c o m * @throws NoEnemiesException */ private void initialize() throws NoEnemiesException { this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.getContentPane().setLayout(new BorderLayout(6, 6)); this.setTitle(Language.get("selectEnemies")); randomMode = new JCheckBox(Language.get("robotsBattleMode.random")); randomMode.setSelected(true); randomMode.addActionListener(new SelectUnselectPositionAction()); icon = new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/target.jpg")); JPanel panelRobots = new JPanel(); panelRobots.setBorder(new EmptyBorder(0, 12, 12, 0)); panelRobots.setLayout(new BorderLayout(0, 0)); JPanel panelSelectAllNone = new JPanel(); panelSelectAllNone.setBorder(new EmptyBorder(0, 12, 0, 12)); panelRobots.add(panelSelectAllNone, BorderLayout.EAST); this.getContentPane().add(panelRobots, BorderLayout.CENTER); GridBagLayout gbl_panelSelectAllNone = new GridBagLayout(); gbl_panelSelectAllNone.columnWidths = new int[] { 0, 0 }; gbl_panelSelectAllNone.rowHeights = new int[] { 0, 0, 8 }; gbl_panelSelectAllNone.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_panelSelectAllNone.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panelSelectAllNone.setLayout(gbl_panelSelectAllNone); JButton btnSelectAll = new JButton(Language.get("selectAllEnemies")); GridBagConstraints gbc_btnSelectAll = new GridBagConstraints(); gbc_btnSelectAll.fill = GridBagConstraints.HORIZONTAL; gbc_btnSelectAll.insets = new Insets(0, 0, 5, 0); gbc_btnSelectAll.gridx = 0; gbc_btnSelectAll.gridy = 0; panelSelectAllNone.add(btnSelectAll, gbc_btnSelectAll); JButton btnSelectNone = new JButton(Language.get("selectNoEnemies")); GridBagConstraints gbc_btnSelectNone = new GridBagConstraints(); gbc_btnSelectNone.fill = GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0; gbc_btnSelectNone.gridy = 1; panelSelectAllNone.add(btnSelectNone, gbc_btnSelectNone); /* * btnInitialPositionsConfig = new * JButton(Language.get("selectRobotsInitialPositions")); * GridBagConstraints gbc_btnInitialPositionsConfig = new * GridBagConstraints(); gbc_btnSelectNone.fill = * GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0; * gbc_btnSelectNone.gridy = 1; * panelSelectAllNone.add(btnInitialPositionsConfig, * gbc_btnInitialPositionsConfig); * btnInitialPositionsConfig.addActionListener(new ActionListener() { * public void actionPerformed(ActionEvent evt) { * selectRobotsInitialPositions(); } }); */ JLabel label = new JLabel(String.format(Language.get("youtRobotAgainst"), HelperEditor.currentRobotName)); label.setBorder(new EmptyBorder(12, 12, 0, 12)); label.setIcon(new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/compite2.png"))); label.setVerticalAlignment(SwingConstants.TOP); label.setFont(label.getFont().deriveFont(Font.BOLD, 14)); panelSelectRobots = new JPanel(); panelSelectRobots.setLayout(new GridLayout(0, 2)); panelSelectRobots.setAutoscrolls(true); panelRobots.add(label, BorderLayout.NORTH); panelRobots.add(panelSelectRobots, BorderLayout.CENTER); // posicion de mi robot JPanel panelSetMyRobotPosition = new JPanel(); // panelRobots.add(panelSetMyRobotPosition, BorderLayout.PAGE_END); panelSetMyRobotPosition.setLayout(new FlowLayout()); JLabel ownPosition = new JLabel(Language.get("myRobotPosition") + " " + HelperEditor.currentRobotName); ownPosition.setFont(new Font("sansserif", Font.BOLD, 12)); panelSetMyRobotPosition.add(ownPosition); // Posicion de mi robot buttonPos = new JButton(icon); buttonPos.addActionListener(new PosicionRobotAction(HelperEditor.currentRobotName)); // el nombre aqui es solo a // modo informativo buttonPos.setPreferredSize(new Dimension(30, 30)); panelSetMyRobotPosition.add(buttonPos); positionComponents.add(buttonPos); // Matas JPanel panelSelectRoundsNumber = new JPanel(); // panelRobots.add(panelSelectRoundsNumber, BorderLayout.SOUTH); panelSelectRoundsNumber.setLayout(new FlowLayout()); panelSelectRoundsNumber.add(new JLabel(Language.get("selectRoundsNumber"))); // this.roundsNumberTextField = new JTextField( // Integer.toString(Batalla.NUMBER_OF_ROUNDS), 5); this.roundsNumberSpinner = new JSpinner(new SpinnerNumberModel(Batalla.NUMBER_OF_ROUNDS, Batalla.MIN_NUMBER_OF_ROUNDS, Batalla.MAX_NUMBER_OF_ROUNDS, 1)); panelSelectRoundsNumber.add(this.roundsNumberSpinner); JPanel panelSouth = new JPanel(); panelSouth.setLayout(new GridLayout(4, 1)); panelSouth.add(panelSetMyRobotPosition); //this.getContentPane().add(randomMode, BorderLayout.SOUTH); panelSouth.add(randomMode); panelSouth.add(new JSeparator()); panelSouth.add(panelSelectRoundsNumber); panelRobots.add(panelSouth, BorderLayout.SOUTH); JPanel panelOkCancel = new JPanel(); this.getContentPane().add(panelOkCancel, BorderLayout.SOUTH); panelOkCancel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 12)); btnOK = new JButton(Language.get("selectStartBattle")); btnOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { startBattle(panelSelectRobots); } }); // comienza deshabilitado hasta que se seleccione 1 enemigo // btnOK.setEnabled(false); panelOkCancel.add(btnOK); JButton btnCancel = new JButton(Language.get("cancel")); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeDialog(); } }); panelOkCancel.add(btnCancel); btnSelectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selectChecks(panelSelectRobots, true); // btnOK.setEnabled(true); } }); btnSelectNone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selectChecks(panelSelectRobots, false); // btnOK.setEnabled(false); } }); // TODO Agregar funcionalidad de elegir las posiciones iniciales de los // robots. // TODO Averiguar como pasar las posiciones para que se elijan de manera // random, probar (0,0,0) try { robotNameClicked = new RobotNameClickedEvent(btnOK); addRobotsToPanel(panelSelectRobots); this.setResizable(false); this.pack(); PositionCalc.centerDialog(this); enablePositionOptions(false); this.setVisible(true); } catch (FileNotFoundException e) { throw new NoEnemiesException(e.getMessage()); } }