我正在制作一个程序,当大写锁定打开时会显示给您。我希望它在 Windows 任务栏上显示一个小图标,包括电池、音量和互联网连接等图标。我只是想知道图像的尺寸可以/应该是多少。
我的 JPanel 上有一个 JTextArea、一个 Jlist 和其他一些东西,JTextArea 似乎在 TextArea 的右侧和底部周围放置了这个奇怪的边框。
我尝试使用textArea.setBorder(BorderFactory.createLineBorder(Color.black, 2));来摆脱它
这按预期添加了黑色边框,但我仍然得到奇怪的边框。这是一张图片。
我似乎无法删除文本区域的白色和灰色边框
我有一个边框布局,垂直和水平方向的间隙均为 5 像素。
编辑
我认为我的说法不正确,即使我不添加白色和灰色的“边框”,它仍然存在.setBorder()
我正在为学校创建一个小应用程序,这会减少你输入jTextField的时间.我还没有那么远,因为当我创建Swing Timer时,我得到了一些我无法弄清楚的错误.我用Google搜索了运气.
这是我的代码.
package randomGUIs;
import javax.swing.Timer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Timer extends javax.swing.JFrame {
String time;
Timer countDownTimer;
public Timer() {
initComponents();
ActionListener downTime = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
jLabel1.setText(time);
}
};
int countdown = 1000;
countDownTimer = new Timer(countdown, downTime);
countDownTimer.setRepeats(true);
};
Run Code Online (Sandbox Code Playgroud)
我得到的错误
错误:randomGUIs.Timer已在此编译单元中定义import javax.swing.Timer;
我正在使用Netbeans,并尝试取消选中"编译保存选项",但运气不错
我目前有一个JLabel嵌入式JTextPane使用这个:
import javax.swing.*;
import javax.swing.text.*;
public class MainFrame
{
JFrame mainFrame = new JFrame("Main Frame");
JTextPane textPane = new JTextPane();
public MainFrame()
{
String[] components = {"Title", "\n"};
String[] styles = {"LABEL_ALIGN", "LEFT_ALIGN"};
StyledDocument sd = textPane.getStyledDocument();
Style DEFAULT_STYLE = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style LEFT_STYLE = sd.addStyle("LEFT_ALIGN", DEFAULT_STYLE);
StyleConstants.setAlignment(LEFT_STYLE, StyleConstants.ALIGN_LEFT);
Style CENTER_STYLE = sd.addStyle("CENTER_ALIGN", DEFAULT_STYLE);
StyleConstants.setAlignment(CENTER_STYLE, StyleConstants.ALIGN_CENTER);
JLabel titleLbl = new JLabel("Title");
Style LABEL_STYLE = sd.addStyle("LABEL_ALIGN", DEFAULT_STYLE);
StyleConstants.setAlignment(LABEL_STYLE, StyleConstants.ALIGN_CENTER);
StyleConstants.setComponent(LABEL_STYLE, titleLbl);
for(int i = 0; i < components.length; …Run Code Online (Sandbox Code Playgroud)