public CellarGUI(Cellar model) { this.model = model; setTitle("Cellar"); setSize(new Dimension(1000, 600)); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); health.setPreferredSize(new Dimension(200, 10)); exp.setPreferredSize(new Dimension(200, 10)); currentRoom.setPreferredSize(new Dimension(200, 10)); spacer.setPreferredSize(new Dimension(200, 115)); magicLabel.setPreferredSize(new Dimension(200, 10)); magicLabel.setHorizontalAlignment(JLabel.CENTER); playerItemLabel.setText("Player's Items (Max 1)"); setLabels(); JScrollPane playerItemsPane = new JScrollPane(); playerItemsList.setListData(model.getPlayer().getItemList().toArray()); playerItemsPane.setViewportView(playerItemsList); playerItemsPane.setPreferredSize(new Dimension(200, 125)); JButton drop = new JButton("Drop Item"); drop.addActionListener(this); drop.setPreferredSize(new Dimension(200, 25)); JScrollPane roomItemsPane = new JScrollPane(); roomItemsList = new JList(getRoomItems()); roomItemsPane.setViewportView(roomItemsList); roomItemsPane.setPreferredSize(new Dimension(200, 125)); JButton pickUp = new JButton("Pick Up"); pickUp.addActionListener(this); pickUp.setPreferredSize(new Dimension(200, 25)); JScrollPane hallsPane = new JScrollPane(); hallList = new JList(getHalls()); hallsPane.setViewportView(hallList); hallsPane.setPreferredSize(new Dimension(200, 200)); JButton enterHall = new JButton("Enter Hallway"); enterHall.setPreferredSize(new Dimension(200, 25)); enterHall.addActionListener(this); JScrollPane outputPane = new JScrollPane(); output = new JTextArea(); outputPane.setPreferredSize(new Dimension(550, 550)); output.setEditable(false); output.setBorder(BorderFactory.createLineBorder(Color.black)); outputPane.setViewportView(output); JLabel roomItemLabel = new JLabel("Items in the Room"); JLabel hallsLabel = new JLabel("Hallways"); JPanel rightPanel = new JPanel(); JPanel leftPanel = new JPanel(); rightPanel.add(playerItemLabel); rightPanel.add(playerItemsPane); rightPanel.add(drop); rightPanel.add(roomItemLabel); rightPanel.add(roomItemsPane); rightPanel.add(pickUp); rightPanel.add(magicLabel); rightPanel.add(magic); rightPanel.add(spacer); rightPanel.add(health); rightPanel.add(exp); rightPanel.add(currentRoom); rightPanel.setPreferredSize(new Dimension(200, 600)); rightPanel.setBackground(Color.WHITE); leftPanel.add(hallsLabel); leftPanel.add(hallsPane); leftPanel.add(enterHall); leftPanel.setPreferredSize(new Dimension(200, 600)); leftPanel.setBackground(Color.WHITE); add(outputPane, BorderLayout.CENTER); add(rightPanel, BorderLayout.WEST); add(leftPanel, BorderLayout.EAST); }
public void makeGUI() { frm = new JFrame(); c = frm.getContentPane(); btnImport = new JButton("Import"); btnImport.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureImport(); } }); btnMove = new JButton("Move"); btnMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureMove(); } }); btnDelete = new JButton("Delete"); btnDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureDelete(); } }); btnAnalyse = new JButton("Analyse"); btnAnalyse.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureAnalysis(); } }); tblItems = new JTable(store); tblItems.setRowSorter(tableSorter); tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblItems.setFillsViewportHeight(true); tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE); tblItems.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { tblItems.setRowSelectionInterval( e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight()); } if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) { int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow()); secureExport(idx); } } public void mouseEntered(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {} public void mousePressed(MouseEvent arg0) {} public void mouseReleased(MouseEvent arg0) {} }); txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH); txaStatus.setEditable(false); txaStatus.setBorder(BorderFactory.createTitledBorder("Status")); txaSearch = new JTextArea(4, TXA_WIDTH); txaSearch.setBorder(BorderFactory.createTitledBorder("Search")); txaSearch.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) { filterBase(txaSearch.getText()); // EXPORT settings here, as in mass export (export everything) if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) { // txaSearch.setText(""); if (JOptionPane.showConfirmDialog( frm, "Do you really want to export the whole secure base?", "Confirm Export", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { totalExport(); } } // LOST X IMPORT asin look through the store for files not listed if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) { for (int i = 0; i < storeLocs.size(); i++) { if (store.stockTake(i)) needsSave = true; } } } public void keyTyped(KeyEvent arg0) {} }); JPanel pnlTop = new JPanel(new GridLayout(1, 4)); JPanel pnlEast = new JPanel(new BorderLayout()); JPanel pnlCenterEast = new JPanel(new BorderLayout()); JScrollPane jspItems = new JScrollPane(tblItems); pnlTop.add(btnImport); pnlTop.add(btnMove); pnlTop.add(btnDelete); pnlTop.add(btnAnalyse); pnlCenterEast.add(txaStatus, BorderLayout.CENTER); pnlCenterEast.add(txaSearch, BorderLayout.NORTH); // pnlEast.add(pswPass, BorderLayout.NORTH); pnlEast.add(pnlCenterEast, BorderLayout.CENTER); c.setLayout(new BorderLayout()); c.add(pnlTop, BorderLayout.NORTH); c.add(pnlEast, BorderLayout.EAST); c.add(jspItems, BorderLayout.CENTER); frm.setContentPane(c); }
public WizStepManyTextFields(Wizard w, String instr, Vector strings) { // store wizard? _instructions.setText(instr); _instructions.setWrapStyleWord(true); _instructions.setEditable(false); _instructions.setBorder(null); _instructions.setBackground(_mainPanel.getBackground()); _mainPanel.setBorder(new EtchedBorder()); GridBagLayout gb = new GridBagLayout(); _mainPanel.setLayout(gb); GridBagConstraints c = new GridBagConstraints(); c.ipadx = 3; c.ipady = 3; c.weightx = 0.0; c.weighty = 0.0; c.anchor = GridBagConstraints.EAST; JLabel image = new JLabel(""); // image.setMargin(new Insets(0, 0, 0, 0)); image.setIcon(WIZ_ICON); image.setBorder(null); c.gridx = 0; c.gridheight = GridBagConstraints.REMAINDER; c.gridy = 0; c.anchor = GridBagConstraints.NORTH; gb.setConstraints(image, c); _mainPanel.add(image); c.weightx = 0.0; c.gridx = 2; c.gridheight = 1; c.gridwidth = 3; c.gridy = 0; c.fill = GridBagConstraints.NONE; gb.setConstraints(_instructions, c); _mainPanel.add(_instructions); c.gridx = 1; c.gridy = 1; c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer = new SpacerPanel(); gb.setConstraints(spacer, c); _mainPanel.add(spacer); c.gridx = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; int size = strings.size(); for (int i = 0; i < size; i++) { c.gridy = 2 + i; String s = (String) strings.elementAt(i); JTextField tf = new JTextField(s, 50); tf.setMinimumSize(new Dimension(200, 20)); tf.getDocument().addDocumentListener(this); _fields.addElement(tf); gb.setConstraints(tf, c); _mainPanel.add(tf); } c.gridx = 1; c.gridy = 3 + strings.size(); c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer2 = new SpacerPanel(); gb.setConstraints(spacer2, c); _mainPanel.add(spacer2); }