当前位置: 首页>>代码示例>>Java>>正文


Java JOptionPane类代码示例

本文整理汇总了Java中javax.swing.JOptionPane的典型用法代码示例。如果您正苦于以下问题:Java JOptionPane类的具体用法?Java JOptionPane怎么用?Java JOptionPane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JOptionPane类属于javax.swing包,在下文中一共展示了JOptionPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setNumberOfClasses

import javax.swing.JOptionPane; //导入依赖的package包/类
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();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:26,代码来源:ClassesPanel.java

示例2: loadHistory

import javax.swing.JOptionPane; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:Skyost,项目名称:SkyDocs,代码行数:25,代码来源:ProjectsFrame.java

示例3: main

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
	}
 
开发者ID:alexferreiradev,项目名称:3way_laboratorios,代码行数:20,代码来源:MaiorNumero.java

示例4: actionPerformed

import javax.swing.JOptionPane; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:luandr,项目名称:ProjetoERP,代码行数:22,代码来源:ClienteViewActionListener.java

示例5: InsertKhachHang

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
    }
}
 
开发者ID:GroupKT,项目名称:GroupK,代码行数:17,代码来源:KhachHangDAL.java

示例6: runScript

import javax.swing.JOptionPane; //导入依赖的package包/类
/**
 * 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
        );
    }
}
 
开发者ID:jachinte,项目名称:grade-buddy,代码行数:25,代码来源:MainWindow.java

示例7: openGD

import javax.swing.JOptionPane; //导入依赖的package包/类
/**
 * @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));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:26,代码来源:EditorActions.java

示例8: getTemplates

import javax.swing.JOptionPane; //导入依赖的package包/类
/**
 * 
 * @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;
}
 
开发者ID:cetic,项目名称:SimQRI,代码行数:23,代码来源:WorkspaceManager.java

示例9: executeCommand

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:InviteCommand.java

示例10: GeometricInteractiveVDSLayerModel

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:25,代码来源:GeometricInteractiveVDSLayerModel.java

示例11: openFile

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
	}
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:19,代码来源:XDMMainWindow.java

示例12: _printCrossPlatform

import javax.swing.JOptionPane; //导入依赖的package包/类
/** 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);
        }
    }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:21,代码来源:PlotFrame.java

示例13: imprevisto

import javax.swing.JOptionPane; //导入依赖的package包/类
/**
 * 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);
        }
    });
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-N,代码行数:22,代码来源:GuiInformationSale.java

示例14: errorMessage

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:20,代码来源:CommonSwing.java

示例15: add_item_about

import javax.swing.JOptionPane; //导入依赖的package包/类
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);
}
 
开发者ID:QwertygidQ,项目名称:DeutschSim,代码行数:17,代码来源:GUI.java


注:本文中的javax.swing.JOptionPane类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。