本文整理匯總了Java中java.awt.ScrollPane.add方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollPane.add方法的具體用法?Java ScrollPane.add怎麽用?Java ScrollPane.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.ScrollPane
的用法示例。
在下文中一共展示了ScrollPane.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.awt.ScrollPane; //導入方法依賴的package包/類
public static void main(String[] args) {
JFrame f = new JFrame("表格效果");
JPanel p = new JPanel();
p.setLayout(new GridLayout(10, 5));
JTextField[] cells = new JTextField[50];
for (int i = 0; i < 50; i++) {
cells[i] = new JTextField(String.valueOf(i), 5);
p.add(cells[i]);
}
ScrollPane sp = new ScrollPane();// 滾動麵板
sp.add(p);
f.add(sp, "Center");
f.setSize(270, 200);
f.setLocation(450, 200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
示例2: createVncClientMainWindow
import java.awt.ScrollPane; //導入方法依賴的package包/類
private Frame createVncClientMainWindow(final BufferedImageCanvas canvas, final String title) {
// Create AWT windows
final Frame frame = new Frame(title + " - VNCle");
// Use scrolling pane to support screens, which are larger than ours
final ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
scroller.add(canvas);
scroller.setSize(screen.getFramebufferWidth(), screen.getFramebufferHeight());
frame.add(scroller);
frame.pack();
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent evt) {
frame.setVisible(false);
shutdown();
}
});
return frame;
}
示例3: setScroll
import java.awt.ScrollPane; //導入方法依賴的package包/類
public void setScroll( boolean hasScroll ) {
if( this.hasScroll == hasScroll ) {
return;
}
this.hasScroll = hasScroll;
if( hasScroll ) {
this.remove(procApp);
ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
sp.add(procApp);
this.add( sp,"Center");
this.validate();
this.repaint();
}
else {
this.removeAll();
this.add( procApp,"Center");
procApp.invalidate();
this.validate();
this.repaint();
}
}
示例4: mouseClicked
import java.awt.ScrollPane; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() > 1)
{
// find the process var to selected row ...
ProcessVar pv = (ProcessVar) pvTable.getPvModel().getElementAt(pvTable.getSelectedRow());
// and show a detail panel about it ...
if (pv != null)
{
PvDetailPanel panDetail = new PvDetailPanel((ProcessVar) pv, true);
ScrollPane panScr = new ScrollPane();
panScr.setPreferredSize(new Dimension(640, 480));
panScr.add(panDetail);
JOptionPane.showMessageDialog(null, panScr);
}
}
}
示例5: PointListDialog
import java.awt.ScrollPane; //導入方法依賴的package包/類
/**
* Constructs an empty PointListDialog
*
* @param owner
*/
public PointListDialog(final Frame owner) {
super(owner, "Point list");
panel = new Panel();
gridbag = new GridBagLayout();
panel.setLayout(gridbag);
panel.setBackground(Color.WHITE);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.NORTHWEST;
c.weighty = 0.1f;
c.fill = GridBagConstraints.NONE;
final ScrollPane scroll = new ScrollPane();
scroll.add(panel);
add(scroll);
}
示例6: createVncClientMainWindow
import java.awt.ScrollPane; //導入方法依賴的package包/類
private Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title) {
// Create AWT windows
final Frame frame = new Frame(title + " - VNCle");
// Use scrolling pane to support screens, which are larger than ours
ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
scroller.add(canvas);
scroller.setSize(screen.getFramebufferWidth(), screen.getFramebufferHeight());
frame.add(scroller);
frame.pack();
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
frame.setVisible(false);
shutdown();
}
});
return frame;
}
示例7: createVncClientMainWindow
import java.awt.ScrollPane; //導入方法依賴的package包/類
protected static Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title, WindowListener windowListener) {
// Create AWT windows
Frame frame = new Frame(title + " - RDP");
// Use scrolling pane to support screens, which are larger than ours
scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
scroller.add(canvas);
scroller.setSize(canvas.getWidth(), canvas.getHeight());
frame.add(scroller);
frame.pack();
frame.setVisible(true);
frame.addWindowListener(windowListener);
return frame;
}
示例8: fillFrame
import java.awt.ScrollPane; //導入方法依賴的package包/類
private void fillFrame(Frame f, List dataList, MidiDevice.Info[] info) {
try {
f.setSize(340, 200);
f.setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2 - 170,
Toolkit.getDefaultToolkit().getScreenSize().height / 2 - 100);
String[] data = new String[info.length];
data[0] = "" + info[0];
data[1] = "" + info[1];
for(int i=2; i< info.length; i++) {
data[i] = MidiSystem.getMidiDevice(info[i]).toString();
}
for(int i=0; i< info.length; i++) {
dataList.add(data[i]);
}
ScrollPane scrollPane = new ScrollPane();
scrollPane.add(dataList);
f.add(scrollPane);
} catch (Exception e) {
System.out.println (e);
System.exit (0);
}
}
示例9: ScrollPaneDemo
import java.awt.ScrollPane; //導入方法依賴的package包/類
ScrollPaneDemo() {
panel = new JPanel(new GridLayout(10, 5));
button = new Button[50];
for (int i = 0; i < button.length; i++) {
button[i] = new Button("按鈕" + i);
panel.add(button[i]);
}
scrollPane = new ScrollPane();
scrollPane.add(panel);
add(scrollPane, "Center");
setBounds(300, 300, 200, 200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
示例10: makeWindow
import java.awt.ScrollPane; //導入方法依賴的package包/類
private void makeWindow() {
result = new JFrame();
result.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
result.setSize(new Dimension(600, 600));
ScrollPane scrollPane = new ScrollPane();
this.area = new JTextPane();
area.setContentType("text/html");
area.setText(generateOutput());
area.setEditable(false);
scrollPane.add(area);
result.add(scrollPane, BorderLayout.CENTER);
result.add(getBottomButtons(), BorderLayout.PAGE_END);
result.add(getSaveButton(), BorderLayout.PAGE_START);
}
示例11: makeWindow
import java.awt.ScrollPane; //導入方法依賴的package包/類
private void makeWindow() {
result = new JFrame();
result.setSize(new Dimension(400, 300));
ScrollPane scrollPane = new ScrollPane();
result.add(scrollPane);
JTextArea area = new JTextArea(output);
scrollPane.add(area);
result.addWindowListener(new CloseListener());
}
示例12: createGUICenter
import java.awt.ScrollPane; //導入方法依賴的package包/類
private ScrollPane createGUICenter(String title, String value) {
mTextArea = new JTextArea(value);
UIUtils.useTabToChangeFocus(mTextArea);
mTextArea.setRows(4);
ScrollPane scrollPane = new ScrollPane();
scrollPane.add(mTextArea);
return scrollPane;
}
示例13: displayDecisionVariables
import java.awt.ScrollPane; //導入方法依賴的package包/類
private void displayDecisionVariables() {
Panel dvPanel = new Panel();
ScrollPane scrollPane = new ScrollPane();
GroupLayout dvlayout = new GroupLayout(dvPanel);
dvlayout.setAutoCreateGaps(true);
dvlayout.setAutoCreateContainerGaps(true);
ParallelGroup groupForElementsInLine = dvlayout.createParallelGroup(Alignment.LEADING);
SequentialGroup groupForElementsInColumns = dvlayout.createSequentialGroup();
for (Displayable displayable : decisionVariables) {
List<InfoGUI> infos = displayable.getInfo();
for (InfoGUI infoGUI : infos) {
DecisionVariableGUI dvGui1 = new DecisionVariableGUI(infoGUI);
groupForElementsInLine.addGroup((dvlayout.createSequentialGroup().addComponent(dvGui1.getLabel())
.addComponent(dvGui1.getComponent())));
groupForElementsInColumns.addGroup((dvlayout.createParallelGroup(Alignment.CENTER)
.addComponent(dvGui1.getLabel()).addComponent(dvGui1.getComponent())));
mapWithControls.add(dvGui1);
}
}
dvlayout.setHorizontalGroup(groupForElementsInLine);
dvlayout.setVerticalGroup(groupForElementsInColumns);
dvPanel.setLayout(dvlayout);
dvPanel.setBackground(Color.lightGray);
Collections.sort(mapWithControls);
Dimension scrollPaneDimension = new Dimension(dvPanel.getPreferredSize().width + 30,
dvPanel.getPreferredSize().height + 35);
scrollPane.setPreferredSize(new Dimension(250, 700));
if (scrollPaneDimension.height < scrollPane.getPreferredSize().height) {
scrollPane.setPreferredSize(scrollPaneDimension);
}
scrollPane.add(dvPanel);
controlPanel.add(scrollPane);
}
示例14: main
import java.awt.ScrollPane; //導入方法依賴的package包/類
/**
* Run test applet.
*
* @param args command line parameters
*/
public static void main(String[] args)
{
JApplet applet = new JApplet() {
private static final long serialVersionUID = 1L;
@Override
public void init()
{
setLayout(new GridBagLayout());
WheelswitchDemo wst = new WheelswitchDemo();
GridBagConstraints consContent = new GridBagConstraints();
consContent.gridx = 0;
consContent.gridy = 1;
consContent.gridwidth = 0;
consContent.fill = java.awt.GridBagConstraints.BOTH;
consContent.anchor = GridBagConstraints.CENTER;
consContent.weightx = 1.0;
consContent.weighty = 1.0;
consContent.insets = new java.awt.Insets(11, 11, 11, 11);
add(wst.initializeContentPanel(), consContent);
ScrollPane helpTextScrollPane = new ScrollPane();
helpTextScrollPane.add(wst.getHelpTextArea());
GridBagConstraints consHelp = new GridBagConstraints();
consHelp.gridx = 0;
consHelp.gridy = 2;
consHelp.gridwidth = 0;
consHelp.fill = java.awt.GridBagConstraints.HORIZONTAL;
consHelp.anchor = GridBagConstraints.CENTER;
consHelp.weightx = 1.0;
consHelp.weighty = 0.0;
consHelp.insets = new java.awt.Insets(0, 11, 11, 11);
add(helpTextScrollPane, consHelp);
}
};
JFrame frame = new JFrame("Wheelswitch Testing Applet");
frame.getContentPane().add(applet);
frame.setSize(500, 400);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
applet.init();
applet.start();
frame.setVisible(true);
}
示例15: GenericHelpFrame
import java.awt.ScrollPane; //導入方法依賴的package包/類
public GenericHelpFrame(String s, String t, int h, int w, int X,int Y, int lines, int columns) {
Font textFont = new java.awt.Font("SanSerif", Font.PLAIN, 12);
FontMetrics textFontMetrics = getFontMetrics(textFont);
Font buttonFont = new java.awt.Font("SanSerif", Font.BOLD, 11);
FontMetrics buttonFontMetrics = getFontMetrics(buttonFont);
Color bgColor = MyColors.helpColor; //new Color(245,245,245);
this.pack();
this.setSize(w,h);
this.setLocation(X,Y);
this.setTitle(t);
this.setResizable(false);
setLayout(new BorderLayout());
TextArea hT = new TextArea("",lines,columns, TextArea.SCROLLBARS_NONE);
hT.setEditable(false);
// Set color and font for TextArea.
hT.setForeground(Color.black);
hT.setFont(textFont);
hT.setBackground(bgColor);
// hT.disable();
ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
sp.add(hT);
this.add("Center", sp);
Panel leftPanel = new Panel();
leftPanel.setBackground(MyColors.gray204);
this.add("West",leftPanel);
// Add Dismiss button and bottom panel
Panel botPanel = new Panel();
botPanel.setFont(buttonFont);
botPanel.setBackground(MyColors.gray204);
Button dismissButton = new Button("Cancel");
botPanel.add(dismissButton);
this.add("South", botPanel);
// Insert the text string in the TextArea
hT.appendText("\n" + s);
// Add inner class event handler for Dismiss button
dismissButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
hide();
dispose();
ParamSetup.helpWindowOpen = false;
}
});
// Add window closing button (inner class)
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
hide();
dispose();
ParamSetup.helpWindowOpen = false;
}
});
}