我使用GridBagLayout
并在其上放置JLabel
,如图所示。我设法通过JLabel
和ipadx
将ipady
的大小设置为所需的大小,但我似乎无法使用它的位置。它看起来总是以中间为中心,而我想从红点开始并且在我调整窗口大小时不要重新定位。我该怎么办?
感谢。我使用的代码也是:
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
JLabel jl = new JLabel("This is a jlabel!", SwingConstants.CENTER);
jl.setBorder(BorderFactory.createLineBorder(Color.black));
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.ipadx = 87;
gbc.ipady = 220;
add(jl, gbc);
答案 0 :(得分:1)
我对它进行了改进...现在你可以使用插图来标记Dimension d = new Dimension(350, 400);
GridBagLayout gbl = new GridBagLayout();
JFrame frame = new JFrame("Heloo");
frame.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
JLabel jl = new JLabel("This is a jlabel!", SwingConstants.CENTER);
jl.setBorder(BorderFactory.createLineBorder(Color.black));
gbc.ipadx = 87;
gbc.ipady = 220;
gbc.insets = new Insets(0, 0, 360, 340);// here work with JFrame size!!
周围的标签,但经过一些研究后我建议选择不同的layout manager。
所以你的代码看起来像是:
SELECT
DATEDIFF(d, ts.minimum, ts.maximum)/ ts.EntryAmount as Frequency
,ts.column1, ts.column2, ts.column3, ts.column4
FROM
(
SELECT
COUNT(*) as EntryAmount,
max(Date) AS maximum,
min(Date) AS minimum,
column1, column2, column3, column4
FROM Times
GROUP BY column1, column2, column3, column4
HAVING COUNT(*) > 1
) ts
希望此代码能为您提供帮助:)