English 中文(简体)
从0到99的上升按钮
原标题:ascending buttons from 0 to 99

我需要我的县从零开始,进入右上角。 请帮助我纠正我的法典。 我为固定它所做的每一次工作,都要让所有县都更低,我也迫切需要:

   private void crear()
   {
      for (i=0; i<100; i++)
      {
         btn_boton = new JButton(String.valueOf(i));
         btn_boton.setBounds(50+55*(i%10),325+25*(i/10),50,20);
         btn_boton.addActionListener(this);
         ventana.add(btn_boton);
      }
      ventana.repaint();

   }

请将此翻译成中文:enter image description here 无法翻译。因为这是一个指向图片的链接,没有文字。

求助按钮...和文本框,等等

9
8
7
6
5
4
3
2
1
0  10  20  30  40  50  60  70  80  90
问题回答

利用适当的布局。 先看

以下示例使用了GridBagLayout,这样我可以从右到左跨越行。

将此翻译成中文:enter image description here 无法翻译,因为这是一张图片。

import java.awt.EventQueue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                JFrame frame = new JFrame();
                frame.add(new TestPane());
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }

    public class TestPane extends JPanel {
        public TestPane() {
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();

            int index = 99;
            for (int y = 0; y < 10; y++) {
                gbc.gridy = y;
                for (int x = 0; x < 10; x++) {
                    gbc.gridx = 10 - x;
                    add(new JButton(Integer.toString(index--)), gbc);
                }
            }
        }
    }
}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签