首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏韩曙亮的移动开发专栏

    【Java AWT 图形界面编程】Container 容器 ③ ( ScrollPane 可滚动容器示例 )

    文章目录 一、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);

    68510编辑于 2023-03-30
  • 来自专栏FREE SOLO

    选择排序

    = 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

    77240发布于 2019-04-19
  • Java图形界面编程 AWT-容器篇

     - 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 组件。

    16310编辑于 2025-12-20
  • 来自专栏c/c++的学习笔记

    AWT的Container容器

    "); // 创建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的子容器。

    90510编辑于 2024-06-14
  • 来自专栏韩曙亮的移动开发专栏

    【Java AWT 图形界面编程】Container 容器总结

    一、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);

    1.5K10编辑于 2023-03-30
  • 来自专栏c/c++学习与分享

    java的图形化界面编程AWT与Swing学习记录与分享(其一container容器)

    ; //再将容器添加到窗口上 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("现在进行测试"));

    44110编辑于 2024-01-18
  • 来自专栏FREE SOLO

    Java利用数组随机抽取幸运观众

    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

    2.3K20发布于 2019-04-19
  • 来自专栏javafx框架tornadofx

    javafx框架tornadofx入门32_制作图标浏览工具

    } } iconTypes.forEach { tab(it) { scrollpane _tabs(it, this) prefWrapLengthProperty().bind((this@scrollpane } } } tab("Search Result") { scrollpane searchContainer = flowpane { prefWrapLengthProperty().bind((this@scrollpane

    1.7K30发布于 2020-05-18
  • 来自专栏大数据

    Java一分钟之-Swing组件:JTable, JTree, JTextArea

    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

    1.2K10编辑于 2024-05-30
  • 来自专栏https://blog.csdn.net/xia

    java高级编程——网络编程(解析网页中的内容)

    }); 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

    94210编辑于 2022-12-21
  • 来自专栏github@hornhuang

    Java-文本编辑器实现

    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

    1.2K10发布于 2021-09-24
  • 来自专栏RAIN7 de 编程之路

    Java Swing 期末大作业-----图书借阅管理系统

    (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));//

    4.5K40编辑于 2022-06-20
  • 来自专栏全栈程序员必看

    java 学生信息管理系统

    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);

    6.5K30编辑于 2022-09-14
  • 来自专栏我的前端之路

    【vite+vue3+Ts+element-plus】肩并肩带你写后台管理之主页面开发(侧边栏菜单生成、标签栏开发)

    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.

    5.5K31编辑于 2023-04-28
  • 来自专栏云计算linux

    Java编程之GUI教程 JPanel面板和JScrollPane

    jPanel.setLayout(new BorderLayout(0,0)); // 设置布局 11 jf.setContentPane(jPanel); 12 scrollPane =new JScrollPane(); 13 jPanel.add(scrollPane,BorderLayout.CENTER); 14 scrollPane.setViewportView

    1.4K10编辑于 2024-12-19
  • 来自专栏mythsman的个人博客

    基于Swing的简单文本编辑器

    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

    1.1K30编辑于 2022-11-14
  • 来自专栏给永远比拿愉快

    JavaFX入门(四):JavaFX布局(一)

    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

    14.1K42发布于 2019-01-22
  • 来自专栏愷龍的Blog

    java-GUI编程之布局类型介绍

    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 导致了该容器中只有一个组件被显示出来 。

    2.2K10编辑于 2022-09-26
  • 【Java】实现多线程计算阶乘(完整版)

    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

    12110编辑于 2025-12-22
  • 来自专栏若尘的技术专栏

    Java 基于JFrame的一个简单学生成绩管理系统(内含详细注释)

    (); 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

    1.7K87发布于 2021-05-15
领券