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


Java JPanel.add方法代码示例

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


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

示例1: main

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * Simple test case for the gradient painter
 * 
 * @param argv The arguments supplied at the command line
 */
public static void main(String[] argv) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createTitledBorder("Gradient"));
	panel.setLayout(null);
	frame.setContentPane(panel);
		
	GradientEditor editor = new GradientEditor();
	editor.setBounds(10,15,270,100);
	panel.add(editor);
	frame.setSize(300,200);
	
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	frame.setVisible(true);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:26,代码来源:GradientEditor.java

示例2: askForNewKey

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * Prompts the user for a new command key
 * @return The new command key or null
 */
protected static CMD askForNewKey(){
	JPanel form = new JPanel(new GridLayout(3, 1));
	JLabel txt = new JLabel("Press a key and click 'OK'");
	JPanel a = new JPanel(new BorderLayout());
	JPanel c = new JPanel(new BorderLayout());
	JCheckBox ctrl = new JCheckBox();
	JCheckBox alt = new JCheckBox();
	c.add(ctrl, BorderLayout.LINE_START);
	c.add(new JLabel("Ctrl"), BorderLayout.CENTER);
	a.add(alt, BorderLayout.LINE_START);
	a.add(new JLabel("Alt"), BorderLayout.CENTER);
	form.add(txt);
	form.add(c);
	form.add(a);
	if(JOptionPane.showOptionDialog(Main.frame.isVisible() ? Main.frame : null, form, "Keys per second", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[]{"OK", "Cancel"}, 0) == 0){
		if(Main.lastevent == null){
			return null;
		}
		CMD cmd = new CMD(Main.lastevent.getKeyCode(), isAltDown || alt.isSelected(), isCtrlDown || ctrl.isSelected());
		if(JOptionPane.showOptionDialog(Main.frame.isVisible() ? Main.frame : null, "Set command key to: " + cmd.toString(), "Keys per second", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[]{"OK", "Cancel"}, 0) == 0){
			return cmd;
		}
	}
	return null;
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:30,代码来源:CommandKeys.java

示例3: actionPerformed

import javax.swing.JPanel; //导入方法依赖的package包/类
public void actionPerformed (ActionEvent evt) {
	centerPanel = new JPanel(new FlowLayout());
					
	iterationsLabel = new JLabel("Iterations");		
	iterationsField = new JTextField((new Integer(VRProblemModel.DEFAULT_LSD_ITERATIONS)).toString(), 4);

	lambdaLabel = new JLabel("Lambda size");		
	lambdaField = new JTextField((new Integer(VRProblemModel.DEFAULT_LAMBDA)).toString(), 4);
	
	globalBestSearchBox = new JCheckBox("Global Best Search");
	badMovesBox = new JCheckBox("Accept Bad Moves");

	centerPanel.add(iterationsLabel);
	centerPanel.add(iterationsField);
	centerPanel.add(lambdaLabel);
	centerPanel.add(lambdaField);			
	centerPanel.add(globalBestSearchBox);
	centerPanel.add(badMovesBox);	
			
	// Add demands table in Center Panel		
	centerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	centerPanel.setBackground(Color.getColor("202,198,202"));

	// Add panels in Main Panel
	getContentPane().add(centerPanel,BorderLayout.CENTER);					
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:27,代码来源:LocalSearchSettings.java

示例4: createNamePanel

import javax.swing.JPanel; //导入方法依赖的package包/类
protected JPanel createNamePanel(final JPanel panel)
{
	final JLabel nameLabel = new JLabel(CurrentLocale.get("com.tle.admin.workflow.editor.nodeeditor.name"));

	nameField = new I18nTextField(BundleCache.getLanguages());

	reject = new JCheckBox(CurrentLocale.get("com.tle.admin.workflow.editor.nodeeditor.reject"));

	final int height1 = nameLabel.getPreferredSize().height;
	final int height2 = nameField.getPreferredSize().height;
	final int height3 = reject.getPreferredSize().height;

	final int[] rows = {height1, height2, height3};
	final int[] cols = {300};

	panel.setLayout(new TableLayout(rows, cols));

	panel.add(nameLabel, new Rectangle(0, 0, 1, 1));
	panel.add(nameField, new Rectangle(0, 1, 1, 1));
	panel.add(reject, new Rectangle(0, 2, 1, 1));

	changeDetector.watch(nameField);
	changeDetector.watch(reject);

	return panel;
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:NodeEditor.java

示例5: WindowOptions

import javax.swing.JPanel; //导入方法依赖的package包/类
public WindowOptions(PreferencesFrame window) {
	super(window);

	checks = new PrefBoolean[] {
			new PrefBoolean(AppPreferences.SHOW_TICK_RATE, Strings.getter("windowTickRate")), };

	toolbarPlacement = new PrefOptionList(AppPreferences.TOOLBAR_PLACEMENT, Strings.getter("windowToolbarLocation"),
			new PrefOption[] { new PrefOption(Direction.NORTH.toString(), Direction.NORTH.getDisplayGetter()),
					new PrefOption(Direction.SOUTH.toString(), Direction.SOUTH.getDisplayGetter()),
					new PrefOption(Direction.EAST.toString(), Direction.EAST.getDisplayGetter()),
					new PrefOption(Direction.WEST.toString(), Direction.WEST.getDisplayGetter()),
					new PrefOption(AppPreferences.TOOLBAR_DOWN_MIDDLE, Strings.getter("windowToolbarDownMiddle")),
					new PrefOption(AppPreferences.TOOLBAR_HIDDEN, Strings.getter("windowToolbarHidden")) });

	JPanel panel = new JPanel(new TableLayout(2));

	panel.add(toolbarPlacement.getJLabel());
	panel.add(toolbarPlacement.getJComboBox());

	setLayout(new TableLayout(1));
	for (int i = 0; i < checks.length; i++) {
		add(checks[i]);
	}
	add(panel);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:26,代码来源:WindowOptions.java

示例6: createPane

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * Used by createSimpleDialogBox and createFeatureDialogBox to create a pane
 * containing a description, a single column of radio buttons, and the Show
 * it! button.
 */
private JPanel createPane(String description, JRadioButton[] radioButtons, JButton showButton) {

    int numChoices = radioButtons.length;
    JPanel box = new JPanel();
    JLabel label = new JLabel(description);

    box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
    box.add(label);

    for (int i = 0; i < numChoices; i++) {
        box.add(radioButtons[i]);
    }

    JPanel pane = new JPanel(new BorderLayout());
    pane.add(box, BorderLayout.PAGE_START);
    pane.add(showButton, BorderLayout.PAGE_END);
    return pane;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:24,代码来源:DialogDemo.java

示例7: CourseInfoPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
public CourseInfoPanel(String course_id) throws Exception{
	//setBackground(new Color(0, 0, 0));
	setLayout(new BorderLayout(0, 0));
	setPreferredSize(new Dimension(1300,600));
	JPanel panel = new JPanel();
	panel.setPreferredSize(new Dimension(1300,50));
	//panel.setForeground(new Color(255, 255, 255));
	//panel.setBackground(new Color(139, 0, 0));
	add(panel, BorderLayout.NORTH);
	JLabel lblCourseSummary = new JLabel("COURSE SUMMARY");
	lblCourseSummary.setFont(new Font("Verdana", Font.BOLD, 25));
	lblCourseSummary.setForeground(new Color(255, 255, 255));
	panel.add(lblCourseSummary);
	JPanel panel_1 = new JPanel();
	panel_1.setBackground(Color.WHITE);//If you want a different background comment this
	//panel_1.setPreferredSize(new Dimension(1300,400));
	coDao = new CourseDAO();
	co=coDao.getCourseById(course_id);
	//System.out.println("Course Selected or not:::" + co.getCourseInfo());
	panel_1.setPreferredSize(new Dimension(1290,500));
	JXLabel jl =new JXLabel("");
	try{
		//System.out.println("Inside the try catch block");
		if(co.getCourseInfo()!=null)
			jl.setText("\n\n"+co.getCourseInfo());
	}catch(Exception e){
		e.printStackTrace();
	}
	jl.setLineWrap(true);
	jl.setFont(new Font("Geneva", Font.BOLD, 16));
	panel_1.add(jl);
	add(panel_1,BorderLayout.CENTER);
}
 
开发者ID:jtatia,项目名称:Course-Management-System,代码行数:34,代码来源:CourseInfoPanel.java

示例8: makeButtons

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * @return the button panel
 */
@Override
protected JComponent makeButtons() {
	help = new HoverHelp();
	helpLabel = help.getHelpLabel();

	helpLabel.setBorder(BorderFactory.createEtchedBorder());
	//helpLabel.setHorizontalAlignment(SwingConstants.CENTER);

	ACTION_FINISH.putValue(Action.NAME, "Solve");
	ACTION_CANCEL.putValue(Action.NAME, "Exit");

	JPanel buttons = new JPanel();

	JButton button_finish = new JButton(ACTION_FINISH);
	help.addHelp(button_finish, "Validates the system and starts the solver");
	JButton button_cancel = new JButton(ACTION_CANCEL);
	help.addHelp(button_cancel, "Exits the wizard discarding all changes");
	JButton button_next = new JButton(ACTION_NEXT);
	help.addHelp(button_next, "Moves on to the next step");
	JButton button_previous = new JButton(ACTION_PREV);
	help.addHelp(button_previous, "Goes back to the previous step");
	JButton button_help = new JButton(ACTION_HELP);
	help.addHelp(button_help, "Displays help for the current panel");
	buttons.add(button_previous);
	buttons.add(button_next);
	buttons.add(button_finish);
	buttons.add(button_cancel);
	buttons.add(button_help);

	JPanel labelbox = new JPanel();
	labelbox.setLayout(new BorderLayout());
	labelbox.add(Box.createVerticalStrut(20), BorderLayout.WEST);
	labelbox.add(helpLabel, BorderLayout.CENTER);

	Box buttonBox = Box.createVerticalBox();
	buttonBox.add(buttons);
	buttonBox.add(labelbox);
	return buttonBox;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:43,代码来源:JabaWizard.java

示例9: contrutorJanela

import javax.swing.JPanel; //导入方法依赖的package包/类
private void contrutorJanela(Evento evento){
	
	this.construtorTabelaModelItem();
	this.construtorPanelNf();
	this.construtorPanelEmitente();
	this.construtorPanelDestinatario();
	this.construtorPanelItem();
	this.contrutorPanelNff();
	this.construtorPanelControler(evento);
	

	JPanel cadastroPanel = new JPanel();
	cadastroPanel.setLayout(new BoxLayout(cadastroPanel, BoxLayout.Y_AXIS));
	cadastroPanel.add(new JLabel(" "));
	cadastroPanel.add(new JLabel(":::::NOTA FISCAL ELETRÔNICA:::::"));
	cadastroPanel.add(new JLabel(" "));
	cadastroPanel.add(cadastroPanelNf);
	cadastroPanel.add(cadastroPanelEmitente);
	cadastroPanel.add(cadastroPanelDestinatario);
	cadastroPanel.add(cadastroPanelItem);
	cadastroPanel.add(cadastroPanelNff);
	cadastroPanel.add(cadastroPanelControler);
	
	
	setLayout(new BorderLayout());
	add(cadastroPanel);
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	//cadastroFrame.setSize(500, 200);
	pack();
	setVisible(true);
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
				setEnabled(true);
		}
	});
	setEnabled(false);
}
 
开发者ID:matheusPeresDeAraujo,项目名称:20170612-NotaFIscalEletronica,代码行数:39,代码来源:FrameCadastroNf.java

示例10: createTestPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
private static JPanel createTestPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JTextArea textArea = new JTextArea(20, 20);
    textArea.setText(getLongString());
    JScrollPane scrollPane = new JScrollPane(textArea);
    panel.add(scrollPane);
    return panel;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TooMuchWheelRotationEventsTest.java

示例11: test_paneAddBackButton

import javax.swing.JPanel; //导入方法依赖的package包/类
private void test_paneAddBackButton(JPanel panel){
	panel.setLayout(null);
	ButtonBack back = new ButtonBack("����");
	panel.add(back);
	back.setBounds(ConstantsTCS.getDemoUnique().getInt_windowWidth() - 100,
			0, 95, 50);
	back.addActionListener(event->{
		cardLayout.show(panelFirst, "id_menu");
	});
}
 
开发者ID:BH2017,项目名称:snake_classic,代码行数:11,代码来源:UserInterface0.java

示例12: makeRow

import javax.swing.JPanel; //导入方法依赖的package包/类
private static JPanel makeRow(Object... cc) {
	JPanel p1 = new JPanel();
	p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS));
	for (int i = 0; i < cc.length; i++) {
		if (i > 0) p1.add(Box.createHorizontalStrut(HGAP));
		if (cc[i] instanceof Component) p1.add((Component)cc[i]);
		else p1.add(new JLabel(cc[i].toString()));
	}
	JPanel p2 = new JPanel(new BorderLayout());
	p2.add(p1, BorderLayout.LINE_START);
	return p2;
}
 
开发者ID:kreativekorp,项目名称:vexillo,代码行数:13,代码来源:ExportDialog.java

示例13: CreateChartDialog

import javax.swing.JPanel; //导入方法依赖的package包/类
public CreateChartDialog(GUIFramework framework, ChartsView chartsView) {
    super(framework.getMainFrame(), true);

    setTitle(ChartResourceManager.getString("Action.CreateChart"));
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.framework = framework;
    this.chartsView = chartsView;

    chartFramework = ChartGUIFramework.getFramework(framework);
    for (ChartPlugin chartPlugin : chartFramework.getChartPlugins()) {
        types.addItem(chartPlugin);
    }

    double[][] size = {
            {5, TableLayout.MINIMUM, TableLayout.FILL,
                    TableLayout.MINIMUM, TableLayout.FILL, 5},
            {5, TableLayout.FILL, 5}};

    TableLayout layout = new TableLayout(size);
    layout.setHGap(5);
    layout.setVGap(5);

    JPanel top = new JPanel(layout);

    top.add(new JLabel(ChartResourceManager.getString("Chart.type")),
            "1, 1");
    top.add(types, "2, 1");
    top.add(new JLabel(ChartResourceManager.getString("Chart.name")),
            "3, 1");
    top.add(name, "4, 1");

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(top, BorderLayout.NORTH);
    panel.add(centerPanel, BorderLayout.CENTER);
    setPlugin((ChartPlugin) types.getSelectedItem());
    types.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            setPlugin((ChartPlugin) types.getSelectedItem());
        }
    });
    setMinimumSize(new Dimension(600, 420));
    setMainPane(panel);
    pack();
    centerDialog();
    Options.loadOptions(this);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:50,代码来源:CreateChartDialog.java

