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


Java JDialog.pack方法代码示例

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


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

示例1: actionPerformed

import javax.swing.JDialog; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
// FIXME: don't create a new one each time!
      final File logfile = new File(Info.getHomeDir(), "errorLog");
      final LogPane lp = new LogPane(logfile);

// FIXME: this should have its own key. Probably keys should be renamed
// to reflect what they are labeling, e.g., Help.show_error_log_menu_item,
// Help.error_log_dialog_title.
      final JDialog d =
        new JDialog(frame, Resources.getString("Help.error_log"));
      d.setLayout(new MigLayout("insets 0"));
      d.add(new JScrollPane(lp), "grow, push, w 500, h 600");

      d.setLocationRelativeTo(frame);
      d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

      d.pack();
      d.setVisible(true);
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:ModuleManagerWindow.java

示例2: showProgress

import javax.swing.JDialog; //导入方法依赖的package包/类
public static ProgressDialog showProgress(Component parent, String message)
{
	JDialog d = ComponentHelper.createJDialog(parent);
	ProgressDialog p = new ProgressDialog(d);

	d.getRootPane().setWindowDecorationStyle(JRootPane.INFORMATION_DIALOG);
	d.setResizable(false);
	d.setContentPane(p);
	d.setTitle(message);
	d.pack();

	d.setLocationRelativeTo(parent);
	d.setVisible(true);

	return p;
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:ProgressDialog.java

示例3: initDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
void initDialog() {
	dialog = new JDialog( 
//	dialog = new JFrame(
		(JFrame)grid.getTopLevelAncestor(), 
		"Grid Rendering Tools");
	tabs = new JTabbedPane(JTabbedPane.TOP);
	tabs.add( "Rendering", this);
	dialog.getContentPane().add(tabs);
	JLabel label = new JLabel("Rendering tools are new "
			+"and still under development - "
			+"use with caution");
	dialog.getContentPane().add(label, "South");
	dialog.pack();
	tabs.add( "3D", pers);
	tabs.addChangeListener( new ChangeListener() {
		public void stateChanged(ChangeEvent e) {
			tabChange();
		}
	});
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:21,代码来源:RenderTools.java

示例4: showLicense

import javax.swing.JDialog; //导入方法依赖的package包/类
/**
 * Brings up a dialog that displays the license.
 */
private void showLicense() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.license.title"));
    final JEditorPane text = new JEditorPane();
    try {
        URL url = getClass().getResource("GNULicense.txt");

        text.setPage(url);
    } catch (Exception el) {
        text.setText(resources.getString("dialog.license.error"));
    }
    text.setEditable(false);
    JScrollPane sp = new JScrollPane(text);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:22,代码来源:WorldFrame.java

示例5: doTest

import javax.swing.JDialog; //导入方法依赖的package包/类
private static void doTest(Runnable action) {
    String description
            = " A print dialog will be shown.\n "
            + " Please select Pages within Page-range.\n"
            + " and enter From 2 and To 3. Then Select OK.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("JobAttribute Updation Test");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");

    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:JobAttrUpdateTest.java

示例6: manageRefactorings

import javax.swing.JDialog; //导入方法依赖的package包/类
private synchronized void manageRefactorings(boolean single) {
    HintsPanel panel;
    if (single) {
        panel = new HintsPanel((HintMetadata) singleRefactoringCombo.getSelectedItem(), null, cpBased);
    } else {
        panel = new HintsPanel((Configuration) configurationCombo.getSelectedItem(), cpBased);
    }
    DialogDescriptor descriptor = new DialogDescriptor(panel, NbBundle.getMessage(InspectAndRefactorPanel.class, "CTL_ManageRefactorings"), true, new Object[]{}, null, 0, null, null);
    
    JDialog dialog = (JDialog) DialogDisplayer.getDefault().createDialog(descriptor);
    dialog.validate();
    dialog.pack();
    dialog.setVisible(true);
    if (panel.isConfirmed()) {
        if (this.configurationRadio.isSelected()) {
            Configuration selectedConfiguration = panel.getSelectedConfiguration();
            if (selectedConfiguration != null) {
                configurationCombo.setSelectedItem(selectedConfiguration);
            }
        } else {
            HintMetadata selectedHint = panel.getSelectedHint();
            if (selectedHint != null) {
                if (panel.hasNewHints()) {
                    singleRefactoringCombo.setModel(new InspectionComboModel((allHints = Utilities.getBatchSupportedHints(cpBased)).keySet()));
                }
                singleRefactoringCombo.setSelectedItem(selectedHint);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:InspectAndRefactorPanel.java

示例7: main

import javax.swing.JDialog; //导入方法依赖的package包/类
public static void main(String[] ignore) {
    boolean[] adv = {false, true};
    for (int j = 0; j < adv.length; j++) {
        JDialog dlg = new JDialog((Frame) null, "advancedMode=" + adv[j], false); // NOI18N
        dlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        TargetMappingPanel panel = new TargetMappingPanel(adv[j]);
        panel.setTargetNames(new ArrayList<String>(Arrays.asList("build", "clean", "test")), true); // NOI18N
        dlg.getContentPane().add(panel);
        dlg.pack();
        dlg.setSize(700, 500);
        dlg.setVisible(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TargetMappingPanel.java

示例8: createDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
private JDialog createDialog(Component parent) {
    Frame frame = parent instanceof Frame ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);

    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);

    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:37,代码来源:FontChooser.java

示例9: mapaLabelMouseClicked

import javax.swing.JDialog; //导入方法依赖的package包/类
private void mapaLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mapaLabelMouseClicked
    JDialog dialog = new JDialog();
    dialog.setUndecorated(true);
    JLabel label = new JLabel(imagemIcone);
    dialog.setLocationRelativeTo(this);
    dialog.setUndecorated(false);
    dialog.add(label);
    dialog.pack();
    dialog.setVisible(true);
}
 
开发者ID:lucas-dolsan,项目名称:tcc-rpg,代码行数:11,代码来源:TelaJogo.java

示例10: createAndShowTestDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
private static void createAndShowTestDialog(String description,
        String failMessage, Runnable action) {
    final JDialog dialog = new JDialog();
    dialog.setTitle("Test: " + (++testCount));
    dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Print Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        throw new RuntimeException(failMessage);
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:ImageableAreaTest.java

示例11: createDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
protected JDialog createDialog(Component parent)
{
    Frame frame = parent instanceof Frame ? (Frame) parent
        : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, Editor.fromConfiguracao.getValor("Inspector.obj.font.selfonte"), true);

    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);

    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:38,代码来源:JFontChooser.java

示例12: actionPerformed

import javax.swing.JDialog; //导入方法依赖的package包/类
public void actionPerformed( final ActionEvent e ) {
    String command = e.getActionCommand();

    if ( COMMAND_OK.equals( command ) ) {
        // Call the OK option listener
        ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
            public Object run() {
                okOptionListener.actionPerformed( e ); // XXX maybe create new event
                actionPerformed(e, categories);
                return null;
            }
        });
        
        final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data_progress"));
        JComponent component = ProgressHandleFactory.createProgressComponent(handle);
        Frame mainWindow = WindowManager.getDefault().getMainWindow();
        final JDialog dialog = new JDialog(mainWindow, 
                NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data"), true);
        SavingProjectDataPanel panel = new SavingProjectDataPanel(component);
        
        dialog.getContentPane().add(panel);
        dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        dialog.pack();
        
        Rectangle bounds = mainWindow.getBounds();
        int middleX = bounds.x + bounds.width / 2;
        int middleY = bounds.y + bounds.height / 2;
        Dimension size = dialog.getPreferredSize();
        dialog.setBounds(middleX - size.width / 2, middleY - size.height / 2, size.width, size.height);
        
        // Call storeListeners out of AWT EQ
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                try {
                    ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
                        @Override
                        public Object run() {
                            FileUtil.runAtomicAction(new Runnable() {
                                @Override
                                public void run() {
                            handle.start();
                            if (storeListener != null) {
                                storeListener.actionPerformed(e);
                            }
                            storePerformed(e, categories);
                            // #97998 related
                            saveModifiedProject();
                                }
                            });
                            return null;
                        }
                    });
                } finally {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            dialog.setVisible(false);
                            dialog.dispose();
                        }
                    });
                }
            }
        });
        
        dialog.setVisible(true);
        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:CustomizerDialog.java

