public boolean mouseOnButton(MouseEvent event) { Point pt = event.getPoint(); if (pt.getX() >= button.getX() && pt.getX() <= button.getX() + button.getWidth()) { return true; } return false; }
/** Updates the location of the color edit panel (if shown). */ private void updateColorPanelPosition() { if (editPanel != null && colorOverlay != null) { int colorPanelX = (int) editPanel.getLocationOnScreen().getX() + colorButton.getX(); int colorPanelY = (int) (editPanel.getLocationOnScreen().getY() + editPanel.getBounds().getHeight()); colorOverlay.setBounds( colorPanelX, colorPanelY, EDIT_COLOR_PANEL_WIDTH, EDIT_COLOR_PANEL_HEIGHT); } }
/** * Calls the given treeNode. * * @param treeNode the <tt>TreeNode</tt> to call */ private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) { if (!(treeNode instanceof ContactNode)) return; UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor(); Point location = new Point(button.getX(), button.getY() + button.getHeight()); SwingUtilities.convertPointToScreen(location, treeContactList); location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y; location.x += 8; location.y -= 8; CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location); }
public void layoutComponents() { setLayout(new BorderLayout()); add(main, BorderLayout.CENTER); if (popperIsVisible) { if (getPopperButtonLocation() == RIGHT) { popper.setPreferredSize(new Dimension(14, main.getHeight())); add(popper, BorderLayout.EAST); } else if (getPopperButtonLocation() == BOTTOM) { popper.setPreferredSize(new Dimension(main.getWidth(), 14)); add(popper, BorderLayout.SOUTH); setPopperArrowDirection(DOWN); setPopupLocation(popper.getX(), popper.getY() + popper.getHeight() + 5); } } Utilities.updateView(this); }
@Override public synchronized void actionPerformed(ActionEvent e) { if (e.getSource() == imageButton) { GameService.orderService(1); int x = imageButton.getX(); int y = imageButton.getY(); if (imageList.get(x + "," + y)) { imageButton.setBounds(GameService.newX, GameService.newY, 100, 100); imageList.remove(x + "," + y); imageList.put(GameService.newX + "," + GameService.newY, false); GameService.orderService(2); GameService.orderService(1); GameService.orderService(3); if (null != GameService.leftNum) imageList.put(GameService.leftNum, true); if (null != GameService.rightNum) imageList.put(GameService.rightNum, true); if (null != GameService.upNum) imageList.put(GameService.upNum, true); if (null != GameService.downNum) imageList.put(GameService.downNum, true); } } }
private void resizeCantor(int width, int height) { int cantorEWidth = (width - 200) / 3; int cantorJtaHeight = 18; int cantorYList = 300; int cantorBWidth = 100; int cantorBHeight = 25; cantorPay.setBounds(10, 10, 150, cantorJtaHeight); cantorCurrL1.setBounds(10, 10, 150, 18); cantorScrollPane.setBounds( cantorCurrL1.getX() + cantorCurrL1.getWidth() + 40, cantorYList - 270, 500, 230); cantorBuyLabel.setBounds( cantorScrollPane.getX(), cantorScrollPane.getY() - 20, cantorEWidth, 18); cantorCurrBox1.setBounds(10, cantorCurrL1.getY() + 20, 100, 20); cantorCurrL2.setBounds(10, cantorCurrBox1.getY() + 20, cantorEWidth, 18); cantorCurrBox2.setBounds(cantorCurrBox1.getX(), cantorCurrL2.getY() + 20, 100, 20); cantorPrice.setBounds(cantorCurrBox2.getX(), cantorCurrBox2.getY() + 30, 150, cantorJtaHeight); cantorAmountJta.setBounds(cantorPrice.getX(), cantorPrice.getY() + 20, 100, cantorJtaHeight); cantorResButton.setBounds( cantorAmountJta.getX(), cantorAmountJta.getY() + 22, cantorBWidth, cantorBHeight); cantorCostLabel.setBounds( cantorResButton.getX(), cantorResButton.getY() + 28, 150, cantorJtaHeight); cantorCostJta.setBounds( cantorCostLabel.getX(), cantorCostLabel.getY() + 22, 100, cantorJtaHeight); cantorClientL.setBounds(10, cantorCostJta.getY() + 80, cantorEWidth, 18); cantorPESJta.setBounds(cantorClientL.getX(), cantorClientL.getY() + 22, 100, cantorJtaHeight); cantorPESButton.setBounds( cantorPESJta.getX(), cantorPESJta.getY() + 22, cantorBWidth, cantorBHeight); cantorScrollClientPane.setBounds( cantorScrollPane.getX(), cantorScrollPane.getY() + cantorScrollPane.getHeight() + 30, 550, 230); cantorDoIt.setBounds( cantorCostJta.getX(), cantorCostJta.getY() + 300, cantorBWidth + 50, cantorBHeight); }
public void content() { Font font00 = new Font("宋体", Font.BOLD, 20); Font font0 = new Font("宋体", Font.BOLD, 16); Font font = new Font("宋体", Font.BOLD, 15); line1 = new JLabel("————————————————————————"); line1.setFont(font0); line1.setBounds( listpanel.getX() - panel.getWidth() / 15, listpanel.getY() - panel.getHeight() / 20, panel.getWidth() * 3 / 5, panel.getHeight() / 10); line2 = new JLabel("——————————————————————"); line2.setFont(font0); line2.setForeground(Color.GRAY); line2.setBounds( listpanel.getX() - panel.getWidth() / 30, listpanel.getY() + panel.getHeight() / 36, panel.getWidth() * 3 / 5, panel.getHeight() / 10); line3 = new JLabel("——————————————————————"); line3.setFont(font0); line3.setForeground(Color.GRAY); line3.setBounds( listpanel.getX() - panel.getWidth() / 30, listpanel.getY() + panel.getHeight() / 100 * 75, panel.getWidth() * 3 / 5, panel.getHeight() / 10); ok = new JButton("提交"); ok.setFont(font); ok.setBounds( listpanel.getX() + panel.getWidth() * 2 / 5, listpanel.getY() + panel.getHeight() * 30 / 40, panel.getWidth() / 10, panel.getHeight() / 20); cancel = new JButton("取消"); cancel.setFont(font); cancel.setBounds( ok.getX() - panel.getWidth() / 7, ok.getY(), panel.getWidth() / 10, panel.getHeight() / 20); outList = new JLabel("出库单"); outList.setFont(font00); outList.setBounds( listpanel.getX() - panel.getWidth() / 15, listpanel.getY() - panel.getHeight() / 13, panel.getWidth() / 10, panel.getHeight() / 10); cargoinfo = new JLabel("货物信息"); cargoinfo.setFont(font0); cargoinfo.setBounds( listpanel.getX() - panel.getWidth() / 30, listpanel.getY(), panel.getWidth() / 10, panel.getHeight() / 10); bar = new JLabel("订单号"); bar.setFont(font); bar.setBounds( cargoinfo.getX(), cargoinfo.getY() + panel.getHeight() / 13, panel.getWidth() / 5, panel.getHeight() / 10); /* code=new JLabel("出库单号:"); code.setFont(font); code.setBounds(cargoinfo.getX(),bar.getY()+panel.getHeight()/13,panel.getWidth()/5, panel.getHeight()/10); */ outDate = new JLabel("出库日期:"); outDate.setFont(font); outDate.setBounds( cargoinfo.getX(), bar.getY() + panel.getHeight() / 14, panel.getWidth() / 5, panel.getHeight() / 10); distination = new JLabel("目的地:"); distination.setFont(font); distination.setBounds( cargoinfo.getX(), outDate.getY() + panel.getHeight() / 13, panel.getWidth() / 5, panel.getHeight() / 10); damageCondition = new JLabel("损坏情况"); damageCondition.setFont(font); damageCondition.setBounds( cargoinfo.getX(), distination.getY() + panel.getHeight() / 13, panel.getWidth() / 5, panel.getHeight() / 10); good = new JCheckBox("完好"); good.setFont(font); good.setBounds( damageCondition.getX() + panel.getWidth() / 8, damageCondition.getY() + panel.getHeight() / 45, panel.getWidth() / 12, panel.getHeight() / 20); damage = new JCheckBox("损坏"); damage.setFont(font); damage.setBounds( good.getX() + panel.getWidth() / 8, damageCondition.getY() + panel.getHeight() / 45, panel.getWidth() / 12, panel.getHeight() / 20); loadingtype = new JLabel("装运形式:"); loadingtype.setFont(font); loadingtype.setBounds( damageCondition.getX(), damageCondition.getY() + panel.getHeight() / 13, panel.getWidth() / 5, panel.getHeight() / 10); tB = new JCheckBox("火车"); tB.setFont(font); tB.setBounds( loadingtype.getX() + panel.getWidth() / 8, loadingtype.getY() + panel.getHeight() / 45, panel.getWidth() / 12, panel.getHeight() / 20); pB = new JCheckBox("飞机"); pB.setFont(font); pB.setBounds( tB.getX() + panel.getWidth() / 8, loadingtype.getY() + panel.getHeight() / 45, panel.getWidth() / 12, panel.getHeight() / 20); bB = new JCheckBox("汽车"); bB.setFont(font); bB.setBounds( pB.getX() + panel.getWidth() / 8, loadingtype.getY() + panel.getHeight() / 45, panel.getWidth() / 12, panel.getHeight() / 20); // transfercode=new JLabel("中转单编号:"); // transfercode.setFont(font); // transfercode.setBounds(cargoinfo.getX(),bB.getY()+panel.getHeight()/14,panel.getWidth()/5, // panel.getHeight()/10); // codetext = new JTextField(); // codetext.setBounds(code.getX()+panel.getWidth()/8,code.getY()+panel.getWidth()/50,panel.getWidth()/6, panel.getHeight()/20); /* tip1 = new JLabel("*请输入10位有效出库单号"); tip1.setFont(new Font("宋体", Font.BOLD, 12)); tip1.setForeground(Color.GRAY); tip1.setBounds(codetext.getX()+codetext.getWidth()+panel.getWidth()/50,code.getY(),panel.getWidth()/3, panel.getHeight()/10); */ vehicleCode = new JLabel("汽运编号:"); vehicleCode.setFont(font); vehicleCode.setBounds( cargoinfo.getX(), bB.getY() + panel.getHeight() / 14, panel.getWidth() / 5, panel.getHeight() / 10); bartext = new JTextField(); bartext.setBounds( bar.getX() + panel.getWidth() / 8, bar.getY() + panel.getWidth() / 50, panel.getWidth() / 6, panel.getHeight() / 20); distext = new JTextField(); distext.setBounds( distination.getX() + panel.getWidth() / 8, distination.getY() + panel.getWidth() / 50, panel.getWidth() / 6, panel.getHeight() / 20); // transtext = new JTextField(); // transtext.setBounds(transfercode.getX()+panel.getWidth()/7,transfercode.getY()+panel.getWidth()/50,panel.getWidth()/6, panel.getHeight()/20); vehtext = new JTextField(); vehtext.setBounds( distination.getX() + panel.getWidth() / 7, vehicleCode.getY() + panel.getWidth() / 50, panel.getWidth() / 6, panel.getHeight() / 20); /* tip2 = new JLabel("*请输入14位有效中转单编号"); tip2.setFont(new Font("宋体", Font.BOLD, 12)); tip2.setForeground(Color.GRAY); tip2.setBounds(transtext.getX()+transtext.getWidth()+panel.getWidth()/50,transfercode.getY(),panel.getWidth()/3, panel.getHeight()/10); */ year = new JComboBox(); month = new JComboBox(); day = new JComboBox(); String[] arr1 = new String[1000]; // 数组时个对象,对象在使用前要初始化 for (int i = 0; i < 1000; i++) { arr1[i] = i + 2000 + "年"; } year = new JComboBox(arr1); Calendar calendar = Calendar.getInstance(); String y = String.valueOf(calendar.get(Calendar.YEAR)) + "年"; for (String y1 : arr1) { if (y1.equals(y)) { year.setSelectedItem(y); } } year.setBounds( outDate.getX() + panel.getWidth() / 8, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 11, panel.getHeight() / 20); String[] arr2 = new String[12]; for (int i = 0; i < 12; i++) { arr2[i] = i + 1 + "月"; } month = new JComboBox(arr2); String m = String.valueOf(calendar.get(Calendar.MONTH) + 1) + "月"; for (String m1 : arr2) { if (m1.equals(m)) { month.setSelectedItem(m1); } } month.setBounds( year.getX() + year.getWidth() + panel.getWidth() / 100, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 12, panel.getHeight() / 20); String[] arr30 = new String[31]; for (int i = 0; i < 31; i++) { arr30[i] = i + 1 + "日"; } day = new JComboBox(arr30); String d = String.valueOf(calendar.get(Calendar.DATE)) + "日"; for (String d1 : arr30) { if (d1.equals(d)) { day.setSelectedItem(d1); } } day.setBounds( month.getX() + month.getWidth() + panel.getWidth() / 100, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 12, panel.getHeight() / 20); listpanel.add(day); month.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { // TODO Auto-generated method stub listpanel.remove(day); switch (month.getSelectedItem().toString()) { case "1月": case "3月": case "5月": case "7月": case "8月": case "10月": case "12月": String[] arr31 = new String[31]; for (int i = 0; i < 31; i++) { arr31[i] = i + 1 + "日"; } day = new JComboBox(arr31); day.setBounds( month.getX() + month.getWidth() + panel.getWidth() / 100, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 12, panel.getHeight() / 20); listpanel.add(day); break; case "4月": case "6月": case "9月": case "11月": String[] arr3 = new String[30]; for (int i = 0; i < 30; i++) { arr3[i] = i + 1 + "日"; } day = new JComboBox(arr3); day.setBounds( month.getX() + month.getWidth() + panel.getWidth() / 100, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 12, panel.getHeight() / 20); listpanel.add(day); break; case "2月": if (isLeap(year.getSelectedItem().toString())) { String[] arr33 = new String[29]; for (int i = 0; i < 29; i++) { arr33[i] = i + 1 + "日"; } day = new JComboBox(arr33); day.setBounds( month.getX() + month.getWidth() + panel.getWidth() / 100, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 12, panel.getHeight() / 20); listpanel.add(day); } else { String[] arr333 = new String[28]; for (int i = 0; i < 28; i++) { arr333[i] = i + 1 + "日"; } day = new JComboBox(arr333); day.setBounds( month.getX() + month.getWidth() + panel.getWidth() / 100, outDate.getY() + panel.getWidth() / 50, panel.getWidth() / 12, panel.getHeight() / 20); listpanel.add(day); } break; default: break; } } }); listpanel.add(year); listpanel.add(month); listpanel.add(day); listpanel.add(line1); listpanel.add(line2); listpanel.add(line3); // listpanel.add(tip1); // listpanel.add(tip2); listpanel.add(outList); listpanel.add(ok); listpanel.add(cancel); listpanel.add(bar); // listpanel.add(code); listpanel.add(cargoinfo); listpanel.add(outDate); listpanel.add(distination); listpanel.add(loadingtype); listpanel.add(damageCondition); listpanel.add(good); listpanel.add(damage); listpanel.add(pB); listpanel.add(bB); listpanel.add(tB); // listpanel.add(transfercode); listpanel.add(vehicleCode); listpanel.add(vehtext); listpanel.add(bartext); // listpanel.add(codetext); listpanel.add(distext); // listpanel.add(transtext); ok.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { String date = ((year.getSelectedIndex() + 2000) + "/") + ((month.getSelectedIndex() + 1) + "/") + ((day.getSelectedIndex() + 1 + "")); String damageCondition = null; if (good.isSelected()) { damageCondition = "完好"; } if (damage.isSelected()) { damageCondition = "损坏"; } TransType transtype = TransType.BUS; if (tB.isSelected()) { transtype = TransType.TRAIN; } if (bB.isSelected()) { transtype = TransType.BUS; } if (pB.isSelected()) { transtype = TransType.PLANE; } WarehouseMemory memory = (WarehouseMemory) ((WritePanel) panel).getMemory(); String code = memory.getWarehouseOutCode(); ReceiptCode cal = ConstructFactory.calculateCode(); code = cal.calculCode(code, memory.getUserName()); System.out.println(code); // code出库单号、bar为订单号 WarehouseOutVO warehouseOutVO = new WarehouseOutVO( bartext.getText(), code, distext.getText(), date, transtype, ((WritePanel) panel).getBelong(), vehtext.getText(), damageCondition); WarehouseBLService service = ConstructFactory.WarehouseFactory(); boolean key = service.WarehouseOut(warehouseOutVO); if (key) { WarehouseReceipt wr = ConstructFactory.WarehouseReceiptFactory(); wr.saveWarehouseOutCode(code, memory.getUserName()); memory.setWarehouseOutCode(memory.getWarehouseOutCode() + " " + code); memory.setWarehouseOutDate(memory.getWarehouseOutDate() + " " + date); } } }); cancel.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { remove(); panel.repaint(); } }); }
public SpriteCreatorGUI() { setLayout(null); JLabel l; /* * Preview box */ previewBox = new SpritePic(this); previewPane = new JScrollPane(previewBox); previewPane.setLocation(220, 10); previewPane.setSize(420, 365); previewPane.getViewport().setBackground(Color.GRAY); add(previewPane); /* * Initialize fields */ l = new JLabel("Name: "); l.setSize(l.getPreferredSize()); l.setLocation(10, 10); nameField = new JTextField(""); nameField.setSize(200, 24); nameField.setLocation(10, 32); add(l); add(nameField); l = new JLabel("Layers: "); l.setSize(200, 16); l.setLocation(10, 64); layerList = new JList(layers); layerListPane = new JScrollPane(layerList); layerListPane.setSize(200, 228); layerListPane.setLocation(10, 92); add(l); add(layerListPane); refreshList(); /* * Initialize Direction handling */ l = new JLabel("Direction: "); l.setSize(l.getPreferredSize()); l.setLocation(650, 10); direction = new JSlider(0, Map.DIRECTIONS); direction.setPaintTicks(true); direction.setPaintLabels(true); direction.setSnapToTicks(true); direction.setSize(230, 36); direction.setLocation(650, 32); direction.addChangeListener(this); add(direction); add(l); /* * Initialize Walk Cycle handling */ l = new JLabel("Walk Cycle Frame: "); l.setSize(l.getPreferredSize()); l.setLocation(650, 72); walkCycle = new JSlider(0, NPC.WALKCYCLE); walkCycle.setPaintTicks(true); walkCycle.setPaintLabels(true); walkCycle.setSnapToTicks(true); walkCycle.setSize(230, 36); walkCycle.setLocation(650, 92); walkCycle.addChangeListener(this); add(walkCycle); add(l); /* * Initialize Buttons */ RemButton = new JButton("-"); RemButton.setSize(48, 24); RemButton.setLocation(210 - RemButton.getWidth(), 350); AddButton = new JButton("+"); AddButton.setSize(48, 24); AddButton.setLocation(RemButton.getX() - AddButton.getWidth(), 350); EdtButton = new JButton("Edit"); EdtButton.setSize(100, 24); EdtButton.setLocation(10, 350); AddButton.addActionListener(this); RemButton.addActionListener(this); EdtButton.addActionListener(this); add(AddButton); add(RemButton); add(EdtButton); SftUpButton = new JButton("\u2191"); SftUpButton.setSize(100, 24); SftUpButton.setLocation(10, 320); SftDnButton = new JButton("\u2193"); SftDnButton.setSize(100, 24); SftDnButton.setLocation(110, 320); SftUpButton.addActionListener(this); SftDnButton.addActionListener(this); add(SftUpButton); add(SftDnButton); int[] buttonSize = {230, 24}; newButton = new JButton("New"); newButton.setSize(buttonSize[0], buttonSize[1]); newButton.setLocation(650, 260); saveButton = new JButton("Save"); saveButton.setSize(buttonSize[0], buttonSize[1]); saveButton.setLocation(650, 290); savePNGButton = new JButton("Save as .PNG"); savePNGButton.setSize(buttonSize[0], buttonSize[1]); savePNGButton.setLocation(650, 320); loadButton = new JButton("Load"); loadButton.setSize(buttonSize[0], buttonSize[1]); loadButton.setLocation(650, 350); newButton.addActionListener(this); saveButton.addActionListener(this); savePNGButton.addActionListener(this); loadButton.addActionListener(this); add(newButton); add(saveButton); add(savePNGButton); add(loadButton); }
private void addComponents() { @SuppressWarnings("unused") LabelsMousePointGet labelsMousePointGet = new LabelsMousePointGet(); for (int i = 0; i < 4; i++) { this.add(LabelsMousePointGet.label[i]); } JLabel pageLabel = new JLabel(""); panelTable = new PanelTable(pageLabel); // ------Add align all button----- ButtonAllCheck buttonAllCheck = new ButtonAllCheck(panelTable, ButtonAllCheck.ALIGN_ALL); this.add(buttonAllCheck); buttonAllCheck.setBounds( PANEL_TABLE_SIZE.width / 5, PANEL_TABLE_SIZE.height + 55, dialWidth, dialHeight); // ------ // ------Add align none button----- ButtonAllCheck buttonAllUnCheck = new ButtonAllCheck(panelTable, ButtonAllCheck.ALIGN_NONE); this.add(buttonAllUnCheck); buttonAllUnCheck.setBounds( PANEL_TABLE_SIZE.width * 3 / 5, PANEL_TABLE_SIZE.height + 55, dialWidth, dialHeight); // ------ this.add(panelTable); panelTable.setBounds(0, 50, PANEL_TABLE_SIZE.width, PANEL_TABLE_SIZE.height); this.add(pageLabel); pageLabel.setBounds(PANEL_TABLE_SIZE.width / 2 - 50, PANEL_TABLE_SIZE.height + 50, 100, 20); // panelTable.setData(ArrayOfTrgWord, ArrayOfSrcWord, ArrayOfMappingData); InputFileDialog trgDialog = new InputFileDialog(InputFileDialog.TRG); InputFileDialog srcDialog = new InputFileDialog(InputFileDialog.SRC); InputFileDialog alignDialog = new InputFileDialog(InputFileDialog.ALIGN); this.add(trgDialog); this.add(srcDialog); this.add(alignDialog); srcDialog.setBounds(10, 10, dialWidth, dialHeight); trgDialog.setBounds(20 + dialWidth, 10, dialWidth, dialHeight); alignDialog.setBounds(30 + dialWidth * 2, 10, dialWidth, dialHeight); try { ButtonPanelControl buttonNext = new ButtonPanelControl(ButtonPanelControl.NEXT, panelTable); ButtonPanelControl buttonPrevious = new ButtonPanelControl(ButtonPanelControl.PREVIOUS, panelTable); this.add(buttonNext); buttonNext.setBounds( PANEL_TABLE_SIZE.width - ButtonPanelControl.size.width - 10, PANEL_TABLE_SIZE.height + 50 + 5, ButtonPanelControl.size.width, ButtonPanelControl.size.height); this.add(buttonPrevious); buttonPrevious.setBounds( PANEL_TABLE_SIZE.width - ButtonPanelControl.size.width * 2 - 15, PANEL_TABLE_SIZE.height + panelTable.getY() + 5, ButtonPanelControl.size.width, ButtonPanelControl.size.height); } catch (IOException e) { // TODO �����������ꂽ catch �u���b�N e.printStackTrace(); } button.setBounds(600, 10, 100, dialHeight); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { panelTable.reGenerateTable(); isFileOpened = true; } }); this.add(button); SaveButton saveButton = new SaveButton(); saveButton.setBounds( button.getX() + button.getSize().width + 50, button.getY(), button.getSize().width, button.getSize().height); this.add(saveButton); }
/** * Constructs the dialog window * * @param p Parent GUI */ public RegionEditorDialog(MapEditorGUI p) { parent = p; setLayout(null); /* * Initialize naming field */ JLabel l = new JLabel("Name"); l.setSize(l.getPreferredSize()); l.setLocation(10, 10); nameField = new JTextField("plains"); nameField.setSize(200, 24); nameField.setLocation(10, 32); add(l); add(nameField); /* * Initialize encounter spinner */ l = new JLabel("Encounter rate"); l.setSize(l.getPreferredSize()); l.setLocation(10, 64); eRateSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 20, 1)); eRateSpinner.setSize(eRateSpinner.getPreferredSize()); eRateSpinner.setLocation(210 - eRateSpinner.getWidth(), 62); add(l); add(eRateSpinner); /* * Initialize Terrain selector */ l = new JLabel("Terrain"); l.setSize(l.getPreferredSize()); l.setLocation(10, 96); terrain = new JComboBox(ToolKit.terrains); terrain.setSize(200, 24); terrain.setLocation(10, 120); add(l); add(terrain); /* * Initialize formation list */ l = new JLabel("Formations"); l.setSize(l.getPreferredSize()); l.setLocation(10, 156); fList = new JList(formations); fPane = new JScrollPane(fList); fPane.setSize(200, 160); fPane.setLocation(10, 172); add(l); add(fPane); /* * Initialize buttons */ okButton = new JButton("OK"); okButton.setSize(80, 24); okButton.setLocation(20, 380); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setSize(80, 24); cancelButton.setLocation(120, 380); cancelButton.addActionListener(this); add(okButton); add(cancelButton); fRemButton = new JButton("-"); fRemButton.setSize(fRemButton.getPreferredSize()); fRemButton.setLocation(210 - fRemButton.getWidth(), 335); fAddButton = new JButton("+"); fAddButton.setSize(fAddButton.getPreferredSize()); fAddButton.setLocation(fRemButton.getX() - fAddButton.getWidth(), 335); fEdtButton = new JButton("Edit"); fEdtButton.setSize(100, 24); fEdtButton.setLocation(10, 335); fAddButton.addActionListener(this); fRemButton.addActionListener(this); fEdtButton.addActionListener(this); add(fAddButton); add(fRemButton); add(fEdtButton); /* * Initialize dialog window */ setSize(230, 450); setVisible(true); setModal(true); setResizable(false); setTitle("Region Editor"); setLocationRelativeTo(parent); }