示例14: DataTableViewer

import javax.swing.JPanel; //导入方法依赖的package包/类
public DataTableViewer(DataTable dataTable, LinkedHashMap<String, Class<? extends Plotter>> availablePlotters,
		boolean showPlotter, String tableMode, boolean autoResize) {
	super(new BorderLayout());

	// create empty buttonCard
	ButtonBarCardPanel bCard = new ButtonBarCardPanel();

	// Build table view
	this.dataTableViewerTable = new DataTableViewerTable(autoResize);
	this.tablePanel = new JPanel(new BorderLayout());
	JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
	infoPanel.add(generalInfo);
	infoPanel.setOpaque(true);
	infoPanel.setBackground(Colors.WHITE);
	tablePanel.add(infoPanel, BorderLayout.NORTH);
	JScrollPane tableScrollPane = new ExtendedJScrollPane(dataTableViewerTable);
	tableScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 10, 10, 5));
	tableScrollPane.setBackground(Colors.WHITE);
	tableScrollPane.getViewport().setBackground(Colors.WHITE);
	tablePanel.add(tableScrollPane, BorderLayout.CENTER);

	// add data table to the result view
	bCard.addCard(new ResourceCard("data_view", "result_view.data_view"), tablePanel);

	// Add plotters if desired
	if (showPlotter) {
		this.plotterSettings = new PlotterConfigurationModel(availablePlotters, dataTable);
		this.plotterPanel = new PlotterPanel(plotterSettings);
		DataTable plotData = plotterSettings.getDataTable();

		// preface to create ChartConfigationPanel:
		ExampleSet exampleSet = DataTableExampleSetAdapter.createExampleSetFromDataTable(plotData);
		Map<DatasetTransformationType, PlotConfiguration> plotConfigurationMap = PlotConfigurationHistory
				.getPlotConfigurationMap(exampleSet, plotData);
		PlotInstance plotInstance = new PlotInstance(plotConfigurationMap.get(DatasetTransformationType.ORIGINAL),
				plotData);
		this.advancedPanel = new ChartConfigurationPanel(true, plotInstance, plotData,
				plotConfigurationMap.get(DatasetTransformationType.DE_PIVOTED));

		// add Plotter to the result view
		bCard.addCard(new ResourceCard("plot_view", "result_view.plot_view"), plotterPanel);

		// add advanced Charts to the result view
		bCard.addCard(new ResourceCard("advanced_charts", "result_view.advanced_charts"), advancedPanel);
	} // end if (showPlotter)

	// check select desired view
	if (PLOT_MODE.equals(tableMode) && showPlotter) {
		bCard.selectCard("plot_view");
	} else if (ADVANCED_MODE.equals(tableMode) && showPlotter) {
		bCard.selectCard("advanced_charts");
	}

	add(bCard, BorderLayout.CENTER);
	setDataTable(dataTable);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:58,代码来源:DataTableViewer.java

