public ListPanel() { list.setTitle("Title"); textField.setFont(new Font(MONOSPACED, PLAIN, 11)); list.setTransferablePolicy(new FileListTransferablePolicy(list)); list.setExportHandler(new FileBotListExportHandler(list)); list.getRemoveAction().setEnabled(true); JSpinner fromSpinner = new JSpinner(fromSpinnerModel); JSpinner toSpinner = new JSpinner(toSpinnerModel); fromSpinner.setEditor(new NumberEditor(fromSpinner, "#")); toSpinner.setEditor(new NumberEditor(toSpinner, "#")); setLayout( new MigLayout("nogrid, fill, insets dialog", "align center", "[pref!, center][fill]")); add(new JLabel("Pattern:"), "gapbefore indent"); add(textField, "gap related, wmin 2cm, sizegroupy editor"); add(new JLabel("From:"), "gap 5mm"); add(fromSpinner, "gap related, wmax 14mm, sizegroup spinner, sizegroupy editor"); add(new JLabel("To:"), "gap 5mm"); add(toSpinner, "gap related, wmax 14mm, sizegroup spinner, sizegroupy editor"); add(new JButton(createAction), "gap 7mm, gapafter indent, wrap paragraph"); add(list, "grow"); // panel with buttons that will be added inside the list component JPanel buttonPanel = new JPanel(new MigLayout("insets 1.2mm, nogrid, fill", "align center")); buttonPanel.add(new JButton(new LoadAction(list.getTransferablePolicy()))); buttonPanel.add(new JButton(new SaveAction(list.getExportHandler())), "gap related"); list.add(buttonPanel, BorderLayout.SOUTH); TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ENTER"), createAction); }
/** positions a label in a particular spot */ private void position(GLabel label_positioned) { GLabel box = label_positioned; box.setFont(new Font("Serif", Font.BOLD, FONTSIZE)); box.setColor(FONTCOLOR); add(box); }
/** Stops execution time measurement. */ public void stop() { add(System.nanoTime() - startClock); }
/** Places a rectangle at x,y with width, height and specified color */ public void place(int x, int y, int width, int height, Color shapeColor) { GRect shape = new GRect(x, y, width, height); shape.setFilled(true); shape.setColor(shapeColor); add(shape); }
/*Defines and places the Rent state as a circle */ private void placeRent(int x, int y, int width, int height, Color rentColor) { GOval shape = new GOval(x, y, width, height); shape.setFilled(true); shape.setColor(rentColor); add(shape); }
/*places the equipment in the Available state based on the availEquipment ArrayList */ private void placeEquipment(Equipment eT) { add(eT.shape); position(eT.label); }
/*Place the labels on top */ private void placeLabels() { /*Place label On Rent */ GLabel onRentLabel = new GLabel("ON RENT"); onRentLabel.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE)); onRentLabel.setColor(FONTCOLOR); add(onRentLabel, RENTX + RENTWIDTH / 2 - onRentLabel.getWidth() / 2, RENTY - EQUIPHEIGHT); /*Place label Available */ GLabel availForRentLabel = new GLabel("AVAILABLE FOR RENT"); availForRentLabel.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE)); availForRentLabel.setColor(FONTCOLOR); add( availForRentLabel, AVAILX + AVAILWIDTH / 2 - availForRentLabel.getWidth() / 2, AVAILY - EQUIPHEIGHT); /*Place label Shop */ GLabel shopLabel = new GLabel("SHOP"); shopLabel.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE)); shopLabel.setColor(FONTCOLOR); add(shopLabel, SHOPX + SHOPWIDTH / 2 - shopLabel.getWidth() / 2, SHOPY - EQUIPHEIGHT * 14); /*Place the lost sales label */ lostSalesLabel1 = new GLabel("Lost Sales HR = " + lostSales.get(0)); lostSalesLabel2 = new GLabel("Lost Sales MR = " + lostSales.get(1)); lostSalesLabel3 = new GLabel("Lost Sales LR = " + lostSales.get(2)); lostSalesLabel1.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE)); lostSalesLabel2.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE)); lostSalesLabel3.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE)); lostSalesLabel1.setColor(FONTCOLOR); lostSalesLabel2.setColor(FONTCOLOR); lostSalesLabel3.setColor(FONTCOLOR); add(lostSalesLabel1, START_X + 4 * EQUIPWIDTH, 4 * EQUIPHEIGHT); add( lostSalesLabel2, START_X + 4 * EQUIPWIDTH, 4 * EQUIPHEIGHT + lostSalesLabel1.getHeight() * 1.5); add( lostSalesLabel3, START_X + 4 * EQUIPWIDTH, 4 * EQUIPHEIGHT + lostSalesLabel2.getHeight() * 3); /*Place the days elapsed label */ daysElapsed = 0; daysElapsedLabel = new GLabel("DAY" + daysElapsed); daysElapsedLabel.setFont(new Font("Serif", Font.BOLD, 24)); daysElapsedLabel.setColor(Color.red.darker()); add(daysElapsedLabel, APPLICATION_WIDTH / 2, START_Y / 2); /*Place the sales Label */ sales = 0; salesLabel = new GLabel("SALES: $" + sales); salesLabel.setFont(new Font("Serif", Font.BOLD, 24)); salesLabel.setColor(Color.GREEN.darker()); add(salesLabel, APPLICATION_WIDTH / 2, daysElapsedLabel.getY() + daysElapsedLabel.getY()); /*Place the capitalInvested Label */ capitalInvested = 0; capitalLabel = new GLabel("Capital Invested: $" + capitalInvested); capitalLabel.setFont(new Font("Serif", Font.BOLD, 18)); capitalLabel.setColor(Color.RED.darker()); add( capitalLabel, lostSalesLabel1.getX(), lostSalesLabel3.getY() + lostSalesLabel3.getHeight() * 2); }
/** places the 4 walls */ private void placeWalls() { GRect walls = new GRect(START_X, START_Y, GWIDTH, GHEIGHT); add(walls); }