當前位置: 首頁>>代碼示例>>Java>>正文


Java JPanel.setPreferredSize方法代碼示例

本文整理匯總了Java中javax.swing.JPanel.setPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JPanel.setPreferredSize方法的具體用法?Java JPanel.setPreferredSize怎麽用?Java JPanel.setPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.setPreferredSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createUIComponents

import javax.swing.JPanel; //導入方法依賴的package包/類
private void createUIComponents() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    previewDocument = editorFactory.createDocument(EMPTY_TEXT);
    previewEditor = editorFactory.createEditor(previewDocument, null, JavaFileType.INSTANCE, true);

    final EditorSettings settings = previewEditor.getSettings();
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);
    settings.setUseSoftWraps(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(1);

    previewPanel = (JPanel) previewEditor.getComponent();
    previewPanel.setName(PREVIEW_PANEL_NAME);
    previewPanel.setPreferredSize(new Dimension(PREFERRED_PREVIEW_WIDTH, PREFERRED_PREVIEW_HEIGHT));
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:23,代碼來源:SettingsPanel.java

示例2: getSplitter

import javax.swing.JPanel; //導入方法依賴的package包/類
private JPanel getSplitter(int widht, int height) {
	JPanel splitPane = new JPanel();
	Dimension dim = new Dimension(widht, height);
	splitPane.setEnabled(false);
	splitPane.setPreferredSize(dim);
	splitPane.setMaximumSize(dim);
	splitPane.setMinimumSize(dim);
	return splitPane;
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:10,代碼來源:MMQueues.java

示例3: getPanel

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * set up the thumb image UI
 *
 * @param f
 * @return
 */
JPanel getPanel(final String f) {
    setThumbImage(f);
    JPanel p = new JPanel() {
        @Override
        public void paintComponent(Graphics g) {
            g.drawImage(thumbs.get(f), 0, 0, null);
        }
    };
    p.setPreferredSize(THUMB_SIZE);
    p.setBorder(new LineBorder(Color.LIGHT_GRAY, 3));
    JComponent c = getThumbSelector(f);
    JComponent cl = setupThumbClose(p);
    setupAlignment(p, c, cl);
    p.setName(f);
    p.addMouseListener(thumbselected);
    p.addMouseListener(Listeners.thumbPrevFocus);
    thumbList.add(p);
    return p;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:26,代碼來源:ImageGallery.java

示例4: logDivider

import javax.swing.JPanel; //導入方法依賴的package包/類
/** Write a horizontal separator into the log window. */
public void logDivider() {
	if (log == null)
		return;
	clearError();
	StyledDocument doc = log.getStyledDocument();
	Style dividerStyle = doc.addStyle("bar", styleRegular);
	JPanel jpanel = new JPanel();
	jpanel.setBackground(Color.LIGHT_GRAY);
	jpanel.setPreferredSize(new Dimension(300, 1)); // 300 is arbitrary,
													// since it will
													// auto-stretch
	StyleConstants.setComponent(dividerStyle, jpanel);
	reallyLog(".", dividerStyle); // Any character would do; "." will be
									// replaced by the JPanel
	reallyLog("\n\n", styleRegular);
	log.setCaretPosition(doc.getLength());
	lastSize = doc.getLength();
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:20,代碼來源:SwingLogPanel.java

示例5: createStatsTable

import javax.swing.JPanel; //導入方法依賴的package包/類
private JPanel createStatsTable(String title, Map<String, String> data) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(new JLabel(title), BorderLayout.PAGE_START);
    StatisticsModel model = new StatisticsModel();
    model.setData(data);
    JTable table = new JTable(model);
    table.setAutoCreateColumnsFromModel(true);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setAutoCreateRowSorter(true);
    JScrollPane scrollPane = new JScrollPane(table);
    table.addNotify();
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getColumnHeader().setOpaque(false);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(300, (data.size()+2)*17));
    return panel;
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:19,代碼來源:StatisticsPanel.java

示例6: prepareControls

import javax.swing.JPanel; //導入方法依賴的package包/類
protected void prepareControls() {
    p = new JPanel(new GridLayout(0, 1));
    propagateAWTControls(p);
    b = new JButton("Space extender");
    p.add(b);
    p.setPreferredSize(new Dimension(500, 500));
    scrollPane = new JScrollPane(p);

    f = new JFrame();
    f.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            frameClicked++;
        }
    });
    f.getContentPane().add(scrollPane, BorderLayout.CENTER);
    ((JComponent) f.getContentPane()).setBorder(
            BorderFactory.createEmptyBorder(50, 50, 50, 50));
    f.setSize(400, 400);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:ViewportOverlapping.java

示例7: createComponent

import javax.swing.JPanel; //導入方法依賴的package包/類
/** Gets component to display. Implements superclass abstract method. 
 * @return this instance */
protected Component createComponent() {
    JPanel panel = new JPanel(new CardLayout());

    // Accessibility
    panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ResourceWizardPanel.class).getString("ACS_ResourceWizardPanel"));                 
    
    panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(1));

    String msgKey = testWizard ? "TXT_SelectTestResource"       //NOI18N
                               : "TXT_SelectResource";          //NOI18N
    panel.setName(NbBundle.getMessage(ResourceWizardPanel.class, msgKey));
    panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);
    
    panel.add(getUI(), CARD_GUI);

    return panel;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:ResourceWizardPanel.java

