在此JPanel上移动此JLabel时遇到问题?我把代码放在下面。基本上应该发生的是,被称为"guy“的JLabel慢慢向右移动。唯一的问题是,JLabel没有刷新,在我第一次移动它之后,它就消失了。
public class Window extends JFrame{
JPanel panel = new JPanel();
JLabel guy = new JLabel(new ImageIcon("guy.gif"));
int counterVariable = 1;
//Just the constructor that
我试图根据用户的输入动态生成制表符及其包含的文本字段。在显示的代码中,输入是noTCPFlows。但是当我运行代码时,我总是得到这样的异常:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at javax.swing
我可以使用add(新的Jlabel())在Jpanel构造函数中在Jpanel上创建label,但是一旦我使用其他函数调用add(),标签就不会显示在面板上。我做错什么了?
public class DisplayPanel extends JPanel {
JLabel headerField = new JLabel("Choose a file to generate report.");
JLabel dateField = new JLabel("123");
JLabel meanField =
我有这样的东西..。
中的JLabels在JPanels中的一堆
-JFrame
--JPanel
--Set<JPanel>
--JLabel object contained in each JPanel object cotained in the set
我想要创建一个外部面板/框架,这样每次我在每个单独的JPanel上悬停时,就会弹出一个新的框架/面板,给我一些数据。这将在本质上与JFrame重叠。
它很简短,但我只是需要一些指导,我需要什么,我需要查找。
我用JFrame、JPanel、JLabel和JButton创建了一个GUI。
// JFrame
Jframe f = new JFrame("");
// JButton
JButton b = new JButton("button1");
// JLabel
JLabel l = new JLabel("panel label");
// JPanel
JPanel p = new JPanel();
我将按钮和标签添加到面板中。我为按钮添加了两个ActionListener。
b.add
我遇到了NullPointerException的麻烦,这是
public class Grid extends JFrame {
private JLabel[][] grid;
public Grid(int max) { //from Constructor
int s = max;
int v = max;
Container cont = getContentPane();
cont.setLayout(new BorderLayout());
JPanel p1 = new JPanel(new BorderLayout());
我想让jpanel1看不见,直到其中一个jlabels被鼠标移到上面。然后,JPanel1必须变为可见,并且JLable(称为jLabel1)必须将其图像设置为鼠标所在的JLabel之一。
public GUI()
{
initComponents();
jPanel1.setVisible(false);
for(int i =4; i<12;i++)
{
JLabel l = new JLabel();
l.setIcon(new ImageIcon(i+".jpg"));
p1
public void testDialog()
{
JPanel myPanel = new JPanel(new GridBagLayout());
GridBagConstraints grid = new GridBagConstraints();
grid.gridx=0; //Moves Things across
grid.gridy=0; //Moves things down
myPanel.add(new JLabel("ENTER PLAYER NAMES", JLa
我正在处理Swing应用程序,我需要将动态滚动窗格添加到选项卡式窗格中,我需要将Jpanel添加到每个滚动窗格中。那么,我如何添加它呢?我尝试过一个代码,但它没有添加滚动窗格。我能帮忙吗。
这是我的密码。
public class ChatDialog_Tabbedpane extends javax.swing.JFrame {
static JLabel jLabelchat;
int i= 0;
public ChatDialog_Tabbedpane() {
initComponents();
setVisible(true);
我在一个JPanel里面有5个JLabels,它在一个JFrame里面。我使用一个循环来添加JLabels,该循环遍历一个颜色数组:
private JLabel target;
// This is the origin of the first label added.
Point origin = new Point(10, 20);
// This is the offset for computing the origin for the next label.
int offset = 200;
for (int i = 0; i < layerColors.l
我有一个可能很容易解决的问题。我使用Intellij Idea构建了一个GUI表单。现在,我正在尝试更改imageLabel JLabel的imageIcon。 我真的不明白为什么,但是当我使用JLabel.setIcon()时,它既没有抛出异常,也没有显示图像。我不知道它出了什么问题。这似乎是一个非常简单的命令。 (我添加了ico.getImage().flush();行,因为当我在周围搜索时,有人说你必须在显示之前刷新图像。我实际上并不知道这一行是做什么的。) 谢谢你的帮助。 public class App
{
private JPanel mainPanel;
pri
我想用两个JFrame显示一个JPanels。为了简单起见,我在JPanel的右半部分实现了一个“占位符”JFrame。我想要在JFrame的左侧实现这一点,它显示了一个JPanel,它是
( a)水平方向不可调整大小(应具有固定宽度)。
( b)左JPanel的类应该有一种方法,将JLabels尽可能地放在JPanel上(第一个JLabel尽可能高,第二个JLabel在第一个JLabel下,第三个JLabel在第二个JLabel下等等),最好位于左JPanel的中心。
我的代码是:
public class Test extends JPanel {
public Test()
因此,我从基本的可视Java组件开始,在准确地使用它们方面遇到了麻烦。
这是我的新问题:我正在尝试实现一个3部分的面板:东、中、西,但无法正确显示中心面板。下面是我的一段代码:
基本上'panelUpMiddle‘是不可见的,所以我想知道为什么?
public class TestCode_Web {
public static void main(String[] args) {
JFrame window = new JFrame("Test");
window.setDefaultCloseOperation(JFrame.EXIT_ON_C
public class ExamplePane extends javax.swing.JFrame {
public ExamplePane() {
// this is constructor
initComponents();
}
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {
jPanel1.setVisible(true);
jPan
最近,我一直试图得到一个透明的JFrame,但没有成功。
我想使所有组件可见,但不是框架,我看到人们将背景设置为透明,并将不透明设置为假。
我正在做这件事,但没有成功。
public class KeyDialog extends JFrame {
public static MapPanel mapPanel = new MapPanel();
public KeyDialog() {
GridBagConstraints customGridBagLayout = new GridBagConstraints();
setLayout(ne
你知道如何以一种好的方式同时显示多个弹出式菜单吗?(对于JPopupMenu)我尝试@Override show(Component invoker, int x, int y),并设法通过移除setInvoker(invoker);同时显示多个弹出式菜单。这样做的问题是我无法以任何方式删除弹出窗口。
问:你知道如何让JPopupMenu在显示更多JPopupMenu时仍然可见,但在其他情况下照常工作(关闭/隐藏其他操作)?
public class MultiPopupMenu {
public static void main(String[] args){
/