示例13: doTest

import javax.swing.JDialog; //导入方法依赖的package包/类
private static void doTest(Runnable action) {
    String description =
      "JTable with rows will be displayed along with scrollbar.\n"
       + "Scroll the table. Verify no arifacts are shown and rows.\n"
       + " are correctly displayed.";
    final JDialog dialog = new JDialog();
    dialog.setTitle("ScrollArtifactTest ");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Create Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        if (frame != null) {
            frame.setVisible(false);
            frame.dispose();
        }
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        if (frame != null) {
            frame.setVisible(false);
            frame.dispose();
        }
        throw new RuntimeException("Scrollbar artifact shown");
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:JTableScrollTest.java

示例14: main

import javax.swing.JDialog; //导入方法依赖的package包/类
public static void main(String[] args) {
	JDialog dlg = new JDialog();
	dlg.add(new ImageBox("http://www.google.com/logos/winter_holiday05_1.gif"));
	dlg.pack();
	dlg.setVisible(true);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:ImageBox.java

示例15: loadExcelURL

import javax.swing.JDialog; //导入方法依赖的package包/类
public void loadExcelURL(String c){
	try {
		URL url = URLFactory.url(c);
		int length = url.openConnection().getContentLength();
		JDialog d = new JDialog((Frame)null, "Loading File");
		JPanel p = new JPanel(new BorderLayout());
		p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
		d.setLocationRelativeTo(null);
		JProgressBar pb = new JProgressBar(0,length);
		p.add(new JLabel("Loading " + (length / 1000) + " kb file"), BorderLayout.NORTH);
		p.add(pb);
		d.getContentPane().add(p);
		d.pack();
		d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		d.setVisible(true); 
		d.setAlwaysOnTop(true);
		Workbook wb = Workbook.getWorkbook(url.openStream());
		if (wb.getNumberOfSheets()==0) return;
		Sheet s = wb.getSheet(0);
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.getRows(); i++) {
			for (int j = 0; j < s.getColumns(); j++)
			{
					if (s.getCell(j, i).getType() == CellType.NUMBER && !s.getCell(j, i).getContents().matches("\\d*")) {
						sb.append(((NumberCell)s.getCell(j, i)).getValue()+"\t");	
						pb.setValue(pb.getValue() + 16);
						pb.repaint();
					}
					else {
						pb.setValue(pb.getValue() + 2*s.getCell(j, i).getContents().length()+36);
						pb.repaint();
						sb.append(s.getCell(j, i).getContents()+"\t");
					}
					//if (j<s.getRows()-1) sb.append(s.getCell(j, i).getContents()+"\t");
				//else sb.append(s.getCell(j, i).getContents()+"\t");
			}
			sb.append("\n");
		}
		name.setText(url.getFile().substring(url.getFile().lastIndexOf('/')+1, url.getFile().lastIndexOf('.')));
		input.setText(sb.toString());
		wb.close();
		d.dispose();
	} catch (Exception e) {
		JOptionPane.showMessageDialog(null, "Error reading URL:\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
		return;
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:48,代码来源:OtherDBInputDialog.java


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