- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
出于某种原因,我无法向下滚动任何教导?我尝试添加到面板,然后将面板添加到滚动条,但没有任何效果。我需要一些帮助来解决这个问题,我已经存货好几个小时了。
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.AncestorListener;
public class StartActivity extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = -1470898831456146593L;
private JTextField textField;
public JTextField[] textStock = new JTextField[190];
public tags[] tags = new tags[90];
public String[] tg = new String[90];
public JList set = new JList();
private JPanel topPanel;
@SuppressWarnings("resource")
public StartActivity(){
setSize(1800, 900); // create an instance
setBackground(Color.gray);
setFocusable(true);
setLayout(null);
topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );
getContentPane().add(new JScrollPane());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//FileReader file = null; // get the tags and their name
//FileReader file2 = null;
InputStreamReader file;
InputStream is = getClass().getResourceAsStream("/resource/tagsName.txt");
InputStream is2 = getClass().getResourceAsStream("/resource/ref.txt");
file = new InputStreamReader(is);
InputStreamReader file2 = new InputStreamReader(is2);
//file = new FileReader("src/resource/tagsName.txt");
BufferedReader br = new BufferedReader(file);
try {
file2 = new FileReader("src/resource/ref.txt");
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BufferedReader br2 = new BufferedReader(file2);
// textField = new JTextField();
// textField.setBounds(35, 136, 86, 20);
// add(textField);
// textField.setColumns(10);
int x = 35;
int y= 136;
for (int i=0 ; i < 190 ; i++){ // add the text field to enter the quote
textStock[i] = new JTextField("");
textStock[i].setBounds(x,y,86,20);
getContentPane().add(textStock[i]);
textStock[i].setColumns(10);
y = y + 25;
if (y > 900){
y = 136;
x = x + 91;
}
}
JLabel label1 = new JLabel("Enter Stock Symbols");
label1.setBounds((x-35)/2, 100, 200, 20);
getContentPane().add(label1);
//addKeyListener(this);
String tg = "";
String rf = "";
x = x + 200;
y= 136;
int i = 0;
int z = x;
try { //
while((tg = br.readLine()) != null){ // add textfields to enter their tags
rf =br2.readLine();
tags[i] = new tags(tg, rf); // tags are a separte method that has their own info
tags[i].setBounds(x, y, 200, 23); // tags are declared as buttons
getContentPane().add(tags[i]);
y = y + 28;
if (y > 900){
y = 136;
x = x + 205;
}
tg = "";
i = i +1;
}
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
br.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
JLabel label2 = new JLabel("Choose stock tags Retrival");
label2.setBounds((x+z)/2, 100, 200, 20);
getContentPane().add(label2);
//set = new JList();
JButton list1= new JButton("List 1");
list1.setBounds(35, 100, 89, 23);
list1.addActionListener(this);
getContentPane().add(list1);
JButton clear = new JButton("Clear");
clear.setBounds(130, 100, 89, 23);
clear.addActionListener(this);
getContentPane().add(clear);
JButton clearT = new JButton("Clear Tags");
clearT.setBounds(getWidth()/2, 100, 100, 23);
clearT.addActionListener(this);
getContentPane().add(clearT);
JButton run = new JButton("Run");
run.setBounds(getWidth()/2, 32, 89, 23);
run.addActionListener(this);
getContentPane().add(run);
JButton analyse = new JButton("Analyse");
analyse.setBounds(getWidth()/2 - 200, 32, 89, 23);
analyse.addActionListener(this);
getContentPane().add(analyse);
//Frame frame = (Frame) this.getParent().getParent();
//frame.setTitle(" Financial Analysis");
try {
} catch (Exception e) {
// TODO: handle exception
}
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
/**
* call method depending on their button
*/
System.out.println(arg0.getActionCommand());
if (arg0.getActionCommand()== "Run"){
stockdata();
}
//System.out.println("true");
if (arg0.getActionCommand()== "List 1"){
listSet(1);
}
if (arg0.getActionCommand()== "Analyse"){
choose();
System.out.println(arg0.getActionCommand());
}
if (arg0.getActionCommand()== "Clear"){
clear();
System.out.println(arg0.getActionCommand());
}
if (arg0.getActionCommand()== "Clear Tags"){
clearT();
System.out.println(arg0.getActionCommand());
}
}
private void clearT() {
// TODO Auto-generated method stub
for (int i=0 ; i < 190 ; i++){
try{
tags[i].setState(false);
tags[i].setStatus(false);
}catch(Exception e){
}
}
}
private void clear() {
// TODO Auto-generated method stub
for (int i=0 ; i < 190 ; i++){
textStock[i].setText("");
}
}
private void choose() {
/*
* analyse quotes with parameters that I choose
*/
int m =0;
String[] quotes = new String[200];
int s =0;
String[] tq = new String[20];
String qurl = "http://finance.yahoo.com/d/quotes.csv?s=";
for (int i=0 ; i < 60 ; i++){
String stock =textStock[i].getText();
if (m == 0 && stock != ""){
qurl = qurl + stock ;
m =1 ;
quotes[s] = stock;
s=s+1;
}
else if(stock != ""){
qurl = qurl +"+"+ stock ;
quotes[s] = stock;
s=s+1;
}
}
qurl = qurl + "&f=l1vhgd1rp6";
System.out.println(qurl);
Analysis tab = new Analysis(qurl, quotes); // param are declared in another method
tab.setVisible(true);
}
private void stockdata() {
/*
* retrieves stock data
*/
int m =0;
String[] tq = new String[20];
String[] quotes = new String[200];
int s =0;
String qurl = "http://finance.yahoo.com/d/quotes.csv?s=";
for (int i=0 ; i < 60 ; i++){
String stock =textStock[i].getText();
if (m == 0 && stock != ""){
qurl = qurl + stock ;
quotes[s] = stock;
s=s+1;
m =1 ;
}
else if(stock != ""){
qurl = qurl +"+"+ stock ;
quotes[s] = stock;
//System.out.println(quotes[s]);
s=s+1;
}
}
qurl = qurl + "&f=";
int z =0;
for (int i=0 ; i < 60 ; i++){
if(tags[i].getStatus()){
qurl = qurl + tags[i].getReference();
tq[z]= tags[i].getName();
z =z+1;
}
}
System.out.println(qurl);
// this method retrives data and creates a table to show them
StockData tab = new StockData(qurl, tq, quotes);
tab.setVisible(true);
}
private void listSet(int fileNumber){
// this method populates a set of stocks
InputStream is = getClass().getResourceAsStream("/resource/set"+fileNumber + ".txt");
InputStreamReader file = new InputStreamReader(is);
BufferedReader br = new BufferedReader(file);
String tg;
int i = 0;
try {
while((tg = br.readLine()) != null){
if (i<190){
textStock[i].setText(tg);
i = i +1;
}}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main( String args[] )
{
StartActivity mainFrame = new StartActivity();
mainFrame.setVisible( true );
}
最佳答案
所以我认为这两行代码是问题所在...
getContentPane().add( topPanel );
getContentPane().add(new JScrollPane());
如果我没记错的话,您需要将面板添加到 JScrollPane,然后将 JScrollPane 添加到框架。所以做类似的事情
getContentPane().add(new JScrollPane(topPanel));
我认为这就足够了。
关于java - 无法向下滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23186750/
我正在使用面部跟踪进行 HCI(人机交互)。我正在尝试使用面部控制 PC。 我有 3x3 二维网格按钮。1 2 34 5 67 8 9 假设,当前焦点在按钮 5 上。如果我按向上箭头,则焦点将在 2
我正在为蛇和梯子制作一 block 板,到目前为止,我已经按降序打印了板。但是,我需要以正确的方式打印电路板。 编辑“螺旋下降”意味着 100...91 81...90 80...71 ...
我有一个可以响应式调整大小的菜单,因此每次调整大小时 div (#menuWFhover) 的内容都会重新排列,因此 div 根据窗口大小具有不同的高度。 当我使用 jQuery slideDown/
我们从服务器获取数据并附加 ListView 。我们的问题是,当向上/向下滚动时,它首先显示白屏,然后显示数据。向下/向上滚动时,之前出现的白屏应删除 for (var i=0; i");
我想要一个汉堡图标动态改变颜色的代码,以适应网站的黑色部分/部分和白色。它最初是 3 段白色,js 代码几乎是好的和正确的,但是当它在白色部分时它一直闪烁,并在红色和白色之间闪烁。 js var to
我对点击事件的页脚位置有疑问。我正在使用 bootstrap css,我有一个可折叠元素(bootstrap 中的 Accordion ),当它折叠时它有一个名为 .accordion-toggle.
在此代码段中,使用关键帧和动画并显示无/ block ,div 动画以在悬停时向下滑动。 h1 { padding: 20px; } div { width: 100%; background
我需要对一个 float 进行四舍五入。例如 4.00011 。内置函数 round() 总是在数字 > .5 时向上舍入,在 = 0 val *= 10 ** precision r
我正在尝试就地缩小文件。 我正在用另一个文件的内容替换一个文件的内容,完成后我想确保源文件是否小于目标文件,目标文件是否正确收缩。 (为什么:因为dest文件是一个备份,写入media的开销很大,所以
似乎每当我用一个负整数除以一个正整数时,我都需要它向下舍入 (向 -inf),而不是向 0。但 C# 和 C++ 都向 0 舍入。 所以我想我需要一个 DivideDownward() 方法。我可以用
考虑这个简单的代码: document.addEventListener( 'keypress', function() { console.log( 'press' ); } ); document
有什么方法可以检查 Azure 资源(例如 Azure IoT 中心或事件中心)是否可用。我所说的可用是指它是否已关闭/工作/正常/启动?我是 Azure 的新手,如果有人能提供一些启发,那就太好了。
有什么方法可以检查 Azure 资源(例如 Azure IoT 中心或事件中心)是否可用。我所说的可用是指它是否已关闭/工作/正常/启动?我是 Azure 的新手,如果有人能提供一些启发,那就太好了。
我见过几个recyclerview的无限滚动示例,但它们都是向下滚动的。 我想要的是一次又一次地加载我的列表,但无论用户是从上面还是从下面滚动。 正常列表 向上滚动 向下滚动 这样可以通过无限滚动一遍
我正在使用带有 View 的 drupal 7,并且我正在使用我发现的向上/向下文本幻灯片的 jquery 脚本。它有效,但是当我尝试将它与带有 ajax 的 View 公开过滤器一起使用时,它似乎不
*场景 我希望制作一个类似于本网站上的 jquery 效果,它位于主 Flash 添加的右侧: http://www.commbank.com.au/ *问题 我已经开始了,但是用很多方法遇到了一些障
互联网。如果这与其他人没有什么关系,请原谅我,但我会将其留在这里,以防这是一个有效的问题。 我正在尝试创建一个文本区域字段,其中用户每次按下键(a-z),都会触发背景颜色更改(在数组中列出)。我一直在
我正在创建一个网络前端来控制一个小型机器人。 Ajax 调用将在 keydown 上进行,以启动机器人,并在 keyup 上进行停止。 我的问题是,当按下某个键时,keyup、keydown 和 ke
我在内容容器中有两个 div,一个向左浮动,另一个向右浮动。我正在使用屏幕的整个宽度。左 div 宽度为 1290px,右 div 宽度为 625px。有时,在加载页面时,滚动条会更改可用屏幕宽度的宽
请看这个UI sketch图片,我在某个站点的侧边栏(黑框)中有这个 div,当我向下滚动或向上滚动时,我不希望它隐藏...我希望它在我向下滚动和移动时自行向下移动当我向上滚动时向上滚动,这样它就永远
我是一名优秀的程序员,十分优秀!