public void stateChanged(ChangeEvent e) { JSpinner source = (JSpinner) e.getSource(); if (source.getName().equals("Hour")) { calendar.set(Calendar.HOUR_OF_DAY, getSelectedHour()); return; } if (source.getName().equals("Year")) { calendar.set(Calendar.YEAR, getSelectedYear()); dayPanel.removeAll(); this.flushWeekAndDayPanal(calendar); dayPanel.revalidate(); dayPanel.updateUI(); return; } if (source.getName().equals("Month")) { calendar.set(Calendar.MONTH, getSelectedMonth() - 1); dayPanel.removeAll(); this.flushWeekAndDayPanal(calendar); dayPanel.revalidate(); dayPanel.updateUI(); return; } }
/** Presune obraz figury z pozice inx0 na pozici inx1. */ public void moveFig(int inx0, int inx1) { JPanel panel0, panel1; panel0 = (JPanel) figurePan.getComponent(inx0); panel1 = (JPanel) figurePan.getComponent(inx1); Component c = panel0.getComponent(0); panel0.removeAll(); panel1.removeAll(); panel1.add(c); panel0.revalidate(); panel1.revalidate(); }
public void actionPerformed(ActionEvent e) { if (e.getSource() == easy) { invSpeed = 50000; bombN = 1; timeDifficulty1 = 1000; distanceLimit = 400; monsterMultiplier = 1; multiplier = 1; setup(); } else if (e.getSource() == hard) { invSpeed = 30000; bombN = 4; timeDifficulty1 = 500; distanceLimit = 200; monsterMultiplier = 2; multiplier = 2; setup(); } else if (e.getSource() == back) { r = null; menu.setVisible(true); back.setVisible(false); this.revalidate(); repaint(); } else if (e.getSource() == howTo) { menu.removeAll(); menu.add(howToBack); menu.add(howToIMGL); menu.revalidate(); menu.repaint(); } else if (e.getSource() == howToBack) { menu.remove(howToIMGL); menu.remove(howToBack); menu.add(keyboardSpeedL1); menu.add(keyboardSpeedL2); menu.add(easy); menu.add(hard); menu.add(howTo); menu.add(onePlayerRB); menu.add(twoPlayerRB); menu.add(mouseRB); menu.add(keyboardRB); menu.add(keyboardSpeedS1); menu.add(keyboardSpeedS2); menu.add(musicCB); menu.add(highscoreL); menu.add(menuIMGL); menu.revalidate(); menu.repaint(); } }
// Implementation of valueChanged public void valueChanged(ListSelectionEvent e) { if (e.getSource() == table.getSelectionModel()) { ListSelectionModel ls = table.getSelectionModel(); int index = ls.getMinSelectionIndex(); long id = (long) table.getValueAt(index, 0); updateFeesData(id); } else { ListSelectionModel ls = feestable.getSelectionModel(); int index = ls.getMinSelectionIndex(); float feespayed = (float) feestable.getValueAt(index, 1); float totalfees = (float) feestable.getValueAt(index, 2); feespayedlabel.setText("Fees Payed: " + feespayed); totalfeeslabel.setText("Total Fees: " + totalfees); if (totalfees - feespayed > 0) { feesduelabel.setText("Fees Due: " + (totalfees - feespayed)); } panel_6.revalidate(); } }
private void updateUIWithFindModel() { boolean needToResetSearchFocus = mySearchTextComponent.hasFocus(); boolean needToResetReplaceFocus = myReplaceTextComponent.hasFocus(); updateSearchComponent(); updateReplaceComponent(); if (myFindModel.isReplaceState()) { if (myReplaceFieldWrapper.getParent() == null) { myLeftPanel.add(myReplaceFieldWrapper, BorderLayout.CENTER); } if (myReplaceToolbarWrapper.getParent() == null) { myRightPanel.add(myReplaceToolbarWrapper, BorderLayout.CENTER); } if (needToResetReplaceFocus) { myReplaceTextComponent.requestFocusInWindow(); } } else { if (myReplaceFieldWrapper.getParent() != null) { myLeftPanel.remove(myReplaceFieldWrapper); } if (myReplaceToolbarWrapper.getParent() != null) { myRightPanel.remove(myReplaceToolbarWrapper); } } if (needToResetSearchFocus) mySearchTextComponent.requestFocusInWindow(); mySearchActionsToolbar1.updateActionsImmediately(); mySearchActionsToolbar2.updateActionsImmediately(); myReplaceActionsToolbar1.updateActionsImmediately(); myReplaceActionsToolbar2.updateActionsImmediately(); myReplaceToolbarWrapper.revalidate(); revalidate(); repaint(); myLivePreviewController.setTrackingSelection(!myFindModel.isGlobal()); }
private void resetRemainderProblems() { problemDisplays = new RemainderProblemDisplay[round.getNumProblems()]; JPanel panel = new JPanel(); panel.setMinimumSize(new Dimension(2, 2)); panel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); for (int i = round.getNumProblems() / 4 + (round.getNumProblems() % 4 == 0 ? 0 : 1); i >= 0; i--) { panel.setSize(new Dimension(370, panel.getSize().height + 60)); } panel.setLayout(new Layout(0, 4)); for (int i = 0; i < round.getNumProblems(); i++) { RemainderProblemDisplay problem = new RemainderProblemDisplay( round.getProblem(i), round.getGenerator().getParam().charAt(0)); problemDisplays[i] = problem; panel.add(problem); } panel.revalidate(); problems.setPreferredSize(new Dimension(388, 360)); problems.setViewportView(panel); problems.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); problems.revalidate(); }
private void resetSemImEditor() { java.util.List<SemEstimator> semEstimators = wrapper.getMultipleResultList(); if (semEstimators.size() == 1) { SemEstimator estimatedSem = semEstimators.get(0); SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem())); panel.removeAll(); panel.add(editor, BorderLayout.CENTER); panel.revalidate(); panel.repaint(); } else { JTabbedPane tabs = new JTabbedPane(); for (int i = 0; i < semEstimators.size(); i++) { SemEstimator estimatedSem = semEstimators.get(i); SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem())); JPanel _panel = new JPanel(); _panel.setLayout(new BorderLayout()); _panel.add(editor, BorderLayout.CENTER); tabs.addTab(estimatedSem.getDataSet().getName(), _panel); } panel.removeAll(); panel.add(tabs); panel.validate(); } }
private void buildExternalsPanel() { FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p")); int row = 1; for (ExternalFileEntry efe : externals) { builder.add(efe.getPanel()).xy(1, row); builder.appendRows("2dlu, p"); row += 2; } builder.add(Box.createVerticalGlue()).xy(1, row); builder.appendRows("2dlu, p, 2dlu, p"); builder.add(addExtPan).xy(1, row + 2); builder.add(Box.createVerticalGlue()).xy(1, row + 2); // builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green)); // externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); JScrollPane pane = new JScrollPane(builder.getPanel()); pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); externalFilesPanel.setMinimumSize(new Dimension(400, 400)); externalFilesPanel.setPreferredSize(new Dimension(400, 400)); externalFilesPanel.removeAll(); externalFilesPanel.add(pane, BorderLayout.CENTER); externalFilesPanel.revalidate(); externalFilesPanel.repaint(); }
private void setupPanels(@Nullable ProjectTemplate template) { restorePanel(myNamePathComponent, 4); restorePanel(myModulePanel, myWizardContext.isCreatingNewProject() ? 8 : 6); restorePanel(myExpertPanel, myWizardContext.isCreatingNewProject() ? 1 : 0); mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this); String description = null; if (template != null) { description = template.getDescription(); if (StringUtil.isNotEmpty(description)) { StringBuilder sb = new StringBuilder("<html><body><font "); sb.append(SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"").append('>'); sb.append(description).append("</font></body></html>"); description = sb.toString(); myDescriptionPane.setText(description); } } myExpertPlaceholder.setVisible( !(myModuleBuilder instanceof TemplateModuleBuilder) && myExpertPanel.getComponentCount() > 0); for (int i = 0; i < 6; i++) { myModulePanel.getComponent(i).setVisible(!(myModuleBuilder instanceof EmptyModuleBuilder)); } myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description)); mySettingsPanel.revalidate(); mySettingsPanel.repaint(); }
/** Show/update/hide page number field, according to loading policy and current data length. */ public final void updatePageNumber(int pageNr) { controlPageNr.setValue(new Integer(pageNr)); pageNrPanel.removeAll(); if (pageNr > 0 && showPageNumber) pageNrPanel.add(controlPageNr); pageNrPanel.revalidate(); this.repaint(); }
protected void showErrorPage(final ErrorInfo info) { storeState(); hideProgress(); myRootComponent = null; myErrorMessages.removeAll(); if (info.myShowStack) { info.myMessages.add( 0, new FixableMessageInfo(true, info.myDisplayMessage, "", "", null, null)); ByteArrayOutputStream stream = new ByteArrayOutputStream(); info.myThrowable.printStackTrace(new PrintStream(stream)); myErrorStack.setText(stream.toString()); myErrorStackLayout.show(myErrorStackPanel, ERROR_STACK_CARD); } else { myErrorStack.setText(null); myErrorStackLayout.show(myErrorStackPanel, ERROR_NO_STACK_CARD); } for (FixableMessageInfo message : info.myMessages) { addErrorMessage( message, message.myErrorIcon ? Messages.getErrorIcon() : Messages.getWarningIcon()); } myErrorPanel.revalidate(); myLayout.show(this, ERROR_CARD); DesignerToolWindowManager.getInstance(getProject()).refresh(true); repaint(); }
public static void updateResultsTable(Object[][] data) { // remove old route table resultsPanel.removeAll(); // create new route table String[] columnNames = { "Route #", "Carrier", "Dep. Airport", "Dep. Time", "Arr. Airport", "Arr. Time", "Price" }; JScrollPane routeTable = new JScrollPane( new JTable(data, columnNames) { public boolean isCellEditable(int rowIndex, int vColIndex) { return false; }; }); // create the routes table in a scrollPane routeTable.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); routeTable.setPreferredSize(new Dimension(resultsPanelWidth, resultsPanelHeight)); resultsPanel.add(routeTable); // add the table to the JPanel resultsPanel.setBorder(BorderFactory.createTitledBorder("Search Results")); // display new route table resultsPanel.revalidate(); resultsPanel.repaint(); }
// Fees update method private void updateFeesData(long id) { String columns[] = {"Course", "Fees Payed", "Total fees", "Installments"}; try { Database db = new Database(); panel_7.removeAll(); feestablemodel = new MyTableModel(db.getFeeData(id), columns); feestable = new JTable(feestablemodel); feestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); feestable.getSelectionModel().addListSelectionListener(this); feesscrollpane = new JScrollPane(feestable); panel_7.add(feesscrollpane); // change fees payed label feespayedlabel.setText("Fees Payed"); feesduelabel.setText("Fees Due"); totalfeeslabel.setText("Total Fees"); panel_7.revalidate(); } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } }
private void restoreEmptyStatus() { removeAll(); setLayout(new BorderLayout()); add(myRefreshAndInfoPanel, BorderLayout.CENTER); myProgressIcon.suspend(); myRefreshAndInfoPanel.revalidate(); myRefreshAndInfoPanel.repaint(); }
void updateToolbar() { if (myToolbar != null) { myNorthPanel.remove(myToolbar); } myToolbar = createToolbar(); myNorthPanel.add(myToolbar); updateToolbarVisibility(); myContentPane.revalidate(); }
/** Vlozi obraz figury s obrazkem specifiovanym pic na pozici index. */ public void putFig(int index, int pic) { JPanel panel = (JPanel) figurePan.getComponent(index); if (panel == null || pic < 0 || pic > 3) { return; } panel.removeAll(); panel.add(new JLabel(new ImageIcon(pictures[pic]))); panel.revalidate(); }
private void showStepComponent(final Component component) { String id = myComponentToIdMap.get(component); if (id == null) { id = addStepComponent(component); myContentPanel.revalidate(); myContentPanel.repaint(); } ((CardLayout) myContentPanel.getLayout()).show(myContentPanel, id); }
public void toggleSoundText(boolean muted) { if (!muted) { taSound.setText("Sound is: on"); } else { taSound.setText("Sound is: off"); } contentPane.revalidate(); contentPane.repaint(); }
private void selectCompiler(BackendCompiler compiler) { if (compiler == null) { compiler = myDefaultCompiler; } myCompiler.setSelectedItem(compiler); mySelectedCompiler = compiler; myCardLayout.show(myContentPanel, compiler.getId()); myContentPanel.revalidate(); myContentPanel.repaint(); }
private void updateCaretPositionText() { if (myErrorMessage != null) { myCaretPositionLabel.setText( IdeBundle.message("label.scope.editor.caret.position", myCaretPosition + 1)); } else { myCaretPositionLabel.setText(""); } myPositionPanel.setVisible(myErrorMessage != null); myCaretPositionLabel.setVisible(myErrorMessage != null); myPanel.revalidate(); }
public void removeElement(PanelElementAbstract b) { int idx = panelElements.indexOf(b); if (idx >= 0) { panelElements.remove(idx); listPanel.remove(b.getPanel()); listLayout.setRows(Math.max(panelElements.size() + 1, minNbRows)); listPanel.revalidate(); listPanel.repaint(); setAddButtonColor(); if (ml != null) b.unRegister(ml); for (int i = idx; i < panelElements.size(); i++) panelElements.get(i).setIdx(idx); } }
private void ensurePresentation() { if (myCurrentHorizontal != myConfiguration.SHORT_DIFF_HORISONTALLY) { final DiffPanel panel = getCurrentPanel(); myPanel.removeAll(); myPanel.add(myTopPanel, BorderLayout.NORTH); myPanel.add(panel.getComponent(), BorderLayout.CENTER); myPanel.revalidate(); myPanel.repaint(); myCurrentHorizontal = myConfiguration.SHORT_DIFF_HORISONTALLY; } }
private void initButtonPanel() { final Parser p = InterfaceConfig.SELECTION_FRAME_PROPERTIES; back.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { state.back(); } }); back.setText(p.getString("back-button")); next.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { state.next(); } }); next.setText(p.getString("next-button-next")); config.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { JDialog d = loaders.get(plugins.getSelectedIndex()).getConfigDialog(SelectionFrame.this); d.setLocationByPlatform(true); d.setModal(true); d.setVisible(true); } }); JButton manual = new JButton(p.getString("manual-button")); manual.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { MainFrame.showHelp( state.getManualTile(), p.getInt("manual-width"), p.getInt("manual-height"), p.getInt("manual-deltaX"), p.getInt("manual-deltaY"), state.getManualURL(), SelectionFrame.this); } }); config.setText(p.getString("config-button")); buttonPanel.add(back); buttonPanel.add(manual); buttonPanel.add(config); buttonPanel.add(next); buttonPanel.revalidate(); }
/** * Scale the generated image and add it to the print preview pane. * * @param pageImage Image to be scaled */ private void addPage(final Image pageImage) { // Create a component representing the scaled page preview image. JPanel panel = new JPanel() { private Image scaled = null; private Dimension dim = new Dimension(); /** Return preview dimensions using the current scale factor. */ public Dimension getPreferredSize() { int width = (int) (pageImage.getWidth(null) * kPreviewScale); int height = (int) (pageImage.getHeight(null) * kPreviewScale); // If the dimensions are not too large, continue processing if ((dim.width != width) || (dim.height != height)) { dim.height = height; dim.width = height; // Cached dimensions are invalid, re-scale the image. scaled = pageImage.getScaledInstance(width, height, Image.SCALE_SMOOTH); setPreferredSize(new Dimension(dim.width + 2 * kGap, dim.height + 2 * kGap)); } return super.getPreferredSize(); } /** Minimum preview size is the same as the preferred size. */ public Dimension getMinimumSize() { return getPreferredSize(); } /** Maximum preview size is the same as the preferred size. */ public Dimension getMaximumSize() { return getPreferredSize(); } /** Clear the drawing area and paint the scaled image. */ public void paintComponent(Graphics g) { g.setColor(previewPane.getBackground()); g.fillRect(0, 0, dim.width + 2 * kGap, dim.height + 2 * kGap); g.setColor(Color.WHITE); g.fillRect(kGap, kGap, dim.width, dim.height); // If the image should be scaled, draw it if (scaled != null) { g.drawImage(scaled, kGap, kGap, dim.width, dim.height, null); } } }; // Add scaled image to the print preview pane and re-layout the pane. previewPane.add(panel); previewPane.revalidate(); previewPane.repaint(); }
private void setToComponent(final JComponent cmp, final boolean requestFocus) { myMatchingCountPanel.removeAll(); myMatchingCountPanel.add(cmp, BorderLayout.CENTER); myMatchingCountPanel.revalidate(); myMatchingCountPanel.repaint(); if (requestFocus) { SwingUtilities.invokeLater( new Runnable() { public void run() { myPatternField.getTextField().requestFocusInWindow(); } }); } }
public void edit(InitVariableAction var) { variable = var; if (editor != null) varEditPane.remove((EditorPanel) editor); var.addVariableListener(variableListener); editor = var.getVariableEditor(); varName.setText(var.getName()); varName.repaint(); if (editor != null) { editor.edit(var.getNewInitialization()); varEditPane.add((EditorPanel) editor, BorderLayout.CENTER); varEditPane.revalidate(); varEditPane.repaint(); } }
private void updateTextFieldShowing() { myTextFieldAction.update(); myNorthPanel.remove(myPathTextFieldWrapper); if (isToShowTextField()) { final ArrayList<VirtualFile> selection = new ArrayList<VirtualFile>(); if (myFileSystemTree.getSelectedFile() != null) { selection.add(myFileSystemTree.getSelectedFile()); } updatePathFromTree(selection, true); myNorthPanel.add(myPathTextFieldWrapper, BorderLayout.CENTER); } else { setErrorText(null); } myPathTextField.getField().requestFocus(); myNorthPanel.revalidate(); myNorthPanel.repaint(); }
private void viewReport() throws Exception { Date fromDate = fromDatePicker.getDate(); Date toDate = toDatePicker.getDate(); if (fromDate.after(toDate)) { POSMessageDialog.showError( BackOfficeWindow.getInstance(), com.floreantpos.POSConstants.FROM_DATE_CANNOT_BE_GREATER_THAN_TO_DATE_); return; } fromDate = DateUtil.startOfDay(fromDate); toDate = DateUtil.endOfDay(toDate); ReportService reportService = new ReportService(); CreditCardReport report = reportService.getCreditCardReport(fromDate, toDate); HashMap<String, Object> map = new HashMap<String, Object>(); ReportUtil.populateRestaurantProperties(map); map.put( "reportTitle", "========= " + Messages.getString("PosMessage.142").toUpperCase() + " =========="); map.put("fromDate", ReportService.formatShortDate(fromDate)); map.put("toDate", ReportService.formatShortDate(toDate)); map.put("reportTime", ReportService.formatFullDate(new Date())); map.put("salesCount", String.valueOf(report.getTotalSalesCount())); map.put("totalSales", NumberUtil.formatNumber(report.getTotalSales())); map.put("netTips", NumberUtil.formatNumber(report.getNetTips())); map.put("netTipsPaid", NumberUtil.formatNumber(report.getTipsPaid())); map.put("netCharge", NumberUtil.formatNumber(report.getNetCharge())); JasperReport jasperReport = (JasperReport) JRLoader.loadObject( getClass().getResource("/com/floreantpos/ui/report/credit_card_report.jasper")); JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, map, new JRTableModelDataSource(report.getTableModel())); JRViewer viewer = new JRViewer(jasperPrint); reportContainer.removeAll(); reportContainer.add(viewer); reportContainer.revalidate(); }
/** Update any UI elements from the model (hint that data has changed). */ public void updateFromModel() { if (ColorAndFontConstants.isInverse()) { inactiveBackGroundColor = new Color( Math.min(255, Themes.currentTheme.detailPanelBackground().getRed() + 2 * COLOR_DELTA), Math.min( 255, Themes.currentTheme.detailPanelBackground().getBlue() + 2 * COLOR_DELTA), Math.min( 255, Themes.currentTheme.detailPanelBackground().getGreen() + 2 * COLOR_DELTA)); } else { inactiveBackGroundColor = new Color( Math.max(0, Themes.currentTheme.detailPanelBackground().getRed() - COLOR_DELTA), Math.max(0, Themes.currentTheme.detailPanelBackground().getBlue() - COLOR_DELTA), Math.max(0, Themes.currentTheme.detailPanelBackground().getGreen() - COLOR_DELTA)); } panelMain.invalidate(); panelMain.revalidate(); panelMain.repaint(); }
public boolean closeDialog(DialogTab dialogTab) { for (int i = 0; i < dialogTabArrayList.size(); i++) { if (dialogTabArrayList.get(i).equals(dialogTab)) { dialogPanelArrayList.remove(i); dialogTabArrayList.remove(i); if (!(currentDialogPanel == null)) currentDialogPanel.setVisible(false); if (dialogTabArrayList.size() == 0) { dialogTabsPanel.setVisible(false); currentDialogTab = null; currentDialogPanel = null; repaint(); revalidate(); return true; } if ((dialogTab.equals(currentDialogTab))) { if (i > 0) { currentDialogPanel = dialogPanelArrayList.get(i - 1); currentDialogTab = dialogTabArrayList.get(i - 1); } else { currentDialogPanel = dialogPanelArrayList.get(i); currentDialogTab = dialogTabArrayList.get(i); } } if (!(currentDialogPanel == null)) { currentDialogTab.setBorder(new LineBorder(Color.RED)); currentDialogPanel.setBounds(0, 84, 960, 1000); bigPanel.add(currentDialogPanel); currentDialogPanel.setVisible(true); } dialogTabsPanel.setVisible(false); if (dialogTabArrayList.size() > 0) repaintDialogTabsPanel(); bigPanel.repaint(); bigPanel.revalidate(); break; } } return false; }