Java Code Examples for javax.swing.JOptionPane

The following are top voted examples for showing how to use javax.swing.JOptionPane. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: SkyDocs   File: ProjectsFrame.java   View source code 6 votes vote down vote up
/**
 * Loads projects from the history.
 */

public final void loadHistory() {
	try {
		final File history = new File(Utils.getParentFolder(), Constants.FILE_GUI_HISTORY);
		if(!history.exists()) {
			return;
		}
		for(final String path : Files.readLines(history, StandardCharsets.UTF_8)) {
			final File projectData = new File(path, Constants.FILE_PROJECT_DATA);
			if(!projectData.exists()) {
				continue;
			}
			projectsModel.addElement(path);
		}
	}
	catch(final Exception ex) {
		ex.printStackTrace(guiPrintStream);
		ex.printStackTrace();
		JOptionPane.showMessageDialog(ProjectsFrame.this, String.format(Constants.GUI_DIALOG_ERROR_MESSAGE, ex.getMessage()), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 2
Project: 3way_laboratorios   File: MaiorNumero.java   View source code 6 votes vote down vote up
public static void main(String[] args) {

		int[] num = new int[10];
		int contador;
		int max = 0;
		int numerostotal = 3;

		// Pede ao usuário para digitar números
		for (contador = 0; contador < numerostotal; contador++) {
			num[contador] = Integer.parseInt(JOptionPane.showInputDialog("Entre com números até " + numerostotal + " no total"));

			// verifica se o número digitado é maior que max
			if (( contador == 0 ) || ( num[contador] < max ))
				max = num[contador];
		}

		// Mostra o maior número.
		JOptionPane.showMessageDialog(null, "O maior número é " + max);
	}
 
Example 3
Project: ProjetoERP   File: ClienteViewActionListener.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    if (action.equals(Vars.PROP_NEW)) {
        ClientesCadastro clienteCadastro = new ClientesCadastro();
        if (VerificaFrame.verificaFrame(clientes.getPainel(), clienteCadastro)) {
            VerificaFrame.exibirFrame(clientes.getPainel(), clienteCadastro);
            clientes.addChild(clienteCadastro);
        }
    } else if (action.equals(Vars.PROP_REMOVE)) {
         JTable tabela = clientes.getTable();
       int cod = (int) tabela.getValueAt(tabela.getSelectedRow(), 1);
        br.com.secharpe.dao.ClienteDAO clDAO = new br.com.secharpe.dao.ClienteDAO();
        clDAO.delete(cod);
        clientes.refreshTable();
    } else if (action.equals(Vars.PROP_EDIT)) {
        JOptionPane.showMessageDialog(null, "W.I.P.");
    } else if (action.equals(Vars.PROP_CLOSE)) {
        clientes.dispose();
    }
}
 
Example 4
Project: GroupK   File: KhachHangDAL.java   View source code 6 votes vote down vote up
public static void InsertKhachHang(KhachHang kh) {
    String sql = "insert into KHACH_HANG values(?,?,?,?,?)";
    try {
        ps = DBconnect.getConnect().prepareStatement(sql);
        ps.setString(1, kh.getMaKH());
        ps.setString(2, kh.getTenKH());
        ps.setDate(3, kh.getBirth());
        ps.setString(4, kh.getDiaChi());
        ps.setString(5, kh.getPhone());
      
        ps.execute();
        JOptionPane.showMessageDialog(null, "Đã thêm khách hàng thành công!" , "Thông báo", 1);
    } catch(Exception e) {
        JOptionPane.showMessageDialog(null, "Khách hàng không được thêm" , "Thông báo", 1);
    }
}
 
Example 5
Project: grade-buddy   File: MainWindow.java   View source code 6 votes vote down vote up
/**
 * Executes the selection script.
 * @param submission The currently selected submission
 * @throws Exception See {@link Command#execute()}
 */
private void runScript(final Submission submission) throws Exception {
    Command c = new Command(
        new String[]{
            "sh",
            this.selectionScript.getAbsolutePath(),
            submission.directory().getAbsolutePath()
        }
    ).execute();
    if (c.result().exitCode() != 0) {
        System.out.println(c.result().outputStream().toString());
        System.err.println(c.result().errorStream().toString());
        JOptionPane.showMessageDialog(
            this,
            "Error executing script. Please read the error output.",
            "Error",
            JOptionPane.ERROR_MESSAGE
        );
    }
}
 
Example 6
Project: Tarski   File: EditorActions.java   View source code 6 votes vote down vote up
/**
 * @throws IOException
 *
 */
protected void openGD(BasicGraphEditor editor, File file,
		String gdText)
{
	mxGraph graph = editor.getGraphComponent().getGraph();

	// Replaces file extension with .mxe
	String filename = file.getName();
	filename = filename.substring(0, filename.length() - 4) + ".mxe";

	if (new File(filename).exists()
			&& JOptionPane.showConfirmDialog(editor,
					mxResources.get("overwriteExistingFile")) != JOptionPane.YES_OPTION)
	{
		return;
	}

	((mxGraphModel) graph.getModel()).clear();
	mxGdCodec.decode(gdText, graph);
	editor.getGraphComponent().zoomAndCenter();
	editor.setCurrentFile(new File(lastDir + "/" + filename));
}
 
Example 7
Project: jmt   File: ClassesPanel.java   View source code 6 votes vote down vote up
private void setNumberOfClasses(int number) {
	classTable.stopEditing();

	if (number <= MAXCLASSES) {
		classes = number;
	} else {
		JOptionPane.showMessageDialog(this, "Sorry, jABA admits only up to " + MAXCLASSES + " classes", "jABA classes warning",
				JOptionPane.ERROR_MESSAGE);
		return;
	}

	classNames = ArrayUtils.resize(classNames, classes, null);
	makeNames();

	classTypes = ArrayUtils.resize(classTypes, classes, CLASS_CLOSED);
	classData = ArrayUtils.resize(classData, classes, 0.0);

	classTable.updateStructure();
	if (!deleting) {
		classOps.add(ListOp.createResizeOp(classes));
	}

	classSpinner.setValue(new Integer(classes));
	classTable.updateDeleteCommand();
}
 
Example 8
Project: SimQRI   File: WorkspaceManager.java   View source code 6 votes vote down vote up
/**
 * 
 * @param modelingProject the name of the selected modeling project
 * @return the list of all the report templates name that are available in the selected modeling project
 */
public static List<String> getTemplates(String modelingProject) { // For the SimulationManagementWindow (names)
	List<String> templatesName = new ArrayList<String>();
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(modelingProject);
	IFolder templatesFolder = project.getFolder("Report Templates");
	try {
		IResource[] folderContent = templatesFolder.members();
		for(IResource resource : folderContent) {
			if(resource.getType() == IFile.FILE && resource.getFileExtension().equals("rptdesign")) {
				templatesName.add(resource.getName());
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
		JOptionPane.showMessageDialog(null, "Error: " + e.getMessage() + "", "Error", JOptionPane.ERROR_MESSAGE);
	}
	return templatesName;
}
 
Example 9
Project: VASSAL-src   File: InviteCommand.java   View source code 6 votes vote down vote up
protected void executeCommand() {
  if (client instanceof NodeClient) {
    final int i = Dialogs.showConfirmDialog(
      GameModule.getGameModule().getFrame(),
      Resources.getString("Chat.invite_heading"), //$NON-NLS-1$
      Resources.getString("Chat.invite_heading"), //$NON-NLS-1$
      Resources.getString("Chat.invitation", player, room),  //$NON-NLS-1$
      JOptionPane.QUESTION_MESSAGE,
      null,
      JOptionPane.YES_NO_OPTION,
      "Invite"+playerId,  //$NON-NLS-1$
      Resources.getString("Chat.ignore_invitation") //$NON-NLS-1$
    );

    if (i == 0) {
      ((NodeClient) client).doInvite(playerId, room);
    }
  }
}
 
Example 10
Project: sumo   File: GeometricInteractiveVDSLayerModel.java   View source code 6 votes vote down vote up
public GeometricInteractiveVDSLayerModel(ILayer layer) {
    this.gl = ((EditGeometryVectorLayer) layer).getGeometriclayer();
    this.il = null;

    for (ILayer l : LayerManager.getIstanceManager().getLayers().keySet()) {
        if (l instanceof ImageLayer && l.isActive()) {
            il = (ImageLayer) l;
            break;
        }
    }

    vdslayer = (IComplexVectorLayer) layer;

    PlatformConfiguration configuration = SumoPlatform.getApplication().getConfiguration();
    // set the preferences values
    try {
        String colorString = configuration.getAzimuthGeometryColor();
        this.azimuthGeometrycolor = new Color(Integer.parseInt(colorString.equals("") ? Color.ORANGE.getRGB() + "" : colorString));
        this.azimuthGeometrylinewidth = configuration.getAzimuthLineWidth();
    } catch (NumberFormatException e) {
        //Logger.getLogger(GeometricInteractiveVDSLayerModel.class.getName()).log(Level.SEVERE, null, e);
        JOptionPane.showMessageDialog(null, "Wrong format with the preference settings", "Error", JOptionPane.ERROR_MESSAGE);
    }
}
 
Example 11
Project: xdman   File: XDMMainWindow.java   View source code 6 votes vote down vote up
private void openFile() {
	int row = table.getSelectedRow();
	if (row < 0)
		return;
	DownloadListItem item = list.get(row);
	if (item == null)
		return;
	if (item.state == IXDMConstants.COMPLETE) {
		File file = new File(item.saveto, item.filename);
		if (file.exists()) {
			XDMUtil.open(file);
		} else {
			showMessageBox(getString("FILE_NOT_FOUND"), getString("DEFAULT_TITLE"), JOptionPane.ERROR_MESSAGE);
		}
	} else {
		showMessageBox(getString("DWN_INCOMPLETE"), getString("DEFAULT_TITLE"), JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 12
Project: OpenDA   File: PlotFrame.java   View source code 6 votes vote down vote up
/** Print using the cross platform dialog.
 *  FIXME: this dialog is slow and is often hidden
 *  behind other windows.  However, it does honor
 *  the user's choice of portrait vs. landscape
 */
protected void _printCrossPlatform() {
    // Build a set of attributes
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(plot);
    if (job.printDialog(aset)) {
        try {
            job.print(aset);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    "Printing failed:\n" + ex.toString(),
                    "Print Error", JOptionPane.WARNING_MESSAGE);
        }
    }
}
 
Example 13
Project: Progetto-N   File: GuiInformationSale.java   View source code 6 votes vote down vote up
/**
 * Quando chiudo il programma o il db smette di funzionare
 */
public void imprevisto(){
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            int i = JOptionPane.showConfirmDialog(rootPane, "Sei sicuro di voler uscire?");
            if(i==JOptionPane.YES_OPTION){
                try {
                    CreateDb createDb = new CreateDb();
                    createDb.DropSchema();
                    dispose();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(rootPane, "Impossibile raggiungere il Database!");
                }  
            }else
                setDefaultCloseOperation(GuiNome.DO_NOTHING_ON_CLOSE);
        }
    });
}
 
Example 14
Project: OpenDiabetes   File: CommonSwing.java   View source code 6 votes vote down vote up
public static void errorMessage(Exception exceptionMsg, boolean quiet) {

        /**
         * Display Jpanel Error messages any SQL Errors. Overloads
         * errorMessage(String e)
         */
        Object[] options = { "OK", };

        JOptionPane.showOptionDialog(null, exceptionMsg, messagerHeader,
                                     JOptionPane.DEFAULT_OPTION,
                                     JOptionPane.ERROR_MESSAGE, null,
                                     options, options[0]);

        if (!quiet) {
            exceptionMsg.printStackTrace();
        }

        // DatabaseManagerSwing.StatusMessage(READY_STATUS);
    }
 
Example 15
Project: DeutschSim   File: GUI.java   View source code 6 votes vote down vote up
private void add_item_about(final JMenu help_menu) {
	JMenuItem item_about = new JMenuItem(new AbstractAction("About"){
		private static final long serialVersionUID = -8311117685045905144L;

		@Override
		public void actionPerformed(ActionEvent arg0) {
			final String text = "DeutschSim by Qwertygid, 2017\n\n" +
					"https://github.com/QwertygidQ/DeutschSim";
			
			// TODO add a logo
			JOptionPane.showMessageDialog(frame, text,
					"About", JOptionPane.INFORMATION_MESSAGE);
		}
	});
	help_menu.add(item_about);
}
 
Example 16
Project: Logisim   File: ProjectLibraryActions.java   View source code 6 votes vote down vote up
public static void doUnloadLibraries(Project proj) {
	LogisimFile file = proj.getLogisimFile();
	ArrayList<Library> canUnload = new ArrayList<Library>();
	for (Library lib : file.getLibraries()) {
		String message = file.getUnloadLibraryMessage(lib);
		if (message == null)
			canUnload.add(lib);
	}
	if (canUnload.isEmpty()) {
		JOptionPane.showMessageDialog(proj.getFrame(), Strings.get("unloadNoneError"),
				Strings.get("unloadErrorTitle"), JOptionPane.INFORMATION_MESSAGE);
		return;
	}
	LibraryJList list = new LibraryJList(canUnload);
	JScrollPane listPane = new JScrollPane(list);
	int action = JOptionPane.showConfirmDialog(proj.getFrame(), listPane, Strings.get("unloadLibrariesDialogTitle"),
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
	if (action == JOptionPane.OK_OPTION) {
		Library[] libs = list.getSelectedLibraries();
		if (libs != null)
			proj.doAction(LogisimFileActions.unloadLibraries(libs));
	}
}
 
Example 17
Project: SkyDocs   File: ProjectsFrame.java   View source code 6 votes vote down vote up
/**
 * Saves the projects history.
 */

public final void saveHistory() {
	try {
		final StringBuilder builder = new StringBuilder();
		for(int i = 0; i < projectsModel.size(); i++) {
			builder.append(projectsModel.getElementAt(i) + System.lineSeparator());
		}
		Files.write(builder.toString(), new File(Utils.getParentFolder(), Constants.FILE_GUI_HISTORY), StandardCharsets.UTF_8);
	}
	catch(final Exception ex) {
		ex.printStackTrace(guiPrintStream);
		ex.printStackTrace();
		JOptionPane.showMessageDialog(ProjectsFrame.this, String.format(Constants.GUI_DIALOG_ERROR_MESSAGE, ex.getMessage()), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 18
Project: Java-Air-Reservation   File: ChooseSeat.java   View source code 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JDesktopPane desktopPane = getDesktopPane();
    int class_ = Integer.parseInt(jComboBox2.getSelectedItem().toString());
    LegClasses lc = new LegClasses(fl.getLeg_no(), class_);
    if (!lc.isExist()) {
        JOptionPane.showMessageDialog(rootPane, "Error: Selected Flight doesnt have that class type");
    } else {
        float amount = lc.getPrice();
        Tickets tk = new Tickets();
        tk.setLeg_no(fl.getLeg_no());
        tk.setClass_(class_);
        tk.setPass_no(cus.getPass_no());
        tk.setSeat_no(Integer.parseInt(jComboBox1.getSelectedItem().toString()));
        if (!tk.save()) {
            JOptionPane.showMessageDialog(rootPane, "Error: Could not reserve ticket");
        } else {
            Payment p = new Payment(cus.getPass_no(), amount);
            desktopPane.add(p);
            p.setVisible(true);
            this.dispose();
        }
    }
}
 
Example 19
Project: DigitRecognizer   File: PredictPanel.java   View source code 6 votes vote down vote up
private void startPrediction(BufferedImage im)
{
    Thread t = new Thread(() ->
    {
        DRowVector in = DigitManipulator.getAnnInput(im, (x) -> execOnEvtQueue(() -> drawPanel.setImage(x)), 500);
        execOnEvtQueue(() -> drawPanel.setImage(DigitManipulator.vectorToImage(in)));

        NeuralNetwork net = window.getNet();
        if(net.getInputSize() != 784)
        {
            JOptionPane.showMessageDialog(window, "Current Neural Network has wrong input size. Expected:784, Actual:"
                                                  + net.getInputSize(), "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }
        if(net.getOutputSize() != 10)
        {
            JOptionPane.showMessageDialog(window, "Current Neural Network has wrong output size. Expected:10, Actual:"
                                                  + net.getOutputSize(), "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }

        DRowVector result = net.feedForward(in);
        execOnEvtQueue(() -> setValues(result.toArray()));
    });
    t.start();
}
 
Example 20
Project: Java-Air-Reservation   File: Login.java   View source code 6 votes vote down vote up
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        JDesktopPane desktopPane = getDesktopPane();
        String user = jTextField3.getText();
        String pass = new String(jPasswordField2.getPassword());
        Admin a = new Admin();

        if (a.adminLogin(user, pass)) {
            Adminlogin al = new Adminlogin();
            desktopPane.add(al);
            al.setVisible(true);
            this.dispose();
        } else {
            JOptionPane.showMessageDialog(rootPane, "Error: Username or password incorrect");
        }
    }
 
Example 21
Project: xdman   File: XDMMainWindow.java   View source code 6 votes vote down vote up
private void refreshLink() {
	int index = table.getSelectedRow();
	if (index < 0) {
		showMessageBox(getString("NONE_SELECTED"), getString("DEFAULT_TITLE"), JOptionPane.ERROR_MESSAGE);
		return;
	}
	DownloadListItem item = list.get(index);
	if (item != null) {
		if (item.state != IXDMConstants.COMPLETE && item.mgr == null) {
			String url = XDMUtil.isNullOrEmpty(item.referer) ? item.url : item.referer;
			url = RefreshLinkDlg.showDialog(this, url);
			if (url != null) {
				item.url = url;
				model.fireTableRowsUpdated(index, index);
				list.downloadStateChanged();
			}
		} else {
			showMessageBox(getString("DWN_ACTIVE_OR_FINISHED"), getString("DEFAULT_TITLE"),
					JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
Example 22
Project: jaer   File: StereoRecorder.java   View source code 6 votes vote down vote up
public void doDepthViewer() {
    try {
        System.load(System.getProperty("user.dir") + "\\jars\\openni2\\OpenNI2.dll");

        // initialize OpenNI
        OpenNI.initialize();

        List<DeviceInfo> devicesInfo = OpenNI.enumerateDevices();
        if (devicesInfo.isEmpty()) {
            JOptionPane.showMessageDialog(null, "No device is connected", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        Device device = Device.open(devicesInfo.get(0).getUri());

        depthViewerThread = new SimpleDepthCameraViewerApplication(device);
        depthViewerThread.start();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 23
Project: aulas   File: Media.java   View source code 6 votes vote down vote up
public static void main(String[] args) throws IOException {
	
	String nota1, nota2;
	double media, n1, n2;
	
	nota1 = JOptionPane.showInputDialog
	("Digite a primeira nota: ");
	
	n1 = Double.parseDouble(nota1);
	nota2 = JOptionPane.showInputDialog
	("Digite a segunda nota: ");
	
	n2 = Double.parseDouble(nota2);
	media = (n1+n2)/2;
	
	JOptionPane.showMessageDialog
	(null,"A media aritmetica " + media);
	System.exit(0);
}
 
Example 24
Project: VASSAL-src   File: GameState.java   View source code 6 votes vote down vote up
protected boolean checkForOldSaveFile(File f) {
  if (f.exists()) {
    // warn user if overwriting a save from an old version
    final AbstractMetaData md = MetaDataFactory.buildMetaData(f);
    if (md != null && md instanceof SaveMetaData) {
      if (Info.hasOldFormat(md.getVassalVersion())) {
        return Dialogs.showConfirmDialog(
          GameModule.getGameModule().getFrame(),
          Resources.getString("Warning.save_will_be_updated_title"),
          Resources.getString("Warning.save_will_be_updated_heading"),
          Resources.getString(
            "Warning.save_will_be_updated_message",
            f.getPath(),
            "3.2"
          ),
            JOptionPane.WARNING_MESSAGE,
          JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION;
      }
    }
  }

  return true;
}
 
Example 25
Project: codigo3   File: Vista.java   View source code 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
{//GEN-HEADEREND:event_jButton1ActionPerformed
    // TODO add your handling code here:

    ultimoIp= VM.ultimoIP();
    if(VM.getIP() != ultimoIp || VM.pilasVacias())
    {
        VM.interpretarCuadrupla(VM.getCuadrupla(VM.getIP()));
        actualizarVista();
    }
    else
    {
        JOptionPane.showMessageDialog(null, "el programa finalizó", "Mensaje", JOptionPane.ERROR_MESSAGE);
    }

    ip.setText("IP = "+ VM.getIP());
    
    try
    {
        tablaCuadruplas.setRowSelectionInterval(VM.getIP(), VM.getIP());
    } catch (Exception e)
    {
    }

}
 
Example 26
Project: ObsidianSuite   File: EntitySetupController.java   View source code 6 votes vote down vote up
public void attemptParent(PartObj parent, PartObj child)
{
	if(parent.getName().equals(child.getName()))
	{
		JOptionPane.showMessageDialog(frame, "Cannot parent a part to itself.", "Parenting issue", JOptionPane.ERROR_MESSAGE);
	} 
	else if (!AnimationParenting.areUnrelated(child, parent) || !AnimationParenting.areUnrelated(parent, child))
	{
		JOptionPane.showMessageDialog(frame, "Parts are already related.", "Parenting issue", JOptionPane.ERROR_MESSAGE);
	}
	else if(child.getParent() != null)
	{
		Object[] options = {"OK", "Remove parenting"};
		int n = JOptionPane.showOptionDialog(frame, child.getDisplayName() + " already has a parent.", "Parenting issue",
				JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,null,options,options[0]);
		if(n == 1)
		{
			parent(null,child);
		}
	}
	else
		parent(parent, child);
}
 
Example 27
Project: Progetto-C   File: Packer.java   View source code 6 votes vote down vote up
/**
 * Save the sprite sheet
 */
private void save() {
	int resp = saveChooser.showSaveDialog(this);
	if (resp == JFileChooser.APPROVE_OPTION) {
		File out = saveChooser.getSelectedFile();
		
		ArrayList list = new ArrayList();
		for (int i=0;i<sprites.size();i++) {
			list.add(sprites.elementAt(i));
		}
		
		try {
			int b = ((Integer) border.getValue()).intValue();
			pack.packImages(list, twidth, theight, b, out);
		} catch (IOException e) {
			// shouldn't happen 
			e.printStackTrace();
			JOptionPane.showMessageDialog(this, "Failed to write output");
		}
	}
}
 
Example 28
Project: sbc-qsystem   File: FAdmin.java   View source code 6 votes vote down vote up
private void miAddSectionActionPerformed(
    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddSectionActionPerformed
    final String secName = (String) JOptionPane
        .showInputDialog(this, getLocaleMessage("admin.add_section_name.message"),
            getLocaleMessage("admin.section.title"), 3, null, null, "");
    if (secName == null) {
        return;
    }
    if (secName.isEmpty()) {
        JOptionPane.showMessageDialog(this, getLocaleMessage("admin.section_empty.error"),
            getLocaleMessage("admin.section.title"), JOptionPane.ERROR_MESSAGE);
        return;
    }

    if (ServerProps.getInstance().getSection(secName) != null) {
        JOptionPane.showMessageDialog(this, getLocaleMessage("admin.section_dublicate.error"),
            getLocaleMessage("admin.section.title"), JOptionPane.ERROR_MESSAGE);
        return;
    }

    final ServerProps.Section section = ServerProps.getInstance().addSection(secName);
    sectionsList
        .setModel(new DefaultComboBoxModel(ServerProps.getInstance().getSections().toArray()));
    sectionsList.setSelectedValue(section, true);
}
 
Example 29
Project: ramus   File: ChartView.java   View source code 6 votes vote down vote up
@Override
public JComponent createComponent() {
    ChartDataPlugin plugin = chartDataFramework
            .getChartDataPlugin(chartSource.getChartType());
    try {
        chartPanel = new ChartPanel(plugin.createChart(element));
        chartPanel.setPopupMenu(null);
    } catch (ChartNotSetupedException e) {
        JOptionPane.showMessageDialog(framework.getMainFrame(),
                ChartResourceManager.getString("Error.chartNotSetuped"));
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                close();
            }
        });
        return new JPanel();
    }
    return chartPanel;
}
 
Example 30
Project: alevin-svn2   File: RemoveConstraintDialog.java   View source code 6 votes vote down vote up
@Override
protected void doAction() {
	if (comboBox.getSelectedIndex() > 0) {
		try {
			// get the selected constraint.
			AbstractConstraint cons = entity.get().get(
					comboBox.getSelectedIndex() - 1);
			if (!entity.remove(cons)) {
				JOptionPane.showMessageDialog(this,
						"Cannot remove the last constraint of an entity.",
						"Error", JOptionPane.ERROR_MESSAGE);
				throw new AssertionError("Removing constraint failed.");
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new AssertionError(
					"An error occured while trying to remove a constraint.");
		}
	}
}
 
Example 31
Project: jdk8u-jdk   File: J2DBench.java   View source code 6 votes vote down vote up
public static boolean saveOrDiscardLastResults() {
    if (lastResults != null) {
        int ret = JOptionPane.showConfirmDialog
            (guiFrame,
             "The results of the last test will be "+
             "discarded if you continue!  Do you want "+
             "to save them?",
             "Discard last results?",
             JOptionPane.YES_NO_CANCEL_OPTION);
        if (ret == JOptionPane.CANCEL_OPTION) {
            return false;
        } else if (ret == JOptionPane.YES_OPTION) {
            if (saveResults()) {
                lastResults = null;
            } else {
                return false;
            }
        }
    }
    return true;
}
 
Example 32
Project: cuttlefish   File: DBToolbar.java   View source code 5 votes vote down vote up
private void settingsButtonEvent() {
	String sleepTimeStr = (String)JOptionPane.showInputDialog(networkPanel, "Enter time between updates in milliseconds", "Time between updates", JOptionPane.QUESTION_MESSAGE, null, null, sleepTime);
	if(sleepTimeStr != null) {
		try {
			sleepTime = Long.parseLong(sleepTimeStr);
		} catch (NumberFormatException ex) {
			JOptionPane.showMessageDialog(networkPanel, "The value that you enter is not an integer", "Incorrect input", JOptionPane.WARNING_MESSAGE, null);
		}
	}
}
 
Example 33
Project: JAddOn   File: JTreeUtils.java   View source code 5 votes vote down vote up
private static void editCategory(Component frame, String path, File folder_categories) {
    String input = JOptionPane.showInputDialog(frame, StaticStandard.getLang().getLang("new_category_name", "New category name") + ":", path);
    if (input != null && !input.isEmpty() && !input.equals(path)) {
        File folder_old = getFolderFromCategory(path, folder_categories);
        input = input.replaceAll(File.separator + File.separator, ".");
        File folder = getFolderFromCategory(input, folder_categories);
        folder_old.renameTo(folder);
        StaticStandard.log("Edited category: \"" + path + "\" to \"" + input + "\"");
        folder.mkdirs();
    }
}
 
Example 34
Project: MonitorYourLAN   File: Historic.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) 
{
	if(e.getSource() == this.updateButton) 
	{
		if(datePicker1.getJFormattedTextField().getText().equals("") == false && datePicker2.getJFormattedTextField().getText().equals("") == false)
		{
			this.displaySPs(thisSP, datePicker1.getJFormattedTextField().getText(), datePicker2.getJFormattedTextField().getText());
		}
		else
		{
			JOptionPane.showMessageDialog(this,"La p�riode s�lectionn�e comporte des erreurs. \n V�rifiez votre saisie.","P�riode non d�finie",JOptionPane.ERROR_MESSAGE);
		}
	}		
}
 
Example 35
Project: java-swing-template   File: Dashboard.java   View source code 5 votes vote down vote up
public void checkForUpdates() {
    if (new File("updater.exe").exists()) {
        Thread th = new Thread(new Runnable() {
            @Override
            public void run() {
                Utilities.runShellCommand(Updator.COMMAND_UPDATECHECK);
            }
        });
        th.start();
    } else {
        JOptionPane.showMessageDialog(this, "Your software version is not equipped with the automatic update funcationality.\nPlease install the latest software to get updater facility.\nThank you.", "Outdated software", JOptionPane.INFORMATION_MESSAGE);
    }
}
 
Example 36
Project: jmt   File: ModelLoader.java   View source code 5 votes vote down vote up
/**
 * Overrides default method to provide a warning if saving over an existing file
 */
@Override
public void approveSelection() {
	// Gets the chosen file name
	String name = getSelectedFile().getName();
	String parent = getSelectedFile().getParent();
	if (getDialogType() == OPEN_DIALOG) {
		super.approveSelection();
	}
	if (getDialogType() == SAVE_DIALOG) {
		boolean hasValidExtension = false;
		String[] extensions = defaultSaveFilter.getExtensions();
		for (String e : extensions) {
			if (name.toLowerCase().endsWith(e)) {
				hasValidExtension = true;
				break;
			}
		}
		if (!hasValidExtension) {
			name += extensions[0];
			setSelectedFile(new File(parent, name));
		}
		if (getSelectedFile().exists()) {
			int resultValue = JOptionPane.showConfirmDialog(this, "<html>File <font color=#0000ff>" + name
					+ "</font> already exists in this folder.<br>Do you want to replace it?</html>", "JMT - Warning",
					JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
			if (resultValue == JOptionPane.OK_OPTION) {
				getSelectedFile().delete();
				super.approveSelection();
			}
		} else {
			super.approveSelection();
		}
	}
}
 
Example 37
Project: jaer   File: PanTiltFrame.java   View source code 5 votes vote down vote up
private void btnHaltActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHaltActionPerformed
    if (panTiltControl == null || panTiltControl.isConnected() == false) {
        JOptionPane.showMessageDialog(null, "Not Connected to Pan-Tilt-Unit", "Not Connected", JOptionPane.OK_CANCEL_OPTION);
    } else {
        panTiltControl.halt();
    }
}
 
Example 38
Project: geomapapp   File: Janus.java   View source code 5 votes vote down vote up
public static String showOpenDialog(java.awt.Component comp) {
	if( jdial==null )jdial = new JanusDialog();
	int ok = jdial.showDialog(comp);
	if( ok==JOptionPane.CANCEL_OPTION )return null;
	Janus j = new Janus(jdial.getDataID(), jdial.getLeg(), jdial.getSite(), jdial.getHole());
	return j.urlString();
}
 
Example 39
Project: Snake-Ladder   File: Main.java   View source code 5 votes vote down vote up
public void Paint(int x, int y){
	//System.out.println("Paint from: "+x+" to "+y);
	new Thread() {
        @Override
        public void run() {
            try {
            	//btnDice.setEnabled(false);
            	//btnDice.setVisible(false);
            	Thread.sleep(500);
            	for(int i=x; i<y; i++){
            		//System.out.println("Paint Player after: "+p);
            		RemoveImage(i);
            		Thread.sleep(50);
	            	SetImage(i+1,player);
	                Thread.sleep(500);
            	}
            	//btnDice.setVisible(true);
            	//btnDice.setEnabled(true);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
                JOptionPane.showMessageDialog(null, "Paint timer error!");
            }

        }
    }.start();
    
    
   ActionListener taskPerformer = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
                

        }
    };
    javax.swing.Timer t = new javax.swing.Timer(1000, taskPerformer);
    t.setRepeats(false);
    t.start();
}
 
Example 40
Project: litiengine   File: Program.java   View source code 5 votes vote down vote up
private static boolean exit() {
  String resourceFile = EditorScreen.instance().getCurrentResourceFile() != null ? EditorScreen.instance().getCurrentResourceFile() : "";
  int n = JOptionPane.showConfirmDialog(
      null,
      Resources.get("hud_saveProjectMessage") + "\n" + resourceFile,
      Resources.get("hud_saveProject"),
      JOptionPane.YES_NO_CANCEL_OPTION);

  if (n == JOptionPane.YES_OPTION) {
    EditorScreen.instance().save(false);
  }

  return n != JOptionPane.CANCEL_OPTION;
}