- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的代码有一点问题。我创建了一个 5,1,0,0 的网格布局。我有一个文本字段、3 个按钮和一个标签,其中用户输入的结果分析显示在底部。现在结果可以出现在多行上,具体取决于句子中的单词有多大,我的问题是当显示多行结果时,我的程序的布局发生变化,我不知道如何保持它相同,而只是标签或如果需要,Applet 窗口本身可以调整大小吗?
public class assignment_tauqeer_abbasi extends JApplet implements ActionListener {
JTextArea textInput; // User Input.
JLabel wordCountLabel; // To display number of words.
public void init() {
//这里的这段代码是Applet的定制,包括背景色、文字颜色、文字背景色、标签和按钮
setBackground(Color.black);
getContentPane().setBackground(Color.black);
textInput = new JTextArea();
textInput.setBackground(Color.white);
JPanel south = new JPanel();
south.setBackground(Color.darkGray);
south.setLayout( new GridLayout(5,1,0,0) );
/* Creating Analyze and Reset buttons */
JButton countButton = new JButton("Analyze");
countButton.addActionListener(this);
south.add(countButton);
JButton resetButton = new JButton("Reset");
resetButton.addActionListener(this);
south.add(resetButton);
JButton fileButton = new JButton("Analyze Text File");
fileButton.addActionListener(this);
south.add(fileButton);
/* Labels telling the user what to do or what the program is outputting */
wordCountLabel = new JLabel(" No. of words:");
wordCountLabel.setBackground(Color.black);
wordCountLabel.setForeground(Color.red);
wordCountLabel.setOpaque(true);
south.add(wordCountLabel);
/* Border for Applet. */
getContentPane().setLayout( new BorderLayout(2,2) );
/* Scroll bar for the text area where the user will input the text they wish to analyse. */
JScrollPane scroller = new JScrollPane( textInput );
getContentPane().add(scroller, BorderLayout.CENTER);
getContentPane().add(south, BorderLayout.SOUTH);
} // end init();
public Insets getInsets() {
// Border size around edges.
return new Insets(2,2,2,2);
}
//Applet定制结束
这是我的布局代码。任何帮助将不胜感激!
最佳答案
GridLayout 将根据最大单元格的内容调整每个单元格的大小。考虑使用 different layout ,或 combination of layouts相反。
关于Java Applet网格布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21996543/
我有一个java小程序,它访问客户端文件系统上的文件。为此,我为我的小程序创建了一个 jar,然后对其进行了签名,现在一切正常。 问题:有什么方法可以让我对小程序类本身进行签名,而不是先创建一个 ja
我制作了一个向用户致意的 Loader Applet,当用户单击该 Applet 上显示的按钮时,它会启动主 applet,并且 Loader Applet 被销毁。 但是点击另一个小程序没有启动!
我是小程序的新手,遇到了一些不寻常的事情。在我经历的一个程序中,applet html tag在 Applet Java file (.java) 中作为评论提及但评论似乎正在执行。这怎么可能? 代码
只是想知道是否有人有过通过 Java Applet 安装硬件驱动程序的经验。我目前正在编写一个小程序,它将访问某些硬件并将嵌入到网页中。为了让最终用户更轻松,我想让它检测是否安装了驱动程序,如果没有安
我在一家政府科学机构工作,该机构通过我们的网站提供大量技术信息。 Web 开发并不是我们真正的强项,但我们过得去。我们当前的许多内容都是通过 Java 小程序提供的。最近我们收到用户的反馈,他们无法访
我不知道是否存在解决方案,但这将是非常可取的。 我正在制作一个 Scala 小程序,我希望主 Applet 类是一个单例,以便可以在小程序的其他地方访问它,有点像: object App extend
import java.util.InputMismatchException; import java.util.Scanner; class Rectangle extends Shape
我的小程序代码编译得很好,但是,我每次都会收到“小程序已启动”消息。请不要阻止我使用 AWT 或 Applet。我只是想完成我的任务。目前,我的代码是: 主要方法 import java.awt.*;
在 Java Card 中,通常是否可以从卡上现有应用程序的上下文中安装新应用程序,例如通过应用程序定义的消息格式发送新代码,然后使用某些卡创建新应用程序实例管理器 API? 还是只能在外部使用相应的
我刚刚开始编写小程序,因此以前从未嵌入过网页。我有 2 个小程序,它们本身运行良好,但是当我尝试在同一页面中运行这 2 个小程序时,只有一个可见。这看起来很奇怪,我尝试为每个小程序使用开始和结束 fo
我有点.NET 导向,并且对Java 很陌生。使用 Eclipse IDE,每当我通过 Applet 扩展我的类时: class xyz extends Applet{ . . . }; 这会产生错误
要创建Applet程序,程序员需要从Applet包继承Applet类,并且Applet类是一个抽象类,这意味着它的继承类必须覆盖Applet类中的所有方法,但Applet则不是这样。程序员可能会或可能
我似乎在这方面找不到任何东西——除了它不能嵌入到 WebView 中。 我目前有一个图像查看产品,可以通过小程序访问并通过 HTML 页面中的 JavaScript 进行控制。 我正在研究使用 Jav
我刚刚学习java applet。我用drawLine()在小程序上画了一条线,当我按下运行时,它正常编译并使用Eclipse的内置小程序查看器显示小程序。这是代码 import java.apple
当我尝试使用 java.applet.Applet 时,出现运行时错误: java.lang.NoClassDefFoundError: java.applet.Applet 我曾尝试手动放置该库,但
我想知道是否有一种方法可以让 Java 类确定它是否在 applet 中使用? 也就是说,我有一个可供第 3 方应用程序和小程序使用的库(一个 .jar 文件)。它确实在 applet 中工作,但我想
我只想在空框架中添加一个按钮,这非常非常简单。 框架没有显示任何内容,尽管程序运行,IDE 告诉我:” java.lang.ClassCastException: Spots cannot be ca
小程序由以下代码组成: public class TestApplet extends Applet { public TestApplet() { EventQueue.invokeLate
我开始问这个问题,然后在提交之前找出答案。我决定无论如何都要发布这个问题,以便遇到同样问题的其他人能够从我的错误中吸取教训。 我遇到了一个小程序问题(实际上是一个 JApplet)无法实例化另一个类,
如何为现代浏览器部署 Java 小程序?我知道有 3 种可能性,但没有人告诉我更喜欢哪一种以及如何使用它们。 有人有这方面的资源吗?我找不到任何:( 最佳答案 如果您可以针对 Java 6 更新 10
我是一名优秀的程序员,十分优秀!