示例15: createEntriesPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
/** Updates the contents of the entries panel. */
private JPanel createEntriesPanel() {
	GridBagLayout layout = new GridBagLayout();

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 1.0;
	gbc.fill = GridBagConstraints.HORIZONTAL;

	JPanel entriesPanel = new JPanel();
	entriesPanel.setLayout(layout);

	List<String> keys = new ArrayList<>(map.getAll().keySet());
	Collections.sort(keys);
	boolean alternatingRow = true;
	for (String key : keys) {
		IOObject object = map.get(key);
		if (object == null) {
			// do not display empty results
			continue;
		}

		// look up icon
		Icon icon = RendererService.getIcon(object.getClass());
		if (icon == null) {
			icon = UNKNOWN_TYPE;
		}

		// look up name
		String type = RendererService.getName(object.getClass());
		if (type == null) {
			type = object.getClass().getSimpleName();
		}

		Action removeAction = new RemoveCacheEntryAction(map, key);
		Action openAction = new OpenCacheEntryAction(map, key);

		IOObjectCacheEntryPanel entry = new IOObjectCacheEntryPanel(icon, type, openAction, removeAction);
		if (alternatingRow) {
			entry.setDefaultBackground(Colors.WHITE);
		}
		alternatingRow = !alternatingRow;

		entriesPanel.add(entry, gbc);
		gbc.gridy += 1;
	}

	gbc.weighty = 1.0;
	gbc.fill = GridBagConstraints.BOTH;
	entriesPanel.add(Box.createVerticalGlue(), gbc);

	return entriesPanel;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:55,代码来源:IOObjectCacheViewer.java


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