jscrollpane

JScrollPane and JPanel

拈花ヽ惹草 提交于 2021-02-16 13:44:45
问题 So, I'm making a kind of text editor, and I need a JScrollPane for vertical navigation. But I can't get it to work. I have read every freaking tutorial on first ten pages of google results, and I can't get it to work. Lets say I have JFrame (size 1000x800). I want to put a JPanel (1000x2000) in it so that it horizontally alignes with the JFrame. I want to stick a simple scroll bar to the right side of the JPanel so I can get to the rest of it. I have reduced sizes, I have added JPanel to

How to use the JScrollPane in Java

风格不统一 提交于 2021-02-08 07:10:47
问题 How can I get the scroller around my JList component in the code given below? It doesn't seem to work properly :( public class JButtonO extends JFrame{ String[] values = {"henry", "Michael","Uche","John","Ullan","Nelly", "Ime","Lekan","Austine","jussi","Ossi","Imam","Empo","Austine","Becky", "Scholar","Ruth", "Anny"}; public JButtonO() { super("the button"); this.setSize(400,200); JPanel panel = new JPanel(); JLabel label = new JLabel("Output Items:"); label.setAlignmentX(1); label

How to use the JScrollPane in Java

霸气de小男生 提交于 2021-02-08 07:06:21
问题 How can I get the scroller around my JList component in the code given below? It doesn't seem to work properly :( public class JButtonO extends JFrame{ String[] values = {"henry", "Michael","Uche","John","Ullan","Nelly", "Ime","Lekan","Austine","jussi","Ossi","Imam","Empo","Austine","Becky", "Scholar","Ruth", "Anny"}; public JButtonO() { super("the button"); this.setSize(400,200); JPanel panel = new JPanel(); JLabel label = new JLabel("Output Items:"); label.setAlignmentX(1); label

JScrollPane doesn't top align when there is more than enough space to show the content

房东的猫 提交于 2021-01-28 04:27:29
问题 I have a JScrollPane that show a list of items. I would like the user to be able to scroll through the list if there is not enough space on the screen to show the list and I would like the list to align to the top of the available space if there is more than enough space to show the list. I can do one or the other but can't seem to get both to work. The code shown below accomplishes the goal of allowing the list to be scrollable if the list is larger than the available space but does not

JScrollPane doesn't show scroll bars when JPanel is added

空扰寡人 提交于 2021-01-28 01:45:20
问题 I'm tried to add a JPanel to a JScrollPane using: panel1 Panel1 = new panel1(); jScrollPane1.setViewportView(Panel1); and it worked. But the problem is scrollPane doesn't show scroll bars even the Panel1 is bigger. (I'm working with NetBeans & panel1 is a jpanel form) 回答1: Override, getPreferredSize() method for the said JScrollPane , you might be able to see the Scroll Bar. Or one can simply call setPreferredSize(), though as stated in the API Sets the preferred size of this component. If

How to make JPanel scrollable?

不问归期 提交于 2021-01-27 18:30:23
问题 I'm creating GUI for my university project and I 'm trying to understand how JScrollPane works. I have successfully written simple program which shows picture in a scrollable way: public class ScrollPaneTest{ public static void main(String[] args){ JFrame testFrame = new JFrame("ramka testowa"); testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel picture = new JLabel(new ImageIcon("JavaSwingCompoentsList.PNG")); JScrollPane scrollPane = new JScrollPane(picture); testFrame.add

Java期末总结

﹥>﹥吖頭↗ 提交于 2021-01-16 06:00:36
经过这一学期对java的学习,对java已经能够初步运用,就是有些有点不记得,得看书或网上查阅使用方法。 相较C语言,java还是有很多大不同之处,却也有着许多相似之处 我也就本学期所学总结一下: 1、先了解java并搭建开发环境jdk。 2、关键字this、static、super、final、instanceof、throw和throws。 this: (1)表示类中的属性; (2)可以使用this调用本类的构造方法; (3)this表示当前对象; (4)用this强调本类中的方法。 static: (1)使用static声明属性; (2)使用static声明方法。 super:使用super调用父类中的指定构造方法(语句必须放在子类构造方法的首行)。 final: (1)使用final声明的类不能有子类; (2)使用final声明的方法不能被子类所覆写; (3)使用final声明的变量即成为常量,常量不可以修改。 instanceof:用来判断一个对象到底是哪个类的实例。 throws:在定义一个方法的时候可以使用throws关键字声明,使用throws声明的方法表示此方法不处理异常,而交给方法的调用处处理。 throw:与throws关键字不同的是,可以直接使用throw关键字抛出一个异常。抛出时直接抛出异常类的实例化对象即可。 3、java中线程的实现: (1

JScrollPane don't appear on JTextArea

三世轮回 提交于 2020-11-29 19:11:47
问题 I have next problem, JScrollPane don't appear on JTextArea and I don't know why? I tried in many ways but nothing, it don't want to show me! I put below a part of the code. All appears correctly, JFame, JTextArea, text inside JTextArea, all without JScrollPane. Please, can somebody help me? package pachet; import java.awt.BorderLayout; import java.awt.Container; import java.util.ArrayList; import javax.swing.GroupLayout; import static javax.swing.GroupLayout.Alignment.BASELINE; import javax

JScrollPane don't appear on JTextArea

為{幸葍}努か 提交于 2020-11-29 19:08:19
问题 I have next problem, JScrollPane don't appear on JTextArea and I don't know why? I tried in many ways but nothing, it don't want to show me! I put below a part of the code. All appears correctly, JFame, JTextArea, text inside JTextArea, all without JScrollPane. Please, can somebody help me? package pachet; import java.awt.BorderLayout; import java.awt.Container; import java.util.ArrayList; import javax.swing.GroupLayout; import static javax.swing.GroupLayout.Alignment.BASELINE; import javax

JScrollPane don't appear on JTextArea

喜夏-厌秋 提交于 2020-11-29 19:03:06
问题 I have next problem, JScrollPane don't appear on JTextArea and I don't know why? I tried in many ways but nothing, it don't want to show me! I put below a part of the code. All appears correctly, JFame, JTextArea, text inside JTextArea, all without JScrollPane. Please, can somebody help me? package pachet; import java.awt.BorderLayout; import java.awt.Container; import java.util.ArrayList; import javax.swing.GroupLayout; import static javax.swing.GroupLayout.Alignment.BASELINE; import javax