示例8: createComponent

import javax.swing.JPanel; //導入方法依賴的package包/類
/** Gets component to display. Implements superclass abstract method. 
 * @return <code>AdditionalPanel</code> instance */
protected Component createComponent() {
    JPanel panel = new JPanel();
    
    //Accessibility
    panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(AdditionalWizardPanel.class).getString("ACS_AdditionalWizardPanel"));                    
    
    panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(2));
    panel.setName(NbBundle.getBundle(getClass()).getString("TXT_ModifyAdditional"));
    panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);

    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(getUI(), constraints);
    
    return panel;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:AdditionalWizardPanel.java

示例9: erzeugeHauptPanel

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * Erzeugt das Hauptpanel, in dem sich Verleihkartenauflister,
 * Verleihkartenanzeiger und Rücknahme-Button befinden.
 */
private void erzeugeHauptPanel()
{
    _hauptPanel = new JPanel();
    _hauptPanel.setLayout(new BorderLayout());
    _hauptPanel.setPreferredSize(new java.awt.Dimension(-1, -1));
    _hauptPanel.setSize(-1, -1);
    _hauptPanel.setAutoscrolls(true);
    _hauptPanel.setBackground(UIConstants.BACKGROUND_COLOR);
}
 
開發者ID:polemonium,項目名稱:SE2Project,代碼行數:14,代碼來源:RueckgabeUI.java

示例10: initialize

import javax.swing.JPanel; //導入方法依賴的package包/類
public void initialize() {
	JPanel empty = new JPanel();
	empty.setPreferredSize(new Dimension(CommonConstants.MAX_GUI_WIDTH_COMMON, CommonConstants.MAX_GUI_HEIGHT_COMMON));
	this.setLayout(new BorderLayout());
	this.add(empty, BorderLayout.CENTER);
	title.setTitleColor(Color.LIGHT_GRAY);
	this.setBorder(title);
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:9,代碼來源:EmptyPanel.java

示例11: get_Panel

import javax.swing.JPanel; //導入方法依賴的package包/類
private JPanel get_Panel() {
    JPanel panel = new Wallpaper_Panel(new GridBagLayout());
    panel.setPreferredSize(new Dimension(340,290));
    
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    
    c.gridy = 0; c.gridx = 0;
    JPanel topGab = new JPanel();
    topGab.setOpaque(false);
    panel.add(topGab, c);

    c.insets = new Insets(0, 0, 10, 0);//top, left, bott, right
    c.gridx = 1;
    
    c.gridy = 1;
    panel.add(get_send_butt(), c);
    c.gridy = 2;c.gridwidth = 1; 
    panel.add(get_receive_butt(), c);
    c.gridy = 3;
    panel.add(get_settings_butt(), c);

    c.insets = new Insets(0, 0, 0, 0); // reset to default
    
    c.gridy = 4;
    panel.add(get_help_butt(), c);

    c.gridx = 2;
    
    c.gridy = 5; 
    JPanel bottGab = new JPanel();
    bottGab.setOpaque(false);
    panel.add(bottGab, c);
    
    return panel;
}
 
開發者ID:adbenitez,項目名稱:MailCopier,代碼行數:39,代碼來源:Main.java

示例12: visualizeGraph

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * Visualize company graph
 */
public void visualizeGraph(String s) {
	try {
		final File png = new File(s);
		png.deleteOnExit();
		Tg2Dot.convertGraph(graph, png.getCanonicalPath(),
				GraphVizOutputFormat.PNG);
		final Image i = ImageIO.read(png);
		JPanel panel = new JPanel() {
			private static final long serialVersionUID = -891941166683362373L;

			@Override
			public void paintComponent(Graphics g) {
				g.drawImage(i, 0, 0, null);
			}
		};
		panel.setPreferredSize(new Dimension(i.getWidth(panel), i
				.getHeight(panel)));
		panel.setVisible(true);
		JFrame f = new JFrame("Company Graph");
		f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		JScrollPane sp = new JScrollPane(panel);
		f.getContentPane().add(sp);
		f.setSize(400, 400);
		f.setVisible(true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:32,代碼來源:CompanyServices.java

示例13: initialize

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * Initialize the panel
 */
private void initialize() {
	// Initialize dialog layout
	
	JPanel panel = new JPanel(new BorderLayout(BORDERSIZE / 2, BORDERSIZE / 2));
	panel.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
	// Adds website image
	JPanel tmpPanel = new JPanel(new BorderLayout(BORDERSIZE, BORDERSIZE));
	// Adds polimi description
	HtmlPanel titleLabel = new HtmlPanel();
	titleLabel.setText(GraphStartScreen.HTML_CONTENT_TITLE_HREF);
	titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
	titleLabel.setAlignmentY(Component.CENTER_ALIGNMENT);
	titleLabel.setOpaque(false);
	tmpPanel.add(titleLabel, BorderLayout.CENTER);

	// Adds application title
	title = new JLabel();
	title.setHorizontalTextPosition(SwingConstants.RIGHT);
	title.setHorizontalAlignment(SwingConstants.CENTER);
	title.setIconTextGap(BORDERSIZE);
	tmpPanel.add(title, BorderLayout.SOUTH);

	panel.add(tmpPanel, BorderLayout.NORTH);

	// Adds text area
	mainArea = new JPanel();
	mainArea.setOpaque(false);
	BoxLayout mainLayout = new BoxLayout(mainArea, BoxLayout.Y_AXIS);
	mainArea.setLayout(mainLayout);
	
	panel.add(mainArea, BorderLayout.CENTER);

	JLabel legal = new JLabel(LEGAL);
	panel.add(legal, BorderLayout.SOUTH);
	panel.setPreferredSize(new Dimension(600,480));
	JScrollPane scroll = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	this.add(scroll, BorderLayout.CENTER);
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:42,代碼來源:AboutDialogPanel.java

示例14: setup

import javax.swing.JPanel; //導入方法依賴的package包/類
private void setup()
{
	header = Icons.getHeader(export);
	footer = new Footer();

	content = new JPanel(new GridLayout(1, 1));

	next = new JButton();
	back = new JButton("< Back");

	next.addActionListener(this);
	back.addActionListener(this);

	JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	buttons.add(back);
	buttons.add(next);

	buttons.setPreferredSize(buttons.getPreferredSize());

	final int width = header.getPreferredSize().width;
	final int height1 = header.getPreferredSize().height;
	final int height2 = buttons.getPreferredSize().height;
	final int height3 = footer.getPreferredSize().height;

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

	JPanel all = new JPanel(new TableLayout(rows, cols, 5, 5));
	all.add(header, new Rectangle(0, 0, 1, 1));
	all.add(content, new Rectangle(0, 1, 1, 1));
	all.add(buttons, new Rectangle(0, 2, 1, 1));
	all.add(footer, new Rectangle(0, 3, 1, 1));

	getContentPane().add(all);

	pack();
	setResizable(false);
	setTitle(title);
	ComponentHelper.centreOnScreen(this);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	updateButtons();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:44,代碼來源:WizardFrame.java

示例15: MouseOptions

import javax.swing.JPanel; //導入方法依賴的package包/類
public MouseOptions(OptionsFrame window) {
	super(window, new GridLayout(1, 3));

	explorer = new ProjectExplorer(getProject());
	explorer.setListener(listener);

	// Area for adding mappings
	addArea.addMouseListener(listener);

	// Area for viewing current mappings
	model = new MappingsModel();
	mappings.setTableHeader(null);
	mappings.setModel(model);
	mappings.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	mappings.getSelectionModel().addListSelectionListener(listener);
	mappings.clearSelection();
	JScrollPane mapPane = new JScrollPane(mappings);

	// Button for removing current mapping
	JPanel removeArea = new JPanel();
	remove.addActionListener(listener);
	remove.setEnabled(false);
	removeArea.add(remove);

	// Area for viewing/changing attributes
	attrTable = new AttrTable(getOptionsFrame());

	GridBagLayout gridbag = new GridBagLayout();
	GridBagConstraints gbc = new GridBagConstraints();
	setLayout(gridbag);
	gbc.weightx = 1.0;
	gbc.weighty = 1.0;
	gbc.gridheight = 4;
	gbc.fill = GridBagConstraints.BOTH;
	JScrollPane explorerPane = new JScrollPane(explorer, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	gridbag.setConstraints(explorerPane, gbc);
	add(explorerPane);
	gbc.weightx = 0.0;
	JPanel gap = new JPanel();
	gap.setPreferredSize(new Dimension(10, 10));
	gridbag.setConstraints(gap, gbc);
	add(gap);
	gbc.weightx = 1.0;
	gbc.gridheight = 1;
	gbc.gridx = 2;
	gbc.gridy = GridBagConstraints.RELATIVE;
	gbc.weighty = 0.0;
	gridbag.setConstraints(addArea, gbc);
	add(addArea);
	gbc.weighty = 1.0;
	gridbag.setConstraints(mapPane, gbc);
	add(mapPane);
	gbc.weighty = 0.0;
	gridbag.setConstraints(removeArea, gbc);
	add(removeArea);
	gbc.weighty = 1.0;
	gridbag.setConstraints(attrTable, gbc);
	add(attrTable);

	getOptions().getMouseMappings().addMouseMappingsListener(listener);
	setCurrentTool(null);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:64,代碼來源:MouseOptions.java


注:本文中的javax.swing.JPanel.setPreferredSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。