का उपयोग कर पैनल में विभाजक को कैसे आकर्षित करें यह एक मिगलाउट-न्यूबी प्रश्न है। मैं जानना चाहता हूं कि पैनल की चौड़ाई में एक लेबल के अंत से विभाजक को कैसे आकर्षित किया जाए।MigLayout
यहाँ मेरी उदाहरण कोड है:
package com.ndh.swingjunk;
import java.awt.*;
import javax.swing.*;
import net.miginfocom.swing.MigLayout;
class MyJFrame extends JFrame {
public MyJFrame() {
super();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("foo");
label.setFont(new Font("Tahoma", Font.BOLD, 11));
JSeparator separator = new JSeparator();
JLabel anotherLabel = new JLabel("some other label");
anotherLabel.setFont(new Font("Tahoma", Font.PLAIN, 11));
JButton button1 = new JButton("button 1");
JButton button2 = new JButton("button 2");
JPanel panel = new JPanel(new MigLayout());
panel.add(label);
panel.add(separator, "growx, wrap");
panel.add(anotherLabel);
panel.add(button1);
panel.add(button2);
getContentPane().add(panel);
pack();
}
}
public class SeparatorLayoutQuestion {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {new MyJFrame().setVisible(true);}});}}
और यहाँ परिणाम है:
जो बहुत लंगड़ा है। मैं पैनल के अंत में "फू" के अंत से फैलाने के लिए विभाजक, बटन भर में सभी तरह से करना चाहते हैं 2.