List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE
int INFORMATION_MESSAGE
To view the source code for javax.swing JOptionPane INFORMATION_MESSAGE.
Click Source Link
From source file:com.simplexrepaginator.RepaginateFrame.java
protected JButton createUnrepaginateButton() { JButton b = new JButton("<html><center>Click to<br>un-repaginate", UNREPAGINATE_ICON); b.setHorizontalTextPosition(SwingConstants.RIGHT); b.setIconTextGap(25);//from ww w.j a v a2s . c o m b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int[] documentsPages = repaginator.unrepaginate(); JOptionPane.showMessageDialog( RepaginateFrame.this, "Unrepaginated " + documentsPages[0] + " documents with " + documentsPages[1] + " pages.", "Unrepagination Complete", JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(RepaginateFrame.this, ex.toString(), "Error During Unrepagination", JOptionPane.ERROR_MESSAGE); } } }); return b; }
From source file:au.org.ala.delta.intkey.ui.FindInCharactersDialog.java
@Action public void findCharacters() { String searchText = _textField.getText(); boolean searchStates = _chckbxSearchStates.isSelected(); boolean searchUsedCharacters = _chckbxSearchUsedCharacters.isSelected(); if (!StringUtils.isEmpty(searchText)) { _numMatchedCharacters = _intkeyApp.findCharacters(searchText, searchStates, searchUsedCharacters); this.setTitle(MessageFormat.format(windowTitleNumberFound, _numMatchedCharacters)); if (_numMatchedCharacters > 0) { _currentMatchedCharacter = 0; characterSelectionUpdated(); } else {/*ww w . ja v a 2s . co m*/ JOptionPane.showMessageDialog(this, noCharactersFoundMessage, "", JOptionPane.INFORMATION_MESSAGE); } } }
From source file:calendarexportplugin.exporter.GoogleExporter.java
public boolean exportPrograms(Program[] programs, CalendarExportSettings settings, AbstractPluginProgramFormating formatting) { try {/* w ww.j a v a 2s .c o m*/ boolean uploadedItems = false; mPassword = IOUtilities.xorDecode(settings.getExporterProperty(PASSWORD), 345903).trim(); if (!settings.getExporterProperty(STORE_PASSWORD, false)) { if (!showLoginDialog(settings)) { return false; } } if (!settings.getExporterProperty(STORE_SETTINGS, false)) { if (!showCalendarSettings(settings)) { return false; } } GoogleService myService = new GoogleService("cl", "tvbrowser-tvbrowsercalenderplugin-" + CalendarExportPlugin.getInstance().getInfo().getVersion().toString()); myService.setUserCredentials(settings.getExporterProperty(USERNAME).trim(), mPassword); URL postUrl = new URL("http://www.google.com/calendar/feeds/" + settings.getExporterProperty(SELECTED_CALENDAR) + "/private/full"); SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd"); formatDay.setTimeZone(TimeZone.getTimeZone("GMT")); SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss"); formatTime.setTimeZone(TimeZone.getTimeZone("GMT")); ParamParser parser = new ParamParser(); for (Program program : programs) { final String title = parser.analyse(formatting.getTitleValue(), program); // First step: search for event in calendar boolean createEvent = true; CalendarEventEntry entry = findEntryForProgram(myService, postUrl, title, program); if (entry != null) { int ret = JOptionPane.showConfirmDialog(null, mLocalizer.msg("alreadyAvailable", "already available", program.getTitle()), mLocalizer.msg("title", "Add event?"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret != JOptionPane.YES_OPTION) { createEvent = false; } } // add event to calendar if (createEvent) { EventEntry myEntry = new EventEntry(); myEntry.setTitle(new PlainTextConstruct(title)); String desc = parser.analyse(formatting.getContentValue(), program); myEntry.setContent(new PlainTextConstruct(desc)); Calendar c = CalendarToolbox.getStartAsCalendar(program); DateTime startTime = new DateTime(c.getTime(), c.getTimeZone()); c = CalendarToolbox.getEndAsCalendar(program); DateTime endTime = new DateTime(c.getTime(), c.getTimeZone()); When eventTimes = new When(); eventTimes.setStartTime(startTime); eventTimes.setEndTime(endTime); myEntry.addTime(eventTimes); if (settings.getExporterProperty(REMINDER, false)) { int reminderMinutes = 0; try { reminderMinutes = settings.getExporterProperty(REMINDER_MINUTES, 0); } catch (NumberFormatException e) { e.printStackTrace(); } if (settings.getExporterProperty(REMINDER_ALERT, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.ALERT); } if (settings.getExporterProperty(REMINDER_EMAIL, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.EMAIL); } if (settings.getExporterProperty(REMINDER_SMS, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.SMS); } } if (settings.isShowBusy()) { myEntry.setTransparency(BaseEventEntry.Transparency.OPAQUE); } else { myEntry.setTransparency(BaseEventEntry.Transparency.TRANSPARENT); } // Send the request and receive the response: myService.insert(postUrl, myEntry); uploadedItems = true; } } if (uploadedItems) { JOptionPane.showMessageDialog(CalendarExportPlugin.getInstance().getBestParentFrame(), mLocalizer.msg("exportDone", "Google Export done."), mLocalizer.msg("export", "Export"), JOptionPane.INFORMATION_MESSAGE); } return true; } catch (AuthenticationException e) { ErrorHandler.handle(mLocalizer.msg("loginFailure", "Problems during login to Service.\nMaybe bad username or password?"), e); settings.setExporterProperty(STORE_PASSWORD, false); } catch (Exception e) { ErrorHandler.handle(mLocalizer.msg("commError", "Error while communicating with Google!"), e); } return false; }
From source file:edu.harvard.i2b2.analysis.queryClient.CRCQueryClient.java
public static String sendPDOQueryRequestREST(String XMLstr) { try {// w w w . j a va2 s .c om MessageUtil.getInstance().setRequest("URL: " + getPDOServiceName() + "\n" + XMLstr); OMElement payload = getQueryPayLoad(XMLstr); Options options = new Options(); targetEPR = new EndpointReference(getPDOServiceName()); options.setTo(targetEPR); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE); options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(600000)); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(600000)); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement responseElement = sender.sendReceive(payload); // log.debug("Client Side response " + responseElement.toString()); MessageUtil.getInstance() .setResponse("URL: " + getPDOServiceName() + "\n" + responseElement.toString()); return responseElement.toString(); } catch (AxisFault axisFault) { axisFault.printStackTrace(); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return null; } catch (java.lang.OutOfMemoryError e) { e.printStackTrace(); return "memory error"; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:de.xplib.xdbm.ui.dialog.FirstStartSetup.java
/** * //from ww w . j av a 2s. c o m */ private void initUI() { this.getContentPane().setLayout(this.mainLayout); Locale l = this.config.getLocale(); Object[] args = new Object[0]; this.jfField.addFileFilter(JFileField.JAR_FILE_FILTER); this.jfField.setFileSelectionMode(JFileChooser.FILES_ONLY); this.jfField.addSelectListener(new FileSelectListener()); this.jfField.addDocumentListener(new EnableButtonListener()); this.jfField.setToolTipText(MessageManager.getText("setup.dialog.jarfile.tooltip", "text", args, l)); this.jtfClass.getDocument().addDocumentListener(new EnableButtonListener()); this.jtfClass.setToolTipText(MessageManager.getText("setup.dialog.class.tooltip", "text", args, l)); this.jtfDbURI.setToolTipText(MessageManager.getText("setup.dialog.dburi.tooltip", "text", args, l)); this.jbTest.setEnabled(false); this.jbTest.setText(MessageManager.getText("setup.dialog.test.label", "text", args, l)); this.jbTest.setToolTipText(MessageManager.getText("setup.dialog.test.tooltip", "text", args, l)); this.jbTest.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { if (actionPerformedTest(ae)) { JOptionPane.showMessageDialog(FirstStartSetup.this, MessageManager.getText("setup.dialog.test.success.message", "text", new Object[0], config.getLocale()), MessageManager.getText("setup.dialog.test.success.title", "text", new Object[0], config.getLocale()), JOptionPane.INFORMATION_MESSAGE); } } }); this.jbCancel.setText(MessageManager.getText("setup.dialog.cancel.label", "text", args, l)); this.jbCancel.setToolTipText(MessageManager.getText("setup.dialog.cancel.tooltip", "text", args, l)); this.jbCancel.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { System.exit(0); } }); this.jbOk.setEnabled(false); this.jbOk.setText(MessageManager.getText("setup.dialog.ok.label", "text", args, l)); this.jbOk.setToolTipText(MessageManager.getText("setup.dialog.ok.tooltip", "text", args, l)); this.jbOk.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { if (actionPerformedTest(ae)) { String jar = jfField.getText().trim(); config.putDriver(jar, jtfClass.getText().trim()); String uri = jtfDbURI.getText().trim(); if (!uri.equals("")) { config.putDatabaseURI(jar, uri); } dispose(); } } }); FormLayout layout = new FormLayout("right:pref, 3dlu, pref, 3dlu, pref, 3dlu, pref", "p, 3dlu, p, 3dlu, p, 3dlu, p, 9dlu, p, 3dlu, p"); layout.setColumnGroups(new int[][] { { 3, 5, 7 } }); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); // Obtain a reusable constraints object to place components in the grid. CellConstraints cc = new CellConstraints(); // Fill the grid with components; the builder can create // frequently used components, e.g. separators and labels. // Add a titled separator to cell (1, 1) that spans 7 columns. builder.addSeparator(MessageManager.getText("setup.dialog.header", "text", args, l), cc.xyw(1, 1, 7)); builder.addLabel(MessageManager.getText("setup.dialog.jarfile.label", "text", args, l), cc.xy(1, 3)); builder.add(this.jfField, cc.xyw(3, 3, 5)); builder.addLabel(MessageManager.getText("setup.dialog.class.label", "text", args, l), cc.xy(1, 5)); builder.add(this.jtfClass, cc.xyw(3, 5, 5)); builder.addLabel(MessageManager.getText("setup.dialog.dburi.label", "text", args, l), cc.xy(1, 7)); builder.add(this.jtfDbURI, cc.xyw(3, 7, 5)); builder.addSeparator("", cc.xyw(1, 9, 7)); builder.add(this.jbTest, cc.xy(3, 11)); builder.add(this.jbCancel, cc.xy(5, 11)); builder.add(this.jbOk, cc.xy(7, 11)); this.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); this.statusPanel.setLayout(this.statusLayout); this.statusPanel.add(this.statusLabel); this.statusPanel.add(this.statusBar); this.statusLabel.setBorder(BorderFactory.createLoweredBevelBorder()); this.statusBar.setBorder(BorderFactory.createLoweredBevelBorder()); this.statusBar.setStringPainted(true); this.getContentPane().add(this.statusPanel, BorderLayout.SOUTH); }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.MainM.java
private static int askForEnablingKEGG() { JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While VANTED is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>" + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>" + "For using VANTED you need also be aware of information about licenses and conditions for<br>" + "usage, listed at the program info dialog and the VANTED website (http://vanted.ipk-gatersleben.de).<br><br>" + "VANTED does not distribute information from KEGG but contains functionality for the online-access to <br>" + "information from KEGG website.<br><br>" + "<b>Before these functions are available to you, you should carefully read the following license information<br>" + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>" + "all other features of this application are still available and fully working.", "VANTED Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(), "VANTED Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?", "VANTED Program Features Initialization", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); return result; }
From source file:de.codesourcery.eve.skills.ui.components.AbstractComponent.java
protected void displayInfo(String message) { Component parent = null;/*from ww w .j a v a 2 s . co m*/ if (getComponentCallback() instanceof Component) { parent = (Component) getComponentCallback(); } JOptionPane.showMessageDialog(parent, message, "Info", JOptionPane.INFORMATION_MESSAGE); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellStatisticsController.java
/** * Initialize main view.//ww w . j a va 2s .c o m */ private void initMainView() { // the view is kept in the parent controllers AnalysisPanel analysisPanel = singleCellAnalysisController.getAnalysisPanel(); analysisPanel.getConditionList().setModel(new DefaultListModel()); // customize tables analysisPanel.getStatTable().getTableHeader().setReorderingAllowed(false); analysisPanel.getStatTable().getTableHeader().setReorderingAllowed(false); analysisPanel.getComparisonTable().setFillsViewportHeight(true); analysisPanel.getComparisonTable().setFillsViewportHeight(true); // init binding groupsBindingList = ObservableCollections.observableList(new ArrayList<SingleCellAnalysisGroup>()); JListBinding jListBinding = SwingBindings.createJListBinding(AutoBinding.UpdateStrategy.READ_WRITE, groupsBindingList, analysisPanel.getAnalysisGroupList()); bindingGroup.addBinding(jListBinding); // fill in combo box List<Double> significanceLevels = new ArrayList<>(); for (SignificanceLevel significanceLevel : SignificanceLevel.values()) { significanceLevels.add(significanceLevel.getValue()); } ObservableList<Double> significanceLevelsBindingList = ObservableCollections .observableList(significanceLevels); JComboBoxBinding jComboBoxBinding = SwingBindings.createJComboBoxBinding( AutoBinding.UpdateStrategy.READ_WRITE, significanceLevelsBindingList, analysisPanel.getSignLevelComboBox()); bindingGroup.addBinding(jComboBoxBinding); bindingGroup.bind(); // add the NONE (default) correction method // when the none is selected, CellMissy does not correct for multiple hypotheses analysisPanel.getCorrectionComboBox().addItem("none"); // fill in combo box: get all the correction methods from the factory Set<String> correctionBeanNames = MultipleComparisonsCorrectionFactory.getInstance() .getCorrectionBeanNames(); correctionBeanNames.stream().forEach((correctionBeanName) -> { analysisPanel.getCorrectionComboBox().addItem(correctionBeanName); }); // do the same for the statistical tests Set<String> statisticsCalculatorBeanNames = StatisticsTestFactory.getInstance() .getStatisticsCalculatorBeanNames(); statisticsCalculatorBeanNames.stream().forEach((testName) -> { analysisPanel.getStatTestComboBox().addItem(testName); }); //significance level to 0.05 analysisPanel.getSignLevelComboBox().setSelectedIndex(1); // add parameters to perform analysis on analysisPanel.getParameterComboBox().addItem("cell speed"); analysisPanel.getParameterComboBox().addItem("cell direct"); /** * Add a group to analysis */ analysisPanel.getAddGroupButton().addActionListener((ActionEvent e) -> { // from selected conditions make a new group and add it to the list addGroupToAnalysis(); }); /** * Remove a Group from analysis */ analysisPanel.getRemoveGroupButton().addActionListener((ActionEvent e) -> { // remove the selected group from list removeGroupFromAnalysis(); }); /** * Execute a Mann Whitney Test on selected Analysis Group */ analysisPanel.getPerformStatButton().addActionListener((ActionEvent e) -> { int selectedIndex = analysisPanel.getAnalysisGroupList().getSelectedIndex(); String statisticalTestName = analysisPanel.getStatTestComboBox().getSelectedItem().toString(); String param = analysisPanel.getParameterComboBox().getSelectedItem().toString(); // check that an analysis group is being selected if (selectedIndex != -1) { SingleCellAnalysisGroup selectedGroup = groupsBindingList.get(selectedIndex); // compute statistics computeStatistics(selectedGroup, statisticalTestName, param); // show statistics in tables showSummary(selectedGroup); // set the correction combobox to the one already chosen analysisPanel.getCorrectionComboBox().setSelectedItem(selectedGroup.getCorrectionMethodName()); if (selectedGroup.getCorrectionMethodName().equals("none")) { // by default show p-values without adjustment showPValues(selectedGroup, false); } else { // show p values with adjustement showPValues(selectedGroup, true); } } else { // ask user to select a group singleCellAnalysisController.showMessage("Please select a group to perform analysis on.", "You must select a group first", JOptionPane.INFORMATION_MESSAGE); } }); /** * Refresh p value table with current selected significance of level */ analysisPanel.getSignLevelComboBox().addActionListener((ActionEvent e) -> { if (analysisPanel.getSignLevelComboBox().getSelectedIndex() != -1) { String statisticalTest = analysisPanel.getStatTestComboBox().getSelectedItem().toString(); Double selectedSignLevel = (Double) analysisPanel.getSignLevelComboBox().getSelectedItem(); SingleCellAnalysisGroup selectedGroup = groupsBindingList .get(analysisPanel.getAnalysisGroupList().getSelectedIndex()); boolean isAdjusted = !selectedGroup.getCorrectionMethodName().equals("none"); singleCellStatisticsAnalyzer.detectSignificance(selectedGroup, statisticalTest, selectedSignLevel, isAdjusted); boolean[][] significances = selectedGroup.getSignificances(); JTable pValuesTable = analysisPanel.getComparisonTable(); for (int i = 1; i < pValuesTable.getColumnCount(); i++) { pValuesTable.getColumnModel().getColumn(i) .setCellRenderer(new PValuesTableRenderer(new DecimalFormat("#.####"), significances)); } pValuesTable.repaint(); } }); /** * Apply correction for multiple comparisons: choose the algorithm! */ analysisPanel.getCorrectionComboBox().addActionListener((ActionEvent e) -> { int selectedIndex = analysisPanel.getAnalysisGroupList().getSelectedIndex(); if (selectedIndex != -1) { SingleCellAnalysisGroup selectedGroup = groupsBindingList.get(selectedIndex); String correctionMethod = analysisPanel.getCorrectionComboBox().getSelectedItem().toString(); // if the correction method is not "NONE" if (!correctionMethod.equals("none")) { // adjust p values singleCellStatisticsAnalyzer.correctForMultipleComparisons(selectedGroup, correctionMethod); // show p - values with the applied correction showPValues(selectedGroup, true); } else { // if selected correction method is "NONE", do not apply correction and only show normal p-values showPValues(selectedGroup, false); } } }); /** * Perform statistical test: choose the test!! */ analysisPanel.getPerformStatButton().addActionListener((ActionEvent e) -> { // get the selected test to be executed String selectedTest = analysisPanel.getStatTestComboBox().getSelectedItem().toString(); String param = analysisPanel.getParameterComboBox().getSelectedItem().toString(); // analysis group int selectedIndex = analysisPanel.getAnalysisGroupList().getSelectedIndex(); if (selectedIndex != -1) { SingleCellAnalysisGroup selectedGroup = groupsBindingList.get(selectedIndex); computeStatistics(selectedGroup, selectedTest, param); } }); //multiple comparison correction: set the default correction to none analysisPanel.getCorrectionComboBox().setSelectedIndex(0); analysisPanel.getStatTestComboBox().setSelectedIndex(0); analysisPanel.getParameterComboBox().setSelectedIndex(0); }
From source file:lab4.YouQuiz.java
private void switchToQuizMode() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);// w w w . java 2 s.com backButton.setFocusable(false); toolbar.add(backButton); toolbar.setAlignmentX(0); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { contentPanel.setQuestion(questionsArray.get(--questionIndex)); forwardButton.setEnabled(true); if (questionIndex - 1 < 0) { backButton.setEnabled(false); } updateAnswerForm(); } }); forwardButton.setFocusable(false); toolbar.add(forwardButton); toolbar.setAlignmentX(0); forwardButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { contentPanel.setQuestion(questionsArray.get(++questionIndex)); backButton.setEnabled(true); if (questionsArray.size() == questionIndex + 1) { forwardButton.setEnabled(false); } updateAnswerForm(); } }); speakButton.setFocusable(false); toolbar.add(speakButton); toolbar.setAlignmentX(0); speakButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { Audio audio = Audio.getInstance(); InputStream sound = null; try { sound = audio.getAudio(questionsArray.get(questionIndex).getQuestion(), Language.ENGLISH); } catch (IOException ex) { Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex); } try { audio.play(sound); } catch (JavaLayerException ex) { Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex); } } }); refreshButton.setFocusable(false); toolbar.add(refreshButton); toolbar.setAlignmentX(0); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { shuffleQuestions(); questionIndex = 0; backButton.setEnabled(false); if (questionsArray.size() == 1) { forwardButton.setEnabled(false); } else { forwardButton.setEnabled(true); } contentPanel.setQuestion(questionsArray.get(questionIndex)); updateAnswerForm(); } }); micButton.setFocusable(false); toolbar.add(micButton); toolbar.setAlignmentX(0); micButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { GSpeechDuplex dup = new GSpeechDuplex(); dup.addResponseListener(new GSpeechResponseListener() { @Override public void onResponse(GoogleResponse gr) { if (questionsArray.get(questionIndex).checkAnswer(gr.getResponse())) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! '" + gr.getResponse() + "' is a wrong Answer. Its '" + questionsArray.get(questionIndex).getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); Microphone mic = new Microphone(FLACFileWriter.FLAC); File file = new File("CRAudioTest.flac"); try { mic.captureAudioToFile(file); Thread.sleep(5000); mic.close(); byte[] data = Files.readAllBytes(mic.getAudioFile().toPath()); dup.recognize(data, (int) mic.getAudioFormat().getSampleRate()); mic.getAudioFile().delete(); } catch (LineUnavailableException | InterruptedException | IOException ex) { } } }); contentPanel = new ContentPanel(); contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); contentPanel.add(toolbar, BorderLayout.NORTH); contentPanel.add(Box.createRigidArea(new Dimension(0, 50))); contentPanel.add(contentPanel.questionLabel); add(contentPanel, BorderLayout.CENTER); if (questionsArray.isEmpty()) { refreshButton.setEnabled(false); backButton.setEnabled(false); forwardButton.setEnabled(false); speakButton.setEnabled(false); } else { questionIndex = 0; backButton.setEnabled(false); if (questionsArray.size() == 1) { forwardButton.setEnabled(false); } contentPanel.setQuestion(questionsArray.get(questionIndex)); contentPanel.add(Box.createRigidArea(new Dimension(0, 20))); contentPanel.add(contentPanel.answerPanel); contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); contentPanel.add(contentPanel.checkButton); updateAnswerForm(); } }
From source file:dialog.DialogFunctionUser.java
private void actionAddUser() { if (!isValidData()) { return;// w w w. j a v a 2 s. c o m } if (isExistUsername(tfUsername.getText())) { JOptionPane.showMessageDialog(null, "Username tn ti", "Error", JOptionPane.ERROR_MESSAGE); return; } String username = tfUsername.getText(); String fullname = tfFullname.getText(); String password = new String(tfPassword.getPassword()); password = LibraryString.md5(password); int role = cbRole.getSelectedIndex(); User objUser; if (mAvatar != null) { objUser = new User(UUID.randomUUID().toString(), username, password, fullname, role, new Date(System.currentTimeMillis()), mAvatar.getPath()); String fileName = FilenameUtils.getBaseName(mAvatar.getName()) + "-" + System.nanoTime() + "." + FilenameUtils.getExtension(mAvatar.getName()); Path source = Paths.get(mAvatar.toURI()); Path destination = Paths.get("files/" + fileName); try { Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); } catch (IOException ex) { Logger.getLogger(DialogFunctionRoom.class.getName()).log(Level.SEVERE, null, ex); } } else { objUser = new User(UUID.randomUUID().toString(), username, password, fullname, role, new Date(System.currentTimeMillis()), ""); } if (mControllerUser.addItem(objUser)) { ImageIcon icon = new ImageIcon(getClass().getResource("/images/ic_success.png")); JOptionPane.showMessageDialog(this.getParent(), "Thm thnh cng", "Success", JOptionPane.INFORMATION_MESSAGE, icon); } else { JOptionPane.showMessageDialog(this.getParent(), "Thm tht bi", "Fail", JOptionPane.ERROR_MESSAGE); } this.dispose(); }