Java Code Examples for com.alee.laf.scroll.WebScrollPane#setViewportView()
The following examples show how to use
com.alee.laf.scroll.WebScrollPane#setViewportView() .
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: WebFileChooserPanel.java From weblaf with GNU General Public License v3.0 | 6 votes |
/** * Creates file tree and all related components. */ protected void createFileTree () { treeScroll = new WebScrollPane ( StyleId.filechooserNavScroll.at ( centralSplit ) ); treeScroll.setPreferredSize ( new Dimension ( dividerLocation, 1 ) ); fileTree = new WebFileTree ( StyleId.filechooserFileTree.at ( treeScroll ) ); fileTree.setExpandSelected ( true ); fileTree.setSelectionMode ( TreeSelectionModel.SINGLE_TREE_SELECTION ); treeScroll.setViewportView ( fileTree ); fileTreeListener = new TreeSelectionListener () { @Override public void valueChanged ( final TreeSelectionEvent e ) { if ( fileTree.getSelectionCount () > 0 ) { updateCurrentFolder ( fileTree.getSelectedFile (), UpdateSource.tree ); } } }; fileTree.addTreeSelectionListener ( fileTreeListener ); }
Example 2
Source File: EmergencySupplyMissionCustomInfoPanel.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public EmergencySupplyMissionCustomInfoPanel() { // Use JPanel constructor super(); // Set the layout. setLayout(new BorderLayout()); // Create the emergency supplies label. WebLabel emergencySuppliesLabel = new WebLabel(Msg.getString("EmergencySupplyMissionCustomInfoPanel.emergencySupplies"), WebLabel.LEFT); //$NON-NLS-1$ add(emergencySuppliesLabel, BorderLayout.NORTH); // Create a scroll pane for the emergency supplies table. WebScrollPane emergencySuppliesScrollPane = new WebScrollPane(); emergencySuppliesScrollPane.setPreferredSize(new Dimension(-1, -1)); add(emergencySuppliesScrollPane, BorderLayout.CENTER); // Create the emergency supplies table and model. emergencySuppliesTableModel = new EmergencySuppliesTableModel(); WebTable emergencySuppliesTable = new WebTable(emergencySuppliesTableModel); emergencySuppliesScrollPane.setViewportView(emergencySuppliesTable); }
Example 3
Source File: ExplorationCustomInfoPanel.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public ExplorationCustomInfoPanel() { // Use JPanel constructor super(); setLayout(new BorderLayout()); // Create the main scroll panel. WebScrollPane mainScrollPane = new WebScrollPane(); add(mainScrollPane, BorderLayout.NORTH); // Create main panel. mainPane = Box.createVerticalBox(); mainScrollPane.setViewportView(mainPane); sitePanes = new HashMap<String, ExplorationSitePanel>(5); }
Example 4
Source File: TabPanelCrew.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Prepare title label. WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelCrew.title"), WebLabel.CENTER); //$NON-NLS-1$ titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); titlePanel.add(titleLabel); topContentPanel.add(titlePanel); // Create crew count panel WebPanel crewCountPanel = new WebPanel(new GridLayout(2, 1, 0, 0)); // crewCountPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(crewCountPanel); // Create crew num label crewNumCache = crewable.getCrewNum(); crewNumLabel = new WebLabel(Msg.getString("TabPanelCrew.crew", crewNumCache), WebLabel.CENTER); //$NON-NLS-1$ crewCountPanel.add(crewNumLabel); // Create crew capacity label crewCapacityCache = crewable.getCrewCapacity(); crewCapLabel = new WebLabel(Msg.getString("TabPanelCrew.crewCapacity", crewCapacityCache), WebLabel.CENTER); //$NON-NLS-1$ crewCountPanel.add(crewCapLabel); // Create crew display panel WebPanel crewDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT)); // crewDisplayPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(crewDisplayPanel); // Create scroll panel for crew list. WebScrollPane crewScrollPanel = new WebScrollPane(); crewScrollPanel.setPreferredSize(new Dimension(175, 200)); crewDisplayPanel.add(crewScrollPanel); // Create crew list model crewListModel = new DefaultListModel<Person>(); //crewListModel = new DefaultListModel<Unit>(); crewCache = crewable.getCrew(); //crewCache = crewable.getUnitCrew(); Iterator<Person> i = crewCache.iterator(); //Iterator<Unit> i = crewCache.iterator(); while (i.hasNext()) crewListModel.addElement(i.next()); // Create crew list crewList = new JList<Person>(crewListModel); //crewList = new JList<Unit>(crewListModel); crewList.addMouseListener(this); crewScrollPanel.setViewportView(crewList); // Create crew monitor button WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$ monitorButton.setMargin(new Insets(1, 1, 1, 1)); monitorButton.addActionListener(this); monitorButton.setToolTipText(Msg.getString("TabPanelCrew.tooltip.monitor")); //$NON-NLS-1$ crewDisplayPanel.add(monitorButton); }
Example 5
Source File: ConstructionMissionCustomInfoPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * @param desktop the main desktop panel. */ public ConstructionMissionCustomInfoPanel(MainDesktopPane desktop) { // Use MissionCustomInfoPanel constructor. super(); // Initialize data members. this.desktop = desktop; // Set layout. setLayout(new BorderLayout()); WebPanel contentsPanel = new WebPanel(new GridLayout(4, 1)); add(contentsPanel, BorderLayout.NORTH); WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); contentsPanel.add(titlePanel); String titleLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.titleLabel"); //$NON-NLS-1$ WebLabel titleLabel = new WebLabel(titleLabelString); titlePanel.add(titleLabel); WebPanel settlementPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT)); contentsPanel.add(settlementPanel); String settlementLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.settlementLabel"); //$NON-NLS-1$ WebLabel settlementLabel = new WebLabel(settlementLabelString); settlementPanel.add(settlementLabel); settlementButton = new WebButton(" "); settlementPanel.add(settlementButton); settlementButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (mission != null) { Settlement settlement = mission.getAssociatedSettlement(); if (settlement != null) getDesktop().openUnitWindow(settlement, false); } } }); WebPanel stagePanel = new WebPanel(new FlowLayout(FlowLayout.LEFT)); contentsPanel.add(stagePanel); String stageLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.stageLabel"); //$NON-NLS-1$ stageLabel = new WebLabel(stageLabelString); stagePanel.add(stageLabel); WebPanel progressBarPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT)); contentsPanel.add(progressBarPanel); WebProgressBar progressBar = new WebProgressBar(); progressBarModel = progressBar.getModel(); progressBar.setStringPainted(true); progressBarPanel.add(progressBar); WebPanel lowerContentsPanel = new WebPanel(new BorderLayout(0, 0)); add(lowerContentsPanel, BorderLayout.CENTER); // Create remaining construction materials label panel. WebPanel remainingMaterialsLabelPane = new WebPanel(new FlowLayout(FlowLayout.LEFT)); lowerContentsPanel.add(remainingMaterialsLabelPane, BorderLayout.NORTH); // Create remaining construction materials label. String remainingMaterialsLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.remainingMaterialsLabel"); //$NON-NLS-1$ WebLabel remainingMaterialsLabel = new WebLabel(remainingMaterialsLabelString); remainingMaterialsLabelPane.add(remainingMaterialsLabel); // Create a scroll pane for the remaining construction materials table. WebScrollPane remainingMaterialsScrollPane = new WebScrollPane(); remainingMaterialsScrollPane.setPreferredSize(new Dimension(-1, -1)); lowerContentsPanel.add(remainingMaterialsScrollPane, BorderLayout.CENTER); // Create the remaining construction materials table and model. remainingMaterialsTableModel = new RemainingMaterialsTableModel(); WebTable remainingMaterialsTable = new WebTable(remainingMaterialsTableModel); remainingMaterialsScrollPane.setViewportView(remainingMaterialsTable); // Add tooltip. setToolTipText(getToolTipString()); }
Example 6
Source File: TradeMissionCustomInfoPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. */ public TradeMissionCustomInfoPanel() { // Use JPanel constructor super(); // Set the layout. setLayout(new GridLayout(3, 1)); // Create the selling goods panel. WebPanel sellingGoodsPane = new WebPanel(new BorderLayout()); add(sellingGoodsPane); // Create the selling goods label. WebLabel sellingGoodsLabel = new WebLabel("Goods to Sell:", WebLabel.LEFT); sellingGoodsPane.add(sellingGoodsLabel, BorderLayout.NORTH); // Create a scroll pane for the selling goods table. WebScrollPane sellingGoodsScrollPane = new WebScrollPane(); sellingGoodsScrollPane.setPreferredSize(new Dimension(-1, -1)); sellingGoodsPane.add(sellingGoodsScrollPane, BorderLayout.CENTER); // Create the selling goods table and model. sellingGoodsTableModel = new SellingGoodsTableModel(); WebTable sellingGoodsTable = new WebTable(sellingGoodsTableModel); sellingGoodsScrollPane.setViewportView(sellingGoodsTable); // Create the desired goods panel. WebPanel desiredGoodsPane = new WebPanel(new BorderLayout()); add(desiredGoodsPane); // Create the desired goods label panel. WebPanel desiredGoodsLabelPane = new WebPanel(new GridLayout(1, 2, 0, 0)); desiredGoodsPane.add(desiredGoodsLabelPane, BorderLayout.NORTH); // Create the desired goods label. WebLabel desiredGoodsLabel = new WebLabel("Desired Goods to Buy:", WebLabel.LEFT); desiredGoodsLabelPane.add(desiredGoodsLabel); // Create the desired goods profit label. desiredGoodsProfitLabel = new WebLabel("Profit:", WebLabel.LEFT); desiredGoodsLabelPane.add(desiredGoodsProfitLabel); // Create a scroll pane for the desired goods table. WebScrollPane desiredGoodsScrollPane = new WebScrollPane(); desiredGoodsScrollPane.setPreferredSize(new Dimension(-1, -1)); desiredGoodsPane.add(desiredGoodsScrollPane, BorderLayout.CENTER); // Create the desired goods table and model. desiredGoodsTableModel = new DesiredGoodsTableModel(); WebTable desiredGoodsTable = new WebTable(desiredGoodsTableModel); desiredGoodsScrollPane.setViewportView(desiredGoodsTable); // Create the bought goods panel. WebPanel boughtGoodsPane = new WebPanel(new BorderLayout()); add(boughtGoodsPane); // Create the bought goods label panel. WebPanel boughtGoodsLabelPane = new WebPanel(new GridLayout(1, 2, 0, 0)); boughtGoodsPane.add(boughtGoodsLabelPane, BorderLayout.NORTH); // Create the bought goods label. WebLabel boughtGoodsLabel = new WebLabel("Goods Bought:", WebLabel.LEFT); boughtGoodsLabelPane.add(boughtGoodsLabel); // Create the bought goods profit label. boughtGoodsProfitLabel = new WebLabel("Profit:", WebLabel.LEFT); boughtGoodsLabelPane.add(boughtGoodsProfitLabel); // Create a scroll pane for the bought goods table. WebScrollPane boughtGoodsScrollPane = new WebScrollPane(); boughtGoodsScrollPane.setPreferredSize(new Dimension(-1, -1)); boughtGoodsPane.add(boughtGoodsScrollPane, BorderLayout.CENTER); // Create the bought goods table and model. boughtGoodsTableModel = new BoughtGoodsTableModel(); WebTable boughtGoodsTable = new WebTable(boughtGoodsTableModel); boughtGoodsScrollPane.setViewportView(boughtGoodsTable); }
Example 7
Source File: MiningMissionCustomInfoPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor * * @param desktop the main desktop. */ MiningMissionCustomInfoPanel(MainDesktopPane desktop) { // Use JPanel constructor super(); // Set the layout. setLayout(new BorderLayout()); // Initialize data members. this.desktop = desktop; // Create LUV panel. WebPanel luvPane = new WebPanel(new FlowLayout(FlowLayout.LEFT)); add(luvPane, BorderLayout.NORTH); // Create LUV label. WebLabel luvLabel = new WebLabel("Light Utility Vehicle: "); luvPane.add(luvLabel); // Create LUV button. luvButton = new WebButton(" "); luvButton.setVisible(false); luvButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open window for light utility vehicle. LightUtilityVehicle luv = mission.getLightUtilityVehicle(); if (luv != null) getDesktop().openUnitWindow(luv, false); } }); luvPane.add(luvButton); // Create center panel. WebPanel centerPane = new WebPanel(new GridLayout(2, 1)); add(centerPane, BorderLayout.CENTER); // Create concentration panel. WebPanel concentrationPane = new WebPanel(new BorderLayout()); centerPane.add(concentrationPane); // Create concentration label. WebButton concentrationLabel = new WebButton("Mineral Concentrations at Site:"); concentrationPane.add(concentrationLabel, BorderLayout.NORTH); // Create concentration scroll panel. WebScrollPane concentrationScrollPane = new WebScrollPane(); concentrationScrollPane.setPreferredSize(new Dimension(-1, -1)); concentrationPane.add(concentrationScrollPane, BorderLayout.CENTER); // Create concentration table. concentrationTableModel = new ConcentrationTableModel(); WebTable concentrationTable = new WebTable(concentrationTableModel); concentrationTable.setDefaultRenderer(Double.class, new NumberCellRenderer(1)); concentrationScrollPane.setViewportView(concentrationTable); // Create excavation panel. WebPanel excavationPane = new WebPanel(new BorderLayout()); centerPane.add(excavationPane); // Create excavation label. WebLabel excavationLabel = new WebLabel("Minerals Excavated at Site:"); excavationPane.add(excavationLabel, BorderLayout.NORTH); // Create excavation scroll panel. WebScrollPane excavationScrollPane = new WebScrollPane(); excavationScrollPane.setPreferredSize(new Dimension(-1, -1)); excavationPane.add(excavationScrollPane, BorderLayout.CENTER); // Create excavation tabel. excavationTableModel = new ExcavationTableModel(); WebTable excavationTable = new WebTable(excavationTableModel); excavationTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2)); excavationScrollPane.setViewportView(excavationTable); }
Example 8
Source File: TabPanelAttribute.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Create attribute label panel. WebPanel attributeLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(attributeLabelPanel); // Create attribute label WebLabel attributeLabel = new WebLabel(Msg.getString("TabPanelAttribute.label"), WebLabel.CENTER); //$NON-NLS-1$ attributeLabel.setFont(new Font("Serif", Font.BOLD, 16)); attributeLabelPanel.add(attributeLabel); // Create attribute scroll panel WebScrollPane attributeScrollPanel = new WebScrollPane(); // attributeScrollPanel.setBorder(new MarsPanelBorder()); centerContentPanel.add(attributeScrollPanel); // Create attribute table model if (person != null) attributeTableModel = new AttributeTableModel(person); else attributeTableModel = new AttributeTableModel(robot); // Create attribute table attributeTable = new ZebraJTable(attributeTableModel); //new JTable(attributeTableModel);// attributeTable.setPreferredScrollableViewportSize(new Dimension(225, 100)); attributeTable.getColumnModel().getColumn(0).setPreferredWidth(100); attributeTable.getColumnModel().getColumn(1).setPreferredWidth(70); attributeTable.setRowSelectionAllowed(true); // attributeTable.setDefaultRenderer(Integer.class, new NumberCellRenderer()); attributeScrollPanel.setViewportView(attributeTable); attributeTable.setAutoCreateRowSorter(true); // Align the content to the center of the cell // Note: DefaultTableCellRenderer does NOT work well with nimrod DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.LEFT); attributeTable.getColumnModel().getColumn(0).setCellRenderer(renderer); attributeTable.getColumnModel().getColumn(1).setCellRenderer(renderer); TableStyle.setTableStyle(attributeTable); update(); //attributeTableModel.update(); }
Example 9
Source File: TabPanelSkill.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Create skill table model if (unit instanceof Person) { skillTableModel = new SkillTableModel(person); } else if (unit instanceof Robot) { skillTableModel = new SkillTableModel(robot); } // Create skill label panel. WebPanel skillLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(skillLabelPanel); // Create skill label WebLabel skillLabel = new WebLabel(Msg.getString("TabPanelSkill.label"), WebLabel.CENTER); //$NON-NLS-1$ skillLabel.setFont(new Font("Serif", Font.BOLD, 16)); skillLabelPanel.add(skillLabel); // Create skill scroll panel WebScrollPane skillScrollPanel = new WebScrollPane(); // skillScrollPanel.setBorder(new MarsPanelBorder()); centerContentPanel.add(skillScrollPanel); // Create skill table skillTable = new ZebraJTable(skillTableModel); skillTable.setPreferredScrollableViewportSize(new Dimension(250, 100)); skillTable.getColumnModel().getColumn(0).setPreferredWidth(150); skillTable.getColumnModel().getColumn(1).setPreferredWidth(50); skillTable.getColumnModel().getColumn(2).setPreferredWidth(60); skillTable.getColumnModel().getColumn(3).setPreferredWidth(100); skillTable.setRowSelectionAllowed(true); skillTable.setDefaultRenderer(Integer.class, new NumberCellRenderer()); // Align the content to the center of the cell DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.RIGHT); skillTable.getColumnModel().getColumn(0).setCellRenderer(renderer); skillTable.getColumnModel().getColumn(1).setCellRenderer(renderer); skillTable.getColumnModel().getColumn(2).setCellRenderer(renderer); skillTable.getColumnModel().getColumn(3).setCellRenderer(renderer); skillScrollPanel.setViewportView(skillTable); // Added sorting skillTable.setAutoCreateRowSorter(true); TableStyle.setTableStyle(skillTable); }
Example 10
Source File: TabPanelSocial.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Create relationship label panel. WebPanel relationshipLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(relationshipLabelPanel); // Create relationship label WebLabel relationshipLabel = new WebLabel(Msg.getString("TabPanelSocial.label"), WebLabel.CENTER); //$NON-NLS-1$ relationshipLabel.setFont(new Font("Serif", Font.BOLD, 16)); relationshipLabelPanel.add(relationshipLabel); // Create relationship scroll panel WebScrollPane relationshipScrollPanel = new WebScrollPane(); // relationshipScrollPanel.setBorder(new MarsPanelBorder()); centerContentPanel.add(relationshipScrollPanel); // Create relationship table model relationshipTableModel = new RelationshipTableModel(person); // Create relationship table relationshipTable = new ZebraJTable(relationshipTableModel); relationshipTable.setPreferredScrollableViewportSize(new Dimension(225, 100)); relationshipTable.getColumnModel().getColumn(0).setPreferredWidth(80); relationshipTable.getColumnModel().getColumn(1).setPreferredWidth(80); relationshipTable.getColumnModel().getColumn(2).setPreferredWidth(40); relationshipTable.setRowSelectionAllowed(true); // For single clicking on a person to pop up his person window. //relationshipTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //relationshipTable.getSelectionModel().addListSelectionListener(this); // Add a mouse listener to hear for double-clicking a person (rather than single click using valueChanged() relationshipTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { JTable table =(JTable) me.getSource(); Point p = me.getPoint(); int row = table.rowAtPoint(p); int col = table.columnAtPoint(p); if (me.getClickCount() == 2) { if (row > 0 && col > 0) { Person selectedPerson = (Person) relationshipTable.getValueAt(row, 1); if (selectedPerson != null) desktop.openUnitWindow(selectedPerson, false); } } } }); relationshipScrollPanel.setViewportView(relationshipTable); // Align the content to the center of the cell DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.RIGHT); relationshipTable.getColumnModel().getColumn(0).setCellRenderer(renderer); relationshipTable.getColumnModel().getColumn(1).setCellRenderer(renderer); relationshipTable.getColumnModel().getColumn(2).setCellRenderer(renderer); // Added sorting relationshipTable.setAutoCreateRowSorter(true); // in conflict with valueChanged(), throw exception if clicking on a person TableStyle.setTableStyle(relationshipTable); }
Example 11
Source File: TabPanelCredit.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Prepare credit label panel. WebPanel creditLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(creditLabelPanel); // Prepare credit label. WebLabel creditLabel = new WebLabel(Msg.getString("TabPanelCredit.label"), WebLabel.CENTER); //$NON-NLS-1$ creditLabel.setFont(new Font("Serif", Font.BOLD, 16)); //creditLabel.setForeground(new Color(102, 51, 0)); // dark brown creditLabelPanel.add(creditLabel); // Create scroll panel for the outer table panel. WebScrollPane creditScrollPanel = new WebScrollPane(); creditScrollPanel.setPreferredSize(new Dimension(280, 280)); centerContentPanel.add(creditScrollPanel); // Prepare credit table model. CreditTableModel creditTableModel = new CreditTableModel((Settlement) unit); // Prepare credit table. creditTable = new ZebraJTable(creditTableModel); creditScrollPanel.setViewportView(creditTable); creditTable.setRowSelectionAllowed(true); creditTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2, true)); creditTable.getColumnModel().getColumn(0).setPreferredWidth(100); creditTable.getColumnModel().getColumn(1).setPreferredWidth(120); creditTable.getColumnModel().getColumn(2).setPreferredWidth(50); // Added the two methods below to make all heatTable columns // Resizable automatically when its Panel resizes creditTable.setPreferredScrollableViewportSize(new Dimension(225, -1)); //creditTable.setAutoResizeMode(WebTable.AUTO_RESIZE_ALL_COLUMNS); // Added sorting creditTable.setAutoCreateRowSorter(true); // Align the preference score to the center of the cell DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.RIGHT); creditTable.getColumnModel().getColumn(0).setCellRenderer(renderer); // creditTable.getColumnModel().getColumn(1).setCellRenderer(renderer); creditTable.getColumnModel().getColumn(2).setCellRenderer(renderer); TableStyle.setTableStyle(creditTable); }
Example 12
Source File: TabPanelBots.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Prepare title label. WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelBots.title"), WebLabel.CENTER); //$NON-NLS-1$ titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); titlePanel.add(titleLabel); topContentPanel.add(titlePanel); // Create crew count panel WebPanel crewCountPanel = new WebPanel(new GridLayout(2, 1, 0, 0)); // crewCountPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(crewCountPanel); // Create crew num label crewNumCache = crewable.getRobotCrewNum(); crewNumLabel = new WebLabel(Msg.getString("TabPanelBots.crew", crewNumCache), WebLabel.CENTER); //$NON-NLS-1$ crewCountPanel.add(crewNumLabel); // Create crew capacity label crewCapacityCache = crewable.getRobotCrewCapacity(); crewCapLabel = new WebLabel(Msg.getString("TabPanelBots.crewCapacity", crewCapacityCache), WebLabel.CENTER); //$NON-NLS-1$ crewCountPanel.add(crewCapLabel); // Create crew display panel WebPanel crewDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT)); // crewDisplayPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(crewDisplayPanel); // Create scroll panel for crew list. WebScrollPane crewScrollPanel = new WebScrollPane(); crewScrollPanel.setPreferredSize(new Dimension(175, 100)); crewDisplayPanel.add(crewScrollPanel); // Create crew list model crewListModel = new DefaultListModel<Robot>(); //crewListModel = new DefaultListModel<Unit>(); crewCache = crewable.getRobotCrew(); //crewCache = crewable.getUnitCrew(); Iterator<Robot> i = crewCache.iterator(); //Iterator<Unit> i = crewCache.iterator(); while (i.hasNext()) crewListModel.addElement(i.next()); // Create crew list crewList = new JList<Robot>(crewListModel); //crewList = new JList<Unit>(crewListModel); crewList.addMouseListener(this); crewScrollPanel.setViewportView(crewList); // Create crew monitor button WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$ monitorButton.setMargin(new Insets(1, 1, 1, 1)); monitorButton.addActionListener(this); monitorButton.setToolTipText(Msg.getString("TabPanelBots.tooltip.monitor")); //$NON-NLS-1$ crewDisplayPanel.add(monitorButton); }
Example 13
Source File: BuildingPanelMedicalCare.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * @param medical the medical care building this panel is for. * @param desktop The main desktop. */ public BuildingPanelMedicalCare(MedicalCare medical, MainDesktopPane desktop) { // Use BuildingFunctionPanel constructor super(medical.getBuilding(), desktop); // Initialize data members this.medical = medical; // Set panel layout setLayout(new BorderLayout()); // Create label panel WebPanel labelPanel = new WebPanel(new GridLayout(3, 1, 0, 0)); add(labelPanel, BorderLayout.NORTH); labelPanel.setOpaque(false); labelPanel.setBackground(new Color(0,0,0,128)); // Create medical care label // 2014-11-21 Changed font type, size and color and label text // 2014-11-21 Added internationalization for labels WebLabel medicalCareLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.title"), WebLabel.CENTER); medicalCareLabel.setFont(new Font("Serif", Font.BOLD, 16)); //medicalCareLabel.setForeground(new Color(102, 51, 0)); // dark brown labelPanel.add(medicalCareLabel); // Create sick bed label WebLabel sickBedLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.numberOfsickBeds", medical.getSickBedNum()), WebLabel.CENTER); labelPanel.add(sickBedLabel); // Create physician label physicianCache = medical.getPhysicianNum(); physicianLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.numberOfPhysicians", physicianCache), WebLabel.CENTER); labelPanel.add(physicianLabel); // Create scroll panel for medical table WebScrollPane scrollPanel = new WebScrollPane(); scrollPanel.setPreferredSize(new Dimension(160, 80)); add(scrollPanel, BorderLayout.CENTER); scrollPanel.getViewport().setOpaque(false); scrollPanel.getViewport().setBackground(new Color(0, 0, 0, 0)); scrollPanel.setOpaque(false); scrollPanel.setBackground(new Color(0, 0, 0, 0)); //scrollPanel.setBorder( BorderFactory.createLineBorder(Color.orange) ); // Prepare medical table model medicalTableModel = new MedicalTableModel(medical); // Prepare medical table JTable medicalTable = new ZebraJTable(medicalTableModel); medicalTable.setCellSelectionEnabled(false); scrollPanel.setViewportView(medicalTable); }
Example 14
Source File: BuildingPanelVehicleMaintenance.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * @param garage the vehicle maintenance function * @param desktop the main desktop */ public BuildingPanelVehicleMaintenance(VehicleMaintenance garage, MainDesktopPane desktop) { // Use BuildingFunctionPanel constructor super(garage.getBuilding(), desktop); // Initialize data members this.garage = garage; // Set panel layout setLayout(new BorderLayout()); // Create label panel WebPanel labelPanel = new WebPanel(new GridLayout(3, 1, 0, 0)); add(labelPanel, BorderLayout.NORTH); labelPanel.setOpaque(false); labelPanel.setBackground(new Color(0,0,0,128)); // Create vehicle maintenance label // 2014-11-21 Changed font type, size and color and label text // 2014-11-21 Added internationalization for labels WebLabel vehicleMaintenanceLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.title"), WebLabel.CENTER); vehicleMaintenanceLabel.setFont(new Font("Serif", Font.BOLD, 16)); //vehicleMaintenanceLabel.setForeground(new Color(102, 51, 0)); // dark brown labelPanel.add(vehicleMaintenanceLabel); // Create vehicle number label vehicleNumberCache = garage.getCurrentVehicleNumber(); vehicleNumberLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.numberOfVehicles", vehicleNumberCache), WebLabel.CENTER); labelPanel.add(vehicleNumberLabel); // Create vehicle capacity label int vehicleCapacity = garage.getVehicleCapacity(); WebLabel vehicleCapacityLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.vehicleCapacity", vehicleCapacity), WebLabel.CENTER); labelPanel.add(vehicleCapacityLabel); // Create vehicle list panel WebPanel vehicleListPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); add(vehicleListPanel, BorderLayout.CENTER); vehicleListPanel.setOpaque(false); vehicleListPanel.setBackground(new Color(0,0,0,128)); // Create scroll panel for vehicle list WebScrollPane vehicleScrollPanel = new WebScrollPane(); vehicleScrollPanel.setPreferredSize(new Dimension(160, 60)); vehicleListPanel.add(vehicleScrollPanel); vehicleScrollPanel.setOpaque(false); vehicleScrollPanel.setBackground(new Color(0,0,0,128)); vehicleScrollPanel.getViewport().setOpaque(false); vehicleScrollPanel.getViewport().setBackground(new Color(0,0,0,128)); // Create vehicle list model vehicleListModel = new DefaultListModel<Vehicle>(); vehicleCache = new ArrayList<Vehicle>(garage.getVehicles()); Iterator<Vehicle> i = vehicleCache.iterator(); while (i.hasNext()) vehicleListModel.addElement(i.next()); // Create vehicle list vehicleList = new JList<Vehicle>(vehicleListModel); vehicleList.addMouseListener(this); vehicleScrollPanel.setViewportView(vehicleList); }
Example 15
Source File: BuildingPanelMalfunctionable.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * * @param malfunctionable the malfunctionable building the panel is for. * @param desktop The main desktop. */ public BuildingPanelMalfunctionable(Malfunctionable malfunctionable, MainDesktopPane desktop) { // Use BuildingFunctionPanel constructor super((Building) malfunctionable, desktop); // Initialize data members. this.malfunctionable = malfunctionable; // Set panel layout setLayout(new BorderLayout()); // Create malfunctions label WebLabel malfunctionsLabel = new WebLabel(Msg.getString("BuildingPanelMalfunctionable.title"), WebLabel.CENTER); malfunctionsLabel.setFont(new Font("Serif", Font.BOLD, 16)); // malfunctionsLabel.setForeground(new Color(102, 51, 0)); // dark brown add(malfunctionsLabel, BorderLayout.NORTH); // Create scroll panel for malfunction list WebScrollPane scrollPanel = new WebScrollPane(); scrollPanel.setPreferredSize(new Dimension(170, 90)); add(scrollPanel, BorderLayout.CENTER); scrollPanel.setOpaque(false); scrollPanel.setBackground(new Color(0, 0, 0, 128)); scrollPanel.getViewport().setOpaque(false); scrollPanel.getViewport().setBackground(new Color(0, 0, 0, 128));// 0, 0, 0, 0)); // scrollPanel.setBorder( BorderFactory.createLineBorder(Color.LIGHT_GRAY) ); // Create malfunction list main panel. WebPanel malfunctionListMainPanel = new WebPanel(new BorderLayout(0, 0)); scrollPanel.setViewportView(malfunctionListMainPanel); // Create malfunction list panel malfunctionListPanel = new WebPanel(); malfunctionListPanel.setLayout(new BoxLayout(malfunctionListPanel, BoxLayout.Y_AXIS)); malfunctionListMainPanel.add(malfunctionListPanel, BorderLayout.NORTH); // Create malfunction panels malfunctionCache = new ArrayList<Malfunction>(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); } }
Example 16
Source File: TabPanelBots.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(titlePane); WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelBots.title"), WebLabel.CENTER); //$NON-NLS-1$ titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); // titleLabel.setForeground(new Color(102, 51, 0)); // dark brown titlePane.add(titleLabel); // Create robot count panel WebPanel countPanel = new WebPanel(new GridLayout(3, 1, 0, 0)); // countPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(countPanel); // Create robot num label robotNumCache = settlement.getNumBots(); robotNumLabel = new WebLabel(Msg.getString("TabPanelBots.associated", robotNumCache), WebLabel.CENTER); // $NON-NLS-1$ countPanel.add(robotNumLabel); // Create robot indoor label robotIndoorCache = settlement.getNumBots(); robotIndoorLabel = new WebLabel(Msg.getString("TabPanelBots.indoor", robotIndoorCache), WebLabel.CENTER); // $NON-NLS-1$ countPanel.add(robotIndoorLabel); // Create robot capacity label robotCapacityCache = settlement.getRobotCapacity(); robotCapLabel = new WebLabel(Msg.getString("TabPanelBots.capacity", robotCapacityCache), WebLabel.CENTER); // $NON-NLS-1$ countPanel.add(robotCapLabel); // Create spring layout robot display panel WebPanel robotDisplayPanel = new WebPanel(new SpringLayout());// FlowLayout(FlowLayout.LEFT)); // robotDisplayPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(robotDisplayPanel); // Create scroll panel for robot list. robotScrollPanel = new WebScrollPane(); robotScrollPanel.setPreferredSize(new Dimension(120, 250)); robotDisplayPanel.add(robotScrollPanel); // Create robot list model robotListModel = new RobotListModel(settlement); // Create robot list robotList = new JList<Robot>(robotListModel); robotList.addMouseListener(this); robotScrollPanel.setViewportView(robotList); // Create robot monitor button WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$ monitorButton.setMargin(new Insets(1, 1, 1, 1)); monitorButton.addActionListener(this); monitorButton.setToolTipText(Msg.getString("TabPanelBots.tooltip.monitor")); //$NON-NLS-1$ WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.CENTER)); // buttonPane.setPreferredSize(new Dimension(25, 25)); buttonPane.add(monitorButton); robotDisplayPanel.add(buttonPane); // Lay out the spring panel. SpringUtilities.makeCompactGrid(robotDisplayPanel, 2, 1, // rows, cols 30, 10, // initX, initY 10, 10); // xPad, yPad }
Example 17
Source File: TabPanelMaintenance.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Create topPanel. WebPanel topPanel = new WebPanel(new GridLayout(2, 1)); centerContentPanel.add(topPanel); // Create maintenance panel. WebPanel maintenancePanel = new WebPanel(new BorderLayout()); topPanel.add(maintenancePanel); // Create maintenance label. WebLabel titleLabel = new WebLabel("Building Maintenance", WebLabel.CENTER); titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); // titleLabel.setForeground(new Color(102, 51, 0)); // dark brown maintenancePanel.add(titleLabel, BorderLayout.NORTH); // Create scroll pane for maintenance list panel. maintenanceScrollPane = new WebScrollPane(); // increase vertical mousewheel scrolling speed for this one maintenanceScrollPane.getVerticalScrollBar().setUnitIncrement(16); maintenanceScrollPane.setPreferredSize(new Dimension(200, 75)); maintenancePanel.add(maintenanceScrollPane, BorderLayout.CENTER); // Prepare maintenance list panel. maintenanceListPanel = new WebPanel(new GridLayout(0, 1, 0, 0)); // maintenanceListPanel.setBorder(new MarsPanelBorder()); maintenanceScrollPane.setViewportView(maintenanceListPanel); populateMaintenanceList(); // Create malfunctions panel. WebPanel malfunctionsPanel = new WebPanel(new BorderLayout()); topPanel.add(malfunctionsPanel); // Create malfunctions label. WebLabel malfunctionsLabel = new WebLabel("Building Malfunctions", WebLabel.CENTER); malfunctionsLabel.setFont(new Font("Serif", Font.BOLD, 16)); // malfunctionsLabel.setForeground(new Color(102, 51, 0)); // dark brown malfunctionsPanel.add(malfunctionsLabel, BorderLayout.NORTH); // Create scroll panel for malfunctions list panel. malfunctionsScrollPane = new WebScrollPane(); // increase vertical mousewheel scrolling speed for this one malfunctionsScrollPane.getVerticalScrollBar().setUnitIncrement(16); malfunctionsScrollPane.setPreferredSize(new Dimension(200, 75)); malfunctionsPanel.add(malfunctionsScrollPane, BorderLayout.CENTER); // Prepare malfunctions outer list panel. WebPanel malfunctionsOuterListPanel = new WebPanel(new BorderLayout(0, 0)); // malfunctionsOuterListPanel.setBorder(new MarsPanelBorder()); malfunctionsScrollPane.setViewportView(malfunctionsOuterListPanel); // Prepare malfunctions list panel. malfunctionsListPanel = new WebPanel(); malfunctionsListPanel.setLayout(new BoxLayout(malfunctionsListPanel, BoxLayout.Y_AXIS)); malfunctionsOuterListPanel.add(malfunctionsListPanel, BorderLayout.NORTH); populateMalfunctionsList(); }
Example 18
Source File: TabPanelGoods.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; // Prepare goods label panel. WebPanel goodsLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(goodsLabelPanel); // Prepare goods label. WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelGoods.label"), WebLabel.CENTER); //$NON-NLS-1$ titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); //titleLabel.setForeground(new Color(102, 51, 0)); // dark brown goodsLabelPanel.add(titleLabel); // Create scroll panel for the outer table panel. WebScrollPane goodsScrollPane = new WebScrollPane(); goodsScrollPane.setPreferredSize(new Dimension(250, 300)); // increase vertical mousewheel scrolling speed for this one goodsScrollPane.getVerticalScrollBar().setUnitIncrement(16); centerContentPanel.add(goodsScrollPane); // Prepare goods table model. goodsTableModel = new GoodsTableModel(((Settlement) unit).getGoodsManager()); // Prepare goods table. goodsTable = new ZebraJTable(goodsTableModel); goodsScrollPane.setViewportView(goodsTable); goodsTable.setRowSelectionAllowed(true); // Override default cell renderer for formatting double values. goodsTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2, true)); goodsTable.getColumnModel().getColumn(0).setPreferredWidth(140); goodsTable.getColumnModel().getColumn(1).setPreferredWidth(80); // Added the two methods below to make all heatTable columns // Resizable automatically when its Panel resizes goodsTable.setPreferredScrollableViewportSize(new Dimension(225, -1)); //goodsTable.setAutoResizeMode(WebTable.AUTO_RESIZE_ALL_COLUMNS); // Align the preference score to the center of the cell DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.RIGHT); goodsTable.getColumnModel().getColumn(0).setCellRenderer(renderer); // goodsTable.getColumnModel().getColumn(1).setCellRenderer(renderer); // Added sorting goodsTable.setAutoCreateRowSorter(true); TableStyle.setTableStyle(goodsTable); // Added goodsSearchable TableSearchable searchable = SearchableUtils.installSearchable(goodsTable); searchable.setPopupTimeout(5000); searchable.setCaseSensitive(false); searchable.setMainIndex(0); // -1 = search for all columns }
Example 19
Source File: TabPanelAssociatedPeople.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER)); topContentPanel.add(titlePane); // Create associated people label WebLabel heading = new WebLabel(Msg.getString("TabPanelAssociatedPeople.title"), WebLabel.CENTER); //$NON-NLS-1$ heading.setFont(new Font("Serif", Font.BOLD, 16)); // heading.setForeground(new Color(102, 51, 0)); // dark brown titlePane.add(heading); // Prepare count spring layout panel. WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0)); // countPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(countPanel); // Create associate label WebLabel populationNumHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.associated"), WebLabel.RIGHT); // $NON-NLS-1$ countPanel.add(populationNumHeader); populationCitizensCache = settlement.getNumCitizens(); populationCitizensLabel = new WebLabel(populationCitizensCache + "", WebLabel.LEFT); countPanel.add(populationCitizensLabel); // Create population indoor label WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.indoor"), WebLabel.RIGHT); // $NON-NLS-1$ countPanel.add(populationIndoorHeader); populationIndoorCache = settlement.getIndoorPeopleCount(); populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT); countPanel.add(populationIndoorLabel); // Create population capacity label WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.capacity"), WebLabel.RIGHT); // $NON-NLS-1$ countPanel.add(populationCapacityHeader); populationCapacityCache = settlement.getPopulationCapacity(); populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT); countPanel.add(populationCapacityLabel); // Lay out the spring panel. SpringUtilities.makeCompactGrid(countPanel, 3, 2, // rows, cols 25, 10, // initX, initY 10, 10); // xPad, yPad UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray); Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelAssociatedPeople.title") + " "); // title.setTitleJustification(TitledBorder.RIGHT); Font titleFont = UIManager.getFont("TitledBorder.font"); title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD)); // Create spring layout population display panel WebPanel populationDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER)); populationDisplayPanel.setBorder(title); // populationDisplayPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(populationDisplayPanel); // Create scroll panel for population list. populationScrollPanel = new WebScrollPane(); populationScrollPanel.setPreferredSize(new Dimension(200, 250)); populationDisplayPanel.add(populationScrollPanel); // Create population list model populationListModel = new AssociatedPopulationListModel(settlement); // Create population list populationList = new JList<Person>(populationListModel); populationList.addMouseListener(this); populationScrollPanel.setViewportView(populationList); // Create population monitor button JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$ monitorButton.setMargin(new Insets(1, 1, 1, 1)); monitorButton.addActionListener(this); monitorButton.setToolTipText(Msg.getString("TabPanelAssociatedPeople.tooltip.monitor")); //$NON-NLS-1$ populationDisplayPanel.add(monitorButton); // WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.RIGHT)); //// buttonPane.setPreferredSize(new Dimension(25, 25)); // buttonPane.add(monitorButton); // // populationDisplayPanel.add(buttonPane); }