JSplitPane가,
확인
하지만 (이클립스와 비교에서) 넷빈즈는 자바로 컴파일 된 경우
편집 I'd like to add a listener on it.
는
- 가 중첩 JSplitPane를위한
if (propertyName.equals(JSplitPane.XxxXxx))
통지하기위한 몇 가지 유용한 방법이다 예
대한의 JSplitPane 각각에는 별도로
를 수신기를 추가 할 필요는있는 JSplitPane에 PropertyChangeListener를 추가
.
import java.awt.Dimension;
import java.awt.GridLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
public class JSplitPaneToy {
public static void main(String[] args) {
JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, makePanel(), makePanel());
JPanel pnl = new JPanel();
pnl.setLayout(new GridLayout(4, 1, 10, 10));
pnl.add(makePanel());
pnl.add(makePanel());
pnl.add(makePanel());
pnl.add(makePanel());
PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent changeEvent) {
JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
String propertyName = changeEvent.getPropertyName();
if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
int current = sourceSplitPane.getDividerLocation();
System.out.println("Current: " + current);
Integer last = (Integer) changeEvent.getNewValue();
System.out.println("Last: " + last);
Integer priorLast = (Integer) changeEvent.getOldValue();
System.out.println("Prior last: " + priorLast);
}else if (propertyName.equals(JSplitPane.RESIZE_WEIGHT_PROPERTY)) {
int current = sourceSplitPane.getDividerLocation();
System.out.println("Current: " + current);
Integer last = (Integer) changeEvent.getNewValue();
System.out.println("Last: " + last);
Integer priorLast = (Integer) changeEvent.getOldValue();
System.out.println("Prior last: " + priorLast);
}
}
};
sp.addPropertyChangeListener(propertyChangeListener);
JFrame frame = new JFrame("JSplitPane Toy");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new GridLayout(0, 2, 10, 10));
frame.add(sp);
frame.add(pnl);
frame.pack();
frame.setVisible(true);
}
private static JScrollPane makePanel() {
JScrollPane pane = new JScrollPane(new JTable(
new Object[][]{{0, 1, 2}, {1, 2, 3}, {2, 3, 4}}, new Object[]{1, 2, 3}));
pane.setPreferredSize(new Dimension(200, 100));
return pane;
}
}
야호, 나는 그것을 생각 [JSplitPane.setContinuousLayout()] (http://docs.oracle.com/javase/7/docs/api/javax/swing/JSplitPane.html#setContinuousLayout (부울)) . – ignis
흠. 감사. 자바로 작성된 것 같습니다 : http://en.wikipedia.org/wiki/NetBeans. 노출 된 API에 JSplitPane을 가져 와서 최상위 구성 요소 크기를 조정하는 데 필요한 것이 있으면 궁금합니다. – nathan
리스너를 추가하고 싶습니다. – nathan