Java Code Examples for javax.swing.JProgressBar#getModel()
The following examples show how to use
javax.swing.JProgressBar#getModel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConstructionSitesPanel.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Constructor. * @param site the construction site. */ private ConstructionSitePanel(ConstructionSite site) { // Use JPanel constructor super(); // Initialize data members. this.site = site; // Set the layout. setLayout(new BorderLayout(5, 5)); // Set border // setBorder(new MarsPanelBorder()); // Create the status panel. statusLabel = new JLabel("Status: ", JLabel.LEFT); add(statusLabel, BorderLayout.NORTH); // Create the progress bar panel. JPanel progressBarPanel = new JPanel(); add(progressBarPanel, BorderLayout.CENTER); // Prepare work progress bar. JProgressBar workBar = new JProgressBar(); workBarModel = workBar.getModel(); workBar.setStringPainted(true); progressBarPanel.add(workBar); // Update progress bar. update(); // Add tooltip. setToolTipText(getToolTipString()); }
Example 2
Source File: TabPanelMaintenance.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * * @param building the building to display. */ public BuildingMaintenancePanel(Building building) { // User WebPanel constructor. super(); manager = building.getMalfunctionManager(); setLayout(new GridLayout(4, 1, 0, 0)); // setBorder(new MarsPanelBorder()); WebLabel buildingLabel = new WebLabel(building.getNickName(), WebLabel.LEFT); buildingLabel.setFont(new Font("Serif", Font.BOLD, 14)); add(buildingLabel); // Add wear condition cache and label. wearConditionCache = (int) Math.round(manager.getWearCondition()); wearConditionLabel = new WebLabel( Msg.getString("BuildingPanelMaintenance.wearCondition", wearConditionCache), WebLabel.CENTER); TooltipManager.setTooltip(wearConditionLabel, Msg.getString("BuildingPanelMaintenance.wear.toolTip"), TooltipWay.down); // wearConditionLabel.setMargin (4); // add(wearConditionLabel); WebPanel mainPanel = new WebPanel(new BorderLayout(0, 0)); add(mainPanel); lastCompletedCache = (int) (manager.getTimeSinceLastMaintenance() / 1000D); lastLabel = new WebLabel("Last completed : " + lastCompletedCache + " sols ago", WebLabel.LEFT); mainPanel.add(lastLabel, BorderLayout.WEST); // lastLabel.setToolTipText(getToolTipString()); TooltipManager.setTooltip(lastLabel, getToolTipString(), TooltipWay.down); // Prepare progress bar panel. WebPanel progressBarPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); // mainPanel.add(progressBarPanel, BorderLayout.CENTER); add(progressBarPanel); mainPanel.add(wearConditionLabel, BorderLayout.CENTER); // Prepare progress bar. JProgressBar progressBar = new JProgressBar(); progressBarModel = progressBar.getModel(); progressBar.setStringPainted(true); progressBar.setPreferredSize(new Dimension(240, 15)); progressBarPanel.add(progressBar); // Set initial value for progress bar. double completed = manager.getMaintenanceWorkTimeCompleted(); double total = manager.getMaintenanceWorkTime(); int percentDone = (int) (100D * (completed / total)); progressBarModel.setValue(percentDone); // Prepare parts label. Map<Integer, Integer> parts = manager.getMaintenanceParts(); partsLabel = new WebLabel(getPartsString(parts, false), WebLabel.CENTER); partsLabel.setPreferredSize(new Dimension(-1, -1)); add(partsLabel); TooltipManager.setTooltip(partsLabel, getPartsString(parts, false), TooltipWay.down); }
Example 3
Source File: TabPanelMaintenance.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * * @param malfunction the malfunction for the panel. * @param building the building the malfunction is in. */ public BuildingMalfunctionPanel(Malfunction malfunction, Building building) { // Use WebPanel constructor super(); // Initialize data members this.malfunction = malfunction; // Set layout and border. setLayout(new GridLayout(5, 1, 0, 0)); // setBorder(new MarsPanelBorder()); // Prepare the building label. WebLabel buildingLabel = new WebLabel(building.getNickName(), WebLabel.LEFT); buildingLabel.setFont(new Font("Serif", Font.BOLD, 14)); add(buildingLabel); // Prepare the malfunction label. malfunctionLabel = new WebLabel(malfunction.getName(), WebLabel.LEFT); malfunctionLabel.setForeground(Color.red); add(malfunctionLabel); workLabel = new WebLabel("", WebLabel.LEFT); // workLabel.setFont(new Font("Serif", Font.ITALIC, 12)); // workLabel.setForeground(Color.LIGHT_GRAY); // workLabel.setBackground(Color.DARK_GRAY); add(workLabel); // Progress bar panel. WebPanel progressBarPanel = new WebPanel(new BorderLayout(0, 0)); add(progressBarPanel, BorderLayout.CENTER); // Prepare progress bar. JProgressBar progressBar = new JProgressBar(); progressBarModel = progressBar.getModel(); progressBar.setStringPainted(true); progressBarPanel.add(progressBar, BorderLayout.CENTER); // Set initial value for repair progress bar. progressBarModel.setValue(0); // Prepare parts label. partsLabel = new WebLabel(getPartsString(malfunction.getRepairParts(), false), WebLabel.CENTER); partsLabel.setPreferredSize(new Dimension(-1, -1)); add(partsLabel); // Add tooltip. // setToolTipText(getToolTipString()); TooltipManager.setTooltip(this, getToolTipString(), TooltipWay.up); update(); }
Example 4
Source File: FoodProductionPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor * * @param process the foodProduction process. * @param showBuilding is the building name shown? * @param processStringWidth the max string width to display for the process * name. */ public FoodProductionPanel(FoodProductionProcess process, boolean showBuilding, int processStringWidth) { // Call JPanel constructor super(); // Initialize data members. this.process = process; // Set layout if (showBuilding) setLayout(new GridLayout(4, 1, 0, 0)); else setLayout(new GridLayout(3, 1, 0, 0)); // Set border setBorder(new MarsPanelBorder()); // Prepare name panel. JPanel namePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 1, 0)); add(namePane); // Prepare cancel button. JButton cancelButton = new JButton(ImageLoader.getIcon("CancelSmall")); cancelButton.setMargin(new Insets(0, 0, 0, 0)); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // try { getFoodProductionProcess().getKitchen().endFoodProductionProcess(getFoodProductionProcess(), true); // } // catch (BuildingException e) {} } }); cancelButton.setToolTipText("Cancel his Food Production Process"); namePane.add(cancelButton); // Prepare name label. String name = process.getInfo().getName(); if (name.length() > 0) { String firstLetter = name.substring(0, 1).toUpperCase(); name = " " + firstLetter + name.substring(1); } if (name.length() > processStringWidth) name = name.substring(0, processStringWidth) + "..."; // 2014-11-19 Capitalized process names JLabel nameLabel = new JLabel(Conversion.capitalize(name), JLabel.CENTER); namePane.add(nameLabel); if (showBuilding) { // Prepare building name label. // 2014-11-19 Changed from getName() to getNickName() String buildingName = process.getKitchen().getBuilding().getNickName(); JLabel buildingNameLabel = new JLabel(buildingName, JLabel.CENTER); add(buildingNameLabel); } // Prepare work panel. JPanel workPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); add(workPane); // Prepare work label. JLabel workLabel = new JLabel("Work: ", JLabel.LEFT); workPane.add(workLabel); // Prepare work progress bar. JProgressBar workBar = new JProgressBar(); workBarModel = workBar.getModel(); workBar.setStringPainted(true); workPane.add(workBar); // Prepare time panel. JPanel timePane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); add(timePane); // Prepare time label. JLabel timeLabel = new JLabel("Time: ", JLabel.LEFT); timePane.add(timeLabel); // Prepare time progress bar. JProgressBar timeBar = new JProgressBar(); timeBarModel = timeBar.getModel(); timeBar.setStringPainted(true); timePane.add(timeBar); // Update progress bars. update(); // Add tooltip. setToolTipText(getToolTipString(process.getInfo(), process.getKitchen().getBuilding())); }
Example 5
Source File: ManufacturePanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor * @param process the manufacturing process. * @param showBuilding is the building name shown? * @param processStringWidth the max string width to display for the process name. */ public ManufacturePanel(ManufactureProcess process, boolean showBuilding, int processStringWidth) { // Call WebPanel constructor super(); // Initialize data members. this.process = process; // Set layout if (showBuilding) setLayout(new GridLayout(4, 1, 0, 0)); else setLayout(new GridLayout(3, 1, 0, 0)); // Set border setBorder(new MarsPanelBorder()); // Prepare name panel. WebPanel namePane = new WebPanel(new FlowLayout(FlowLayout.LEFT, 1, 0)); add(namePane); // Prepare cancel button. JButton cancelButton = new JButton(ImageLoader.getIcon("CancelSmall")); cancelButton.setMargin(new Insets(0, 0, 0, 0)); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // try { getManufactureProcess().getWorkshop().endManufacturingProcess(getManufactureProcess(), true); // } // catch (BuildingException e) {} } }); cancelButton.setToolTipText("Cancel manufacturing process"); namePane.add(cancelButton); // Prepare name label. String name = process.getInfo().getName(); if (name.length() > 0) { String firstLetter = name.substring(0, 1).toUpperCase(); name = " " + firstLetter + name.substring(1); } if (name.length() > processStringWidth) name = name.substring(0, processStringWidth) + "..."; // Capitalize process names JLabel nameLabel = new JLabel(Conversion.capitalize(name), JLabel.CENTER); namePane.add(nameLabel); if (showBuilding) { // Prepare building name label. String buildingName = process.getWorkshop().getBuilding().getNickName(); JLabel buildingNameLabel = new JLabel(buildingName, JLabel.CENTER); add(buildingNameLabel); } // Prepare work panel. WebPanel workPane = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); add(workPane); // Prepare work label. JLabel workLabel = new JLabel("Work: ", JLabel.LEFT); workPane.add(workLabel); // Prepare work progress bar. JProgressBar workBar = new JProgressBar(); workBarModel = workBar.getModel(); workBar.setStringPainted(true); workPane.add(workBar); // Prepare time panel. WebPanel timePane = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); add(timePane); // Prepare time label. JLabel timeLabel = new JLabel("Time: ", JLabel.LEFT); timePane.add(timeLabel); // Prepare time progress bar. JProgressBar timeBar = new JProgressBar(); timeBarModel = timeBar.getModel(); timeBar.setStringPainted(true); timePane.add(timeBar); // Update progress bars. update(); // Add tooltip. setToolTipText(getToolTipString(process.getInfo(), process.getWorkshop().getBuilding())); }
Example 6
Source File: MaintenanceTabPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; Malfunctionable malfunctionable = (Malfunctionable) unit; MalfunctionManager manager = malfunctionable.getMalfunctionManager(); // Create maintenance label. JPanel mpanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JLabel maintenanceLabel = new JLabel(Msg.getString("MaintenanceTabPanel.title", JLabel.CENTER)); maintenanceLabel.setFont(new Font("Serif", Font.BOLD, 16)); mpanel.add(maintenanceLabel); topContentPanel.add(mpanel); // Create maintenance panel JPanel maintenancePanel = new JPanel(new GridLayout(6, 1, 0, 0)); maintenancePanel.setBorder(new MarsPanelBorder()); topContentPanel.add(maintenancePanel); // Create wear condition label. wearConditionCache = (int) Math.round(manager.getWearCondition()); wearConditionLabel = new JLabel("Condition: " + wearConditionCache + "%", JLabel.CENTER); wearConditionLabel.setToolTipText("The health condition due to wear & tear : 100% = new; 0% = worn out"); maintenancePanel.add(wearConditionLabel); // Create lastCompletedLabel. lastCompletedTime = (int) (manager.getTimeSinceLastMaintenance() / 1000D); lastCompletedLabel = new JLabel("Last Completed: " + lastCompletedTime + " sols", JLabel.CENTER); maintenancePanel.add(lastCompletedLabel); // Create maintenance progress bar panel. JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); maintenancePanel.add(progressPanel); // Prepare maintenance parts label. partsLabel = new JLabel(getPartsString(false), JLabel.CENTER); partsLabel.setPreferredSize(new Dimension(-1, -1)); maintenancePanel.add(partsLabel); // Prepare progress bar. JProgressBar progressBar = new JProgressBar(); progressBarModel = progressBar.getModel(); progressBar.setStringPainted(true); progressPanel.add(progressBar); // Set initial value for progress bar. double completed = manager.getMaintenanceWorkTimeCompleted(); double total = manager.getMaintenanceWorkTime(); int percentDone = (int) (100D * (completed / total)); progressBarModel.setValue(percentDone); // Prepare malfunction panel JPanel malfunctionPanel = new JPanel(new BorderLayout(0, 0)); // malfunctionPanel.setBorder(new MarsPanelBorder()); centerContentPanel.add(malfunctionPanel, BorderLayout.CENTER); // Create malfunctions label JLabel malfunctionsLabel = new JLabel("Malfunctions", JLabel.CENTER); malfunctionPanel.add(malfunctionsLabel, BorderLayout.NORTH); // Create scroll panel for malfunction list JScrollPane malfunctionScrollPanel = new JScrollPane(); malfunctionScrollPanel.setPreferredSize(new Dimension(170, 90)); malfunctionPanel.add(malfunctionScrollPanel, BorderLayout.CENTER); // Create malfunction list main panel. JPanel malfunctionListMainPanel = new JPanel(new BorderLayout(0, 0)); malfunctionScrollPanel.setViewportView(malfunctionListMainPanel); // Create malfunction list panel malfunctionListPanel = new JPanel(); malfunctionListPanel.setLayout(new BoxLayout(malfunctionListPanel, BoxLayout.Y_AXIS)); malfunctionListMainPanel.add(malfunctionListPanel, BorderLayout.NORTH); // Create malfunction panels malfunctionCache = malfunctionable.getMalfunctionManager().getMalfunctions(); malfunctionPanels = new ArrayList<MalfunctionPanel>(); Iterator<Malfunction> i = malfunctionCache.iterator(); while (i.hasNext()) { MalfunctionPanel panel = new MalfunctionPanel(i.next()); malfunctionListPanel.add(panel); malfunctionPanels.add(panel); } }