文章目录 一、ScrollPane 可滚动容器示例 一、ScrollPane 可滚动容器示例 ---- ScrollPane 可滚动容器 无法在 屏幕中独立存在 , 必须 依赖于 Frame 窗口而存在 ; 如果要 显示 ScrollPane 可滚动容器 , 需要 将其添加到 Frame 窗口中 才能显示出来 ; 代码示例 : import java.awt.*; public class HelloAWT 参数, 则总是显示滚动条 ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); // 向 ScrollPan 容器中添加 Component 组件 scrollPane.add(new TextField("测试文本")); scrollPane.add (new Button("测试按钮")); // 将 ScrollPan 添加到 Frame 窗口中 frame.add(scrollPane);
= new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 0; contentPane.add(scrollPane, gbc_scrollPane); gbc_scrollPane_1.insets = new Insets(0, 0, 5, 0); gbc_scrollPane_1.fill = GridBagConstraints.BOTH ; gbc_scrollPane_1.gridx = 0; gbc_scrollPane_1.gridy = 2; contentPane.add(scrollPane _1, gbc_scrollPane_1); textArea2 = new JTextArea(); scrollPane_1.setViewportView
- ScrollPane 是 Container的子类,表示一个具有滚动条的容器。 - 关键方法: - `setPreferredSize(Dimension d)`:设置 `ScrollPane` 的首选大小。 ScrollPane scrollPane = new ScrollPane(); scrollPane.add(new Button("按钮")); frame.add(scrollPane p1=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);//滚动面板,滚动条一直显示 //此时只能看到按钮,因为默认布局管理器的影响 p1.add 通过继承 Container类,Java 提供了多个容器类,如 Panel、Frame、Dialog、ScrollPane`等,开发者可以灵活地使用这些容器类来组织和管理应用程序的 UI 组件。
"); // 创建scroll pane对象,并指定默认有滚动条 ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS ); // 往ScrollPane添加组件 scrollPane.add(new TextField("测试文本")); scrollPane.add(new ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);:这是创建一个ScrollPane对象,并指定默认有垂直和水平滚动条 scrollPane.add(new Button("测试按钮"));:这是往ScrollPane容器中添加一个Button组件,用于触发事件。 frame.add(scrollPane);:这是把ScrollPane容器添加到Frame框架中,作为Frame的子容器。
一、AWT 简介 二、AWT 核心类继承体系 三、Container 容器类子类 四、Container 容器常用 API 五、Frame 窗口示例 六、Panel 示例 七、窗口中文乱码处理 八、ScrollPane 可滚动容器示例 ---- ScrollPane 可滚动容器 无法在 屏幕中独立存在 , 必须 依赖于 Frame 窗口而存在 ; 如果要 显示 ScrollPane 可滚动容器 , 需要 将其添加到 参数, 则总是显示滚动条 ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); // 向 ScrollPan 容器中添加 Component 组件 scrollPane.add(new TextField("测试文本")); scrollPane.add (new Button("测试按钮")); // 将 ScrollPan 添加到 Frame 窗口中 frame.add(scrollPane);
; //再将容器添加到窗口上 test.add(p); //使之可视化 test.setVisible(true); } } ScrollPane public class study { public static void main(String[] args) { Frame test=new Frame("这里演示scrollPane 容器"); //设置位置,大小 test.setBounds(100,200,1000,500); //创建scrollPane容器对象 ScrollPane sp=new ScrollPane(); //创建文本域和按钮同时添加进去 sp.add(new TextField("现在进行测试"));
panel.add(nameField, BorderLayout.NORTH); nameField.setColumns(10); JScrollPane scrollPane = new JScrollPane(); panel.add(scrollPane); personnelArea = new JTextArea(); personnelArea.setEditable(false); scrollPane.setViewportView(personnelArea); JPanel _1 = new JScrollPane(); panel_1.add(scrollPane_1); resultArea = new JTextArea(); resultArea.setEditable(false); resultArea.setLineWrap(true); scrollPane_1.setViewportView
} } iconTypes.forEach { tab(it) { scrollpane _tabs(it, this) prefWrapLengthProperty().bind((this@scrollpane } } } tab("Search Result") { scrollpane searchContainer = flowpane { prefWrapLengthProperty().bind((this@scrollpane
DefaultTableModel(data, columnNames); JTable table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add(scrollPane); frame.setVisible( JFrame.EXIT_ON_CLOSE); JTextArea textArea = new JTextArea("Enter your text here..."); JScrollPane scrollPane = new JScrollPane(textArea); frame.getContentPane().add(scrollPane); frame.setVisible
}); button.setText("解析网页"); panel.add(button); final JScrollPane scrollPane =new JScrollPane(); getContentPane().add(scrollPane,BorderLayout.CENTER); ta_content =new JTextArea(); ta_content.setFont(new Font("",Font.BOLD,14)); scrollPane.setViewportView
JMenuItem jMenuItem3; JMenuItem jMenuItem4; JSeparator jSeparator1; JTextArea jTextArea; JScrollPane scrollPane jMenuItem4 = new JMenuItem("退出"); jSeparator1 = new JSeparator(); jTextArea = new JTextArea(); scrollPane setLayout(); setSouthPanel(); // set relationship for your component setRelationShip(); // 设置 scrollPane setScscrollPane(); iniClick(); } private void setRelationShip() { jFrame.add(BorderLayout.CENTER, scrollPane (JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
(scrollPane); bookPane=new JPanel(new GridLayout(4,4)); //4行4列,需要创建每个组件,加到bookPane中,另外6个课后完成 (scrollPane); //4行4列,需要创建每个组件,加到bookPane中,另外6个课后完成 bookPane=new JPanel(new GridLayout (scrollPane); bookPane=new JPanel(new GridLayout(2,4)); labBookTypeID =new JLabel(" (scrollPane); bookPane=new JPanel(new GridLayout(2,4)); labTypeID =new JLabel("读者类型编号 =new JScrollPane(table); // 把表单加入查询面板 scrollPane.setPreferredSize(new Dimension(400,300));//
new JTable(update_table); button=new JButton("更新"); button.addActionListener(this); JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBounds(0,0,550,380); table.setPreferredSize(new Dimension (scrollPane.getWidth() - 50, scrollPane.getHeight()*2));//使表格出现滑动条 add(scrollPane); add(button); =new JScrollPane(table); scrollPane.setBounds(0,0,550,380); table.setPreferredSize(new Dimension( scrollPane.getWidth() - 50, scrollPane.getHeight()*2)); baseBox.add(scrollPane); add(baseBox);
this.cachedViews.push(view.name) } }, } 之后我们用router-link渲染一下数据 <el-scrollbar ref="<em>scrollPane</em> wrapRef.scrollLeft scrollLeft += eventDelta / 8 <em>scrollPane</em>.value.setScrollLeft(scrollLeft) } 关于滚动 $el.offsetWidth > <em>scrollPane</em>.value?.wrapRef.offsetWidth + <em>scrollPane</em>.value?. $el.offsetLeft < <em>scrollPane</em>.value?. wrapRef.scrollLeft + 20 if (isOut) { <em>scrollPane</em>.value?.scrollTo(item.
jPanel.setLayout(new BorderLayout(0,0)); // 设置布局 11 jf.setContentPane(jPanel); 12 scrollPane =new JScrollPane(); 13 jPanel.add(scrollPane,BorderLayout.CENTER); 14 scrollPane.setViewportView
TextEditer extends JFrame { private static final long serialVersionUID = 1L; private JScrollPane scrollPane textArea.setForeground(fgColor); textArea.setBackground(bgColor); textArea.setLineWrap(true);// 超出边界自动换行 scrollPane = new JScrollPane(textArea);// 加入滚动条 this.add(scrollPane); } private void setMenubar() { menubar
ScrollPane ScrollPane顾名思义就是可以显示滚动条的容器控件了。 我们在ScrollPane中放置一个TextArea文本域控件,并且设置TextArea的大小大于ScrollPane的大小,这样就可以显示出水平和垂直滚动条了。如下图: ? > <ScrollPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" javafx.com/fxml/1"> <content> <TextArea prefHeight="600.0" prefWidth="500.0" /> </content> </ScrollPane
BorderLayout管理其内部组件布局; Panel可以容纳其他组件,但不能独立存在,它必须内嵌其他容器中使用,默认使用FlowLayout管理其内部组件布局; ScrollPane "); //2.创建ScrollPane对象,并且指定默认有滚动条 ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS ); //3.往ScrollPane中添加组件 scrollPane.add(new TextField("这是测试文本")); scrollPane.add (new Button("这是测试按钮")); //4.把ScrollPane添加到Frame中 frame.add(scrollPane); //5 这是因为ScrollPane 使用 BorderLayout 布局管理器的缘故,而 BorderLayout 导致了该容器中只有一个组件被显示出来 。
5.notify方法,唤醒处于等待状态的线程 代码如下: import java.awt.BorderLayout; import java.awt.ScrollPane; import javax.swing.JButton frame.add(northPan, BorderLayout.NORTH); // 中间,记录计算过程与结果 consoleArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(consoleArea); frame.add(scrollPane, BorderLayout.CENTER); frame.setVisible(true
(); bSort = new JButton("排序"); textArea.setEditable(false); // 设置水平和垂直方向滚动条总是出现 JScrollPane scrollPane 窗口放大时,长度和宽度 constraints.weightx = 1.0; constraints.weighty = 1.0; gridBagLayout.setConstraints(scrollPane constraints.fill = GridBagConstraints.HORIZONTAL; gridBagLayout.setConstraints(bSort, constraints); panel2.add(scrollPane