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


Java JScrollPane.setPreferredSize方法代码示例

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


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

示例1: generateScrollPane

import javax.swing.JScrollPane; //导入方法依赖的package包/类
public JScrollPane generateScrollPane()
{	
	JScrollPane newScroll = new JScrollPane();
	JList list = new JList(listModel);
	list.setFont( new Font("monospaced", Font.PLAIN, 12) );
	newScroll.setViewportView(list);
	
	Dimension listSize = new Dimension(400, 150);
	newScroll.setSize(listSize);
	newScroll.setMaximumSize(listSize);
	newScroll.setPreferredSize(listSize);
	
	newScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {  
        public void adjustmentValueChanged(AdjustmentEvent e) {  
            e.getAdjustable().setValue(e.getAdjustable().getMaximum());  
        }
    }); 
	return newScroll;
}
 
开发者ID:TeamRedFox,项目名称:PointOfSale,代码行数:20,代码来源:Cart.java

示例2: initComponents

import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void initComponents() {
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    listModel = new DefaultListModel();
    list = new JList(listModel);
    list.getAccessibleContext().setAccessibleName(Bundle.ProfilingPointsDisplayer_ListAccessName());
    list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setVisibleRowCount(6);
    list.setCellRenderer(org.netbeans.modules.profiler.ppoints.Utils.getPresenterListRenderer());

    JScrollPane listScroll = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                             JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroll.setPreferredSize(new Dimension(405, listScroll.getPreferredSize().height));

    add(listScroll, BorderLayout.CENTER);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProfilingPointsDisplayer.java

示例3: InfrastructureBrowserPanel

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * 
 */
public InfrastructureBrowserPanel() {
	setLayout(new BorderLayout(0, 0));

	final JPanel panel = new JPanel();
	add(panel, BorderLayout.SOUTH);

	btnRefresh = new JButton("Refresh");
	panel.add(btnRefresh);

	final JScrollPane scrollPane = new JScrollPane();
	scrollPane.setPreferredSize(new Dimension(600, 500));
	add(scrollPane, BorderLayout.CENTER);
	model = new InfrastructureTreeModel(new ArrayList<ClusterInfo>());
	tree = new JTree(model);
	tree.setCellRenderer(new InfrastructureCellRenderer(tree
			.getCellRenderer()));
	scrollPane.setViewportView(tree);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:22,代码来源:InfrastructureBrowserPanel.java

示例4: run

import javax.swing.JScrollPane; //导入方法依赖的package包/类
@Override
public void run() {
    frame = new JFrame();
    frame.setTitle("Results - jOthelloT");
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    JScrollPane mainScroll = new JScrollPane(panel);
    mainScroll.getVerticalScrollBar().setUnitIncrement(16);
    mainScroll.setPreferredSize(new Dimension(800, 600));
    frame.getContentPane().add(mainScroll, BorderLayout.CENTER);
    JButton button = new JButton("Save");
    button.addActionListener((ActionEvent e) -> {
        saveResults(othelloChampionship.getBtResult(), othelloChampionship.getPartialResults(),othelloChampionship.getlistQualifying());
    });
    frame.getContentPane().add(button, BorderLayout.SOUTH);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
开发者ID:data-library,项目名称:jOthelloT,代码行数:19,代码来源:Results.java

示例5: createExceptionsPanel

import javax.swing.JScrollPane; //导入方法依赖的package包/类
Box createExceptionsPanel() {
	Box box = Box.createVerticalBox();
	box.setOpaque(false);
	box.setBorder(new EmptyBorder(10, 0, 0, 10));

	Box b0 = Box.createHorizontalBox();
	b0.add(new JLabel(getString("LBL_EXCEPT")));
	b0.setBorder(new EmptyBorder(0, 0, 10, 0));
	b0.add(Box.createHorizontalGlue());
	box.add(b0);

	txtException = new JTextArea();
	txtException.setLineWrap(false);
	txtException.setWrapStyleWord(true);

	JScrollPane jsp = new JScrollPane(txtException);
	jsp.setPreferredSize(new Dimension(10, 10));

	box.add(jsp);

	Box b = Box.createHorizontalBox();
	b.add(new JLabel(getString("LBL_EXCEPT_LN")));
	b.add(Box.createHorizontalGlue());
	b.setBorder(new EmptyBorder(5, 0, 5, 0));
	box.add(b);

	return box;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:29,代码来源:ConfigDialog.java

示例6: init

import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void init(JLabel label, String[] columns, TableSorter sorter) {
    tableModel = new PropertiesTableModel(columns);
    tableModel.addTableModelListener(this);
    if(sorter == null) {
        sorter = new TableSorter(tableModel);
    } 
    this.sorter = sorter;   
    table = new SortedTable(this.sorter);
    table.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PropertiesTable.class, "tableProperties.AccessibleContext.accessibleName"));
    table.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesTable.class, "tableProperties.AccessibleContext.accessibleDescription"));
    table.getTableHeader().setReorderingAllowed(false);
    TableCellRenderer cellRenderer = new PropertiesTableCellRenderer();
    table.setDefaultRenderer(String.class, cellRenderer);
    table.setRowHeight(Math.max(
            table.getRowHeight(),
            cellRenderer.getTableCellRendererComponent(table, "abc", true, true, 0, 0)//NOI18N
                        .getPreferredSize().height + 2));
    //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
    table.getTableHeader().setReorderingAllowed(true);
    table.setRowHeight(table.getRowHeight());
    table.addAncestorListener(this);
    component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    component.setPreferredSize(new Dimension(340, 150));
    table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N        
    label.setLabelFor(table);
    setColumns(columns);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:PropertiesTable.java

示例7: createIDEEditorPanel

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * Constructs an IDE editor panel, preset with the file's code, with which the user can edit the file's code
 * @param d the dimension of the editor panel
 * @return the IDE editor panel
 * @throws IOException if file fails to save, rendering the initial compilation a failure
 * @throws MalformedURLException if the class fails to load into the ArJClassEditor (leaving it unable to run the compiled class)
 */
public JPanel createIDEEditorPanel(Dimension d) throws MalformedURLException, IOException
{
	JScrollPane editorScrollPane = createEditorScrollPane(readFile());
	editorScrollPane.setPreferredSize(new Dimension((int) d.getWidth(), (int) (2/3 * d.getHeight())));
	consolePane.getViewport().setPreferredSize(new Dimension((int) d.getWidth(), (int) (1/3 * d.getHeight())));
	JPanel editorPanel = new JPanel();
	editorPanel.setLayout(new BoxLayout(editorPanel, BoxLayout.PAGE_AXIS));
	editorPanel.setSize(d);
	editorPanel.add(editorScrollPane);
	editorPanel.add(consolePane);
	compile();
	return editorPanel;
}
 
开发者ID:arjunvnair,项目名称:ArJ-class-editor,代码行数:21,代码来源:ArJClassEditor.java

示例8: checkVersion

import javax.swing.JScrollPane; //导入方法依赖的package包/类
protected void checkVersion() {
	if (AT_SEA) {
		return;
	}
	URL url=null;
	try {
		String versionURL = PathUtil.getPath("VERSION_PATH",
				BASE_URL+"/gma_version/") + "version";
		url = URLFactory.url(versionURL);

		BufferedReader in = new BufferedReader(new InputStreamReader( url.openStream() ));
		String version = in.readLine();
		if( compareVersions(VERSION, version) < 0) {
			GMADownload.download( VERSION, version);
		}
		try {
			String alertPath = PathUtil.getPath("HTML/HTML_PATH",
					BASE_URL+"/gma_html/") + "Alert.html";
			url = URLFactory.url(alertPath);
			JEditorPane jep = new JEditorPane(url);
			JPanel panel = new JPanel( new BorderLayout() );
			JScrollPane sp = new JScrollPane(jep);
			sp.setPreferredSize( new Dimension(600,400) );
			sp.setSize( new Dimension(600,400) );
			panel.add( sp );
			JOptionPane.showMessageDialog( null, panel, "GeoMapApp Alert", JOptionPane.INFORMATION_MESSAGE);
		//	System.out.println( jep.getText() );
		} catch(Exception e) {
		}
	} catch (IOException ex ) {
		JOptionPane.showMessageDialog(frame,
				"The server: " + url.getHost() + "\n is not available. Please be patient.",
				getBaseURL(), JOptionPane.ERROR_MESSAGE);
		ex.printStackTrace();
		// System.exit(0);
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:38,代码来源:MapApp.java

示例9: alert

import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void alert(String message, String title) {
    JTextArea textArea = new JTextArea(message);
    JScrollPane scrollPane = new JScrollPane(textArea);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    scrollPane.setPreferredSize(new Dimension(500, 500));
    JOptionPane.showMessageDialog(null, scrollPane, title,
            JOptionPane.INFORMATION_MESSAGE);
}
 
开发者ID:varunon9,项目名称:Image-Stegano,代码行数:10,代码来源:ImageStegano.java

示例10: getStackTracePane

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * Creates the pane with the stack trace of an exception.
 * @param e the exception to be shown in the pane.
 * @return the pane object.
 */
private JScrollPane getStackTracePane(Throwable e) {
    // Create a text pane
    JTextPane stackTracePane = new JTextPane();
    stackTracePane.setEditable(false);
    // Text font
    Font font = new Font("Serif", Font.PLAIN, 12);
    stackTracePane.setFont(font);
    // Get the message and the stack trace from the exception and put them
    // in text pane.
    StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    stackTracePane.setText("Exception in GROOVE " + sw.toString());

    // Extra panel to prevent wrapping of the exception message.
    JPanel noWrapPanel = new JPanel(new BorderLayout());
    noWrapPanel.add(stackTracePane);

    // Pane to create the scroll bars.
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setPreferredSize(new Dimension(700, 300));
    scrollPane.setBorder(BorderFactory.createTitledBorder(null,
        "Exception Stack Trace:",
        TitledBorder.DEFAULT_JUSTIFICATION,
        TitledBorder.DEFAULT_POSITION));
    scrollPane.setViewportView(noWrapPanel);

    return scrollPane;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:34,代码来源:BugReportDialog.java

示例11: createDetailPanel

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * Creates a Panel for the error details and attaches the error message to it, but doesn't add
 * the Panel to the dialog.
 *
 * @param squaredError
 * @return
 */
private JScrollPane createDetailPanel(String errorMessage) {

	JTextArea textArea = new JTextArea(errorMessage);
	textArea.setLineWrap(true);
	textArea.setEditable(false);
	JScrollPane detailPane = new ExtendedJScrollPane(textArea);
	detailPane.setPreferredSize(new Dimension(getWidth(), 200));
	return detailPane;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:ExtendedErrorDialog.java

示例12: initComponents

import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void initComponents() {
	setLayout(new BorderLayout(5, 5));
	this.setBorder(new EmptyBorder(20, 20, 20, 20));
	//classesList = new JList(new StationsListModel());
	stationsList = new JList();
	stationsList.setListData(stationData.getStationKeys());
	stationsList.setCellRenderer(new StationElementRenderer());
	stationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	panelDescription = new JLabel(STATIONS_PAR_DESCRIPTION);
	JScrollPane jsp = new JScrollPane(stationsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jsp.setPreferredSize(new Dimension(140, 200));
	add(panelDescription, BorderLayout.NORTH);
	add(jsp, BorderLayout.WEST);
	stationsList.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			if (e.getValueIsAdjusting()) {
				return;
			}
			updateParsPane();
		}
	});
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:AllStationsParametersPanel.java

示例13: getUsableControl

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * set up the editor control of the field
 *
 * @param jc
 * @return
 */
JComponent getUsableControl(JComponent jc) {
    if (jc instanceof JTextArea) {
        JScrollPane js = new JScrollPane();
        js.setPreferredSize(new Dimension(200, 100));
        js.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        js.setViewportView(jc);
        return js;
    } else {
        return jc;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:18,代码来源:ReportDefect.java

示例14: initComponents

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * Set up the panel contents and layout
 */
private void initComponents() {

	stTable = new STTable();

	Box hBox = Box.createHorizontalBox();
	hBox.add(Box.createHorizontalStrut(20));
	//Horizontal box containing Description label and buttons
	Box descrBox = Box.createVerticalBox();
	descrBox.add(new JLabel(DESCRIPTION_SERVICETIMES));
	descrBox.add(Box.createHorizontalStrut(10));
	descrBox.add(new JButton(SWITCH_TO_SD));
	descrBox.setPreferredSize(new Dimension(220, 1000));
	descrBox.setMinimumSize(new Dimension(200, 200));

	hBox.add(descrBox);
	hBox.add(Box.createHorizontalStrut(10));
	JScrollPane visitTablePane = new JScrollPane(stTable);
	visitTablePane.setPreferredSize(new Dimension(1000, 1000));
	visitTablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	visitTablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	hBox.add(visitTablePane);
	hBox.add(Box.createHorizontalStrut(20));

	Box totalBox = Box.createVerticalBox();
	totalBox.add(Box.createVerticalStrut(20));
	totalBox.add(hBox);
	totalBox.add(Box.createVerticalStrut(20));

	setLayout(new BorderLayout());
	add(totalBox, BorderLayout.CENTER);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:36,代码来源:ServiceTimesPanel.java

示例15: showError

import javax.swing.JScrollPane; //导入方法依赖的package包/类
@Override
public void showError(String description) {
	if (!filesOpening.empty()) {
		File top = filesOpening.peek();
		String init = toProjectName(top) + ":";
		if (description.contains("\n")) {
			description = init + "\n" + description;
		} else {
			description = init + " " + description;
		}
	}

	if (description.contains("\n") || description.length() > 60) {
		int lines = 1;
		for (int pos = description.indexOf('\n'); pos >= 0; pos = description.indexOf('\n', pos + 1)) {
			lines++;
		}
		lines = Math.max(4, Math.min(lines, 7));

		JTextArea textArea = new JTextArea(lines, 60);
		textArea.setEditable(false);
		textArea.setText(description);
		textArea.setCaretPosition(0);

		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setPreferredSize(new Dimension(350, 150));
		JOptionPane.showMessageDialog(parent, scrollPane, Strings.get("fileErrorTitle"), JOptionPane.ERROR_MESSAGE);
	} else {
		JOptionPane.showMessageDialog(parent, description, Strings.get("fileErrorTitle"),
				JOptionPane.ERROR_MESSAGE);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:33,代码来源:Loader.java


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