本文整理匯總了Java中javax.swing.SpringLayout.putConstraint方法的典型用法代碼示例。如果您正苦於以下問題:Java SpringLayout.putConstraint方法的具體用法?Java SpringLayout.putConstraint怎麽用?Java SpringLayout.putConstraint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.SpringLayout
的用法示例。
在下文中一共展示了SpringLayout.putConstraint方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GroupBox
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public GroupBox(final AbstractButton b)
{
button = b;
button.addItemListener(this);
button.setOpaque(true);
button.setBackground(this.getBackground());
final int buttonHeight = button.getPreferredSize().height;
inner = new JPanel();
inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
BorderFactory.createEmptyBorder(buttonHeight / 2, 5, 5, 5)));
final SpringLayout layout = new SpringLayout();
super.setLayout(layout);
super.add(button);
super.add(inner);
layout.putConstraint(SpringLayout.WEST, button, 10, SpringLayout.WEST, this);
layout.putConstraint(SpringLayout.NORTH, inner, buttonHeight / 2, SpringLayout.NORTH, this);
layout.putConstraint(SpringLayout.WEST, inner, 0, SpringLayout.WEST, this);
layout.putConstraint(SpringLayout.SOUTH, this, 0, SpringLayout.SOUTH, inner);
layout.putConstraint(SpringLayout.EAST, this, 0, SpringLayout.EAST, inner);
}
示例2: AFrame
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public AFrame(String title) {
super(title);
contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
JPanel panel = new JPanel();
contentPanel.add(panel);
JPanel pan = new JPanel();
contentPanel.add(pan);
SpringLayout slPanel = new SpringLayout();
pan.setLayout(slPanel);
animalButton = new JButton("Animal");
slPanel.putConstraint(SpringLayout.NORTH, animalButton, 65, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, animalButton, 93, SpringLayout.WEST, pan);
pan.add(animalButton);
employeeButton = new JButton("Employee");
slPanel.putConstraint(SpringLayout.NORTH, employeeButton, 100, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, employeeButton, 93, SpringLayout.WEST, pan);
pan.add(employeeButton);
JPanel rightPanel = new JPanel();
contentPanel.add(rightPanel);
setVisible(true);
}
示例3: EmployeeFrame
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public EmployeeFrame(String title) {
super(title);
contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
JPanel panel = new JPanel();
contentPanel.add(panel);
JPanel pan = new JPanel();
contentPanel.add(pan);
SpringLayout slPanel = new SpringLayout();
pan.setLayout(slPanel);
caretakerButton = new JButton("Caretaker");
slPanel.putConstraint(SpringLayout.NORTH, caretakerButton, 65, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, caretakerButton, 93, SpringLayout.WEST, pan);
pan.add(caretakerButton);
JPanel rightPanel = new JPanel();
contentPanel.add(rightPanel);
setVisible(true);
}
示例4: EmployeeFrame
import javax.swing.SpringLayout; //導入方法依賴的package包/類
/**
*
* @param title
* The title of the frame.
*/
public EmployeeFrame(final String title) {
super(title);
contentPanel.setLayout(new GridLayout(0, 1, 0, 0));
JPanel pan = new JPanel();
contentPanel.add(pan);
SpringLayout slPanel = new SpringLayout();
pan.setLayout(slPanel);
Caretaker = new JButton("Caretaker");
slPanel.putConstraint(SpringLayout.NORTH, Caretaker, 180, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, Caretaker, 280, SpringLayout.WEST, pan);
pan.add(Caretaker);
JPanel panel_2 = new JPanel();
contentPanel.add(panel_2);
setVisible(true);
}
示例5: PlainTextGenerator
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public PlainTextGenerator() {
SpringLayout layout = new SpringLayout();
JLabel label = new JLabel("Text: ");
JScrollPane scrollPane = new JScrollPane(textarea);
textarea.setLineWrap(true);
panel.setLayout(layout);
panel.add(label);
panel.add(scrollPane);
layout.putConstraint(NORTH, label, 5, NORTH, panel);
layout.putConstraint(WEST, label, 5, WEST, panel);
layout.putConstraint(NORTH, scrollPane, 5, SOUTH, label);
layout.putConstraint(SOUTH, scrollPane, -5, SOUTH, panel);
layout.putConstraint(EAST, scrollPane, -5, EAST, panel);
layout.putConstraint(WEST, scrollPane, 5, WEST, panel);
}
示例6: UrlGenerator
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public UrlGenerator() {
SpringLayout layout = new SpringLayout();
JLabel label = new JLabel("URL: ");
txtUrl.setText("http://");
panel.setLayout(layout);
panel.add(label);
panel.add(txtUrl);
layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, panel);
layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.WEST, txtUrl, 5, SpringLayout.EAST, label);
layout.putConstraint(SpringLayout.NORTH, txtUrl, 5, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.EAST, txtUrl, -5, SpringLayout.EAST, panel);
}
示例7: PhoneNumberGenerator
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public PhoneNumberGenerator() {
SpringLayout layout = new SpringLayout();
JLabel label = new JLabel("Phone Number: ");
panel.setLayout(layout);
panel.add(label);
panel.add(txtPhoneNumber);
layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.WEST, panel);
layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.WEST, txtPhoneNumber, 5, SpringLayout.EAST, label);
layout.putConstraint(SpringLayout.NORTH, txtPhoneNumber, 5, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.EAST, panel, 5, SpringLayout.EAST, txtPhoneNumber);
}
示例8: AddFrame
import javax.swing.SpringLayout; //導入方法依賴的package包/類
/**
*
* @param title
* The title of the frame.
*/
public AddFrame(final String title) {
super(title);
contentPanel.setLayout(new GridLayout(0, 1, 0, 0));
// JPanel panel = new JPanel();
// contentPanel.add(panel);
JPanel pan = new JPanel();
contentPanel.add(pan);
SpringLayout slPanel = new SpringLayout();
pan.setLayout(slPanel);
Animal = new JButton("Animal");
slPanel.putConstraint(SpringLayout.NORTH, Animal, 0, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, Animal, 0, SpringLayout.WEST, pan);
pan.add(Animal);
Employee = new JButton("Employee");
slPanel.putConstraint(SpringLayout.NORTH, Employee, 0, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, Employee, 78, SpringLayout.WEST, pan);
pan.add(Employee);
JPanel panel_2 = new JPanel();
contentPanel.add(panel_2);
setVisible(true);
}
示例9: setHolder
import javax.swing.SpringLayout; //導入方法依賴的package包/類
void setHolder(Component c) {
holder.removeAll();
SpringLayout l = (SpringLayout) holder.getLayout();
l.putConstraint(EAST, c, 0, EAST, holder);
l.putConstraint(WEST, c, 0, WEST, holder);
l.putConstraint(NORTH, c, 0, NORTH, holder);
l.putConstraint(SOUTH, c, 0, SOUTH, holder);
holder.add(c);
revalidate();
}
示例10: initialize
import javax.swing.SpringLayout; //導入方法依賴的package包/類
private final void initialize() {
SpringLayout l = new SpringLayout();
this.setLayout(l);
this.setPreferredSize(D);
this.setMinimumSize(D);
Category[] v = Category.values();
AnimPanel[] catPanels = new AnimPanel[v.length];
for (int i = 0; i < v.length; i++) {
catPanels[i] = new AnimPanel(v[i], doThing);
}
PrettyBox<AnimPanel> catList = new PrettyBox<AnimPanel>(catPanels);
JPanel listWrap = new JPanel();
JScrollPane wrap = new JScrollPane(listWrap);
JPanel w = (JPanel) this.getContentPane();
l.putConstraint(NORTH, catList, 5, NORTH, w);
l.putConstraint(EAST, catList, -5, EAST, w);
l.putConstraint(WEST, catList, 5, WEST, w);
w.add(catList);
l.putConstraint(NORTH, wrap, 5, SOUTH, catList);
l.putConstraint(SOUTH, wrap, -5, SOUTH, w);
l.putConstraint(EAST, wrap, 0, EAST, catList);
l.putConstraint(WEST, wrap, 0, WEST, catList);
w.add(wrap);
catList.addItemListener(
arg0 -> {
listWrap.removeAll();
listWrap.add((AnimPanel) catList.getSelectedItem());
this.revalidate();
this.repaint();
});
listWrap.add(catPanels[0]);
}
示例11: putConstraint
import javax.swing.SpringLayout; //導入方法依賴的package包/類
private void putConstraint(Component father, Component son,
int west, int north)
{
SpringLayout layout = (SpringLayout)getLayout();
layout.putConstraint(SpringLayout.WEST, son, west,
SpringLayout.WEST, father);
layout.putConstraint(SpringLayout.NORTH, son, north,
SpringLayout.NORTH, father);
}
示例12: makeUDPPanel
import javax.swing.SpringLayout; //導入方法依賴的package包/類
private void makeUDPPanel() {
// TODO Auto-generated method stub
SpringLayout us=new SpringLayout();
this.udpPanel = new JPanel(us);
JLabel udpHostLabel = new JLabel("Host:");
JLabel udpPortLabel = new JLabel("Port:");
udpHostField = new JTextField();
udpPortField = new JTextField();
udpPanel.add(udpHostLabel);
us.putConstraint(SpringLayout.WEST, udpHostLabel, 50, SpringLayout.WEST, udpPanel);
us.putConstraint(SpringLayout.NORTH, udpHostLabel, 50, SpringLayout.NORTH, udpPanel);
udpPanel.add(udpPortLabel);
us.putConstraint(SpringLayout.WEST, udpPortLabel, 50, SpringLayout.WEST, udpPanel);
us.putConstraint(SpringLayout.NORTH, udpPortLabel, 50, SpringLayout.SOUTH, udpHostLabel);
udpPanel.add(udpHostField);
us.putConstraint(SpringLayout.WEST, udpHostField, 140, SpringLayout.WEST, udpPanel);
us.putConstraint(SpringLayout.NORTH, udpHostField, 50, SpringLayout.NORTH, udpPanel);
us.putConstraint(SpringLayout.EAST, udpHostField, -50, SpringLayout.EAST, udpPanel);
udpPanel.add(udpPortField);
us.putConstraint(SpringLayout.WEST, udpPortField, 140, SpringLayout.WEST, udpPanel);
us.putConstraint(SpringLayout.NORTH, udpPortField, 50, SpringLayout.SOUTH, udpHostLabel);
us.putConstraint(SpringLayout.EAST, udpPortField, -50, SpringLayout.EAST, udpPanel);
}
示例13: makeTCPPanel
import javax.swing.SpringLayout; //導入方法依賴的package包/類
private void makeTCPPanel() {
// TODO Auto-generated method stub
this.tcpPanel = new JPanel();
SpringLayout tcpLayout = new SpringLayout();
tcpPanel.setLayout(tcpLayout);
this.hostAddressField = new JTextField();
hostAddressField.setPreferredSize(new Dimension(100,25));
this.listeningPortField= new JTextField();
listeningPortField.setPreferredSize(new Dimension(100,25));
JLabel hostAddressLabel = new JLabel("Host Address:");
JLabel listeningPortLabel = new JLabel("Listening Port:");
tcpPanel.add(listeningPortLabel);
tcpPanel.add(hostAddressLabel);
tcpPanel.add(hostAddressField);
tcpPanel.add(listeningPortField);
tcpLayout.putConstraint(SpringLayout.WEST, hostAddressLabel, 50, SpringLayout.WEST, tcpPanel);
tcpLayout.putConstraint(SpringLayout.NORTH, hostAddressLabel, 50, SpringLayout.NORTH, tcpPanel);
tcpLayout.putConstraint(SpringLayout.WEST, listeningPortLabel, 50, SpringLayout.WEST, tcpPanel);
tcpLayout.putConstraint(SpringLayout.NORTH, listeningPortLabel, 50, SpringLayout.SOUTH, hostAddressLabel);
tcpLayout.putConstraint(SpringLayout.WEST, hostAddressField, 200, SpringLayout.WEST, tcpPanel);
tcpLayout.putConstraint(SpringLayout.NORTH, hostAddressField, 50, SpringLayout.NORTH, tcpPanel);
tcpLayout.putConstraint(SpringLayout.EAST, hostAddressField, -50, SpringLayout.EAST, tcpPanel);
tcpLayout.putConstraint(SpringLayout.WEST, listeningPortField, 200, SpringLayout.WEST, tcpPanel);
tcpLayout.putConstraint(SpringLayout.NORTH, listeningPortField, 60, SpringLayout.NORTH, hostAddressLabel);
tcpLayout.putConstraint(SpringLayout.EAST, listeningPortField, -50, SpringLayout.EAST, tcpPanel);
}
示例14: UploadFirmware
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public UploadFirmware()
{
super("Upload Firmware");
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setPreferredSize(new Dimension(600,600));
contentLayout = new SpringLayout();
contentPanel = new JPanel(contentLayout);
JLabel firmwareLabel= new JLabel("Select Firmware Type:");
contentPanel.add(firmwareLabel);
contentLayout.putConstraint(SpringLayout.WEST, firmwareLabel, 50, SpringLayout.WEST, contentPanel);
contentLayout.putConstraint(SpringLayout.NORTH, firmwareLabel, 50, SpringLayout.NORTH, contentPanel);
firmwarePanel = new JPanel();
firmwarePanel.setPreferredSize(new Dimension(300,300));
firmwarePanel.setBorder(BorderFactory.createLineBorder(Color.black));
contentPanel.add(firmwarePanel);
contentLayout.putConstraint(SpringLayout.WEST, firmwarePanel, 50, SpringLayout.WEST, contentPanel);
contentLayout.putConstraint(SpringLayout.NORTH, firmwarePanel, 50, SpringLayout.SOUTH, firmwareLabel);
contentLayout.putConstraint(SpringLayout.EAST, firmwarePanel, -50, SpringLayout.EAST, contentPanel);
this.add(contentPanel);
this.pack();
}
示例15: BirdFrame
import javax.swing.SpringLayout; //導入方法依賴的package包/類
public BirdFrame(String title) {
super(title);
contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
JPanel panel = new JPanel();
contentPanel.add(panel);
JPanel pan = new JPanel();
contentPanel.add(pan);
SpringLayout slPanel = new SpringLayout();
pan.setLayout(slPanel);
flamingoButton = new JButton("Flamingo");
slPanel.putConstraint(SpringLayout.NORTH, flamingoButton, 65, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, flamingoButton, 93, SpringLayout.WEST, pan);
pan.add(flamingoButton);
hummingbirdButton = new JButton("Hummingbird");
slPanel.putConstraint(SpringLayout.NORTH, hummingbirdButton, 100, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, hummingbirdButton, 93, SpringLayout.WEST, pan);
pan.add(hummingbirdButton);
owlButton = new JButton("Owl");
slPanel.putConstraint(SpringLayout.NORTH, owlButton, 135, SpringLayout.NORTH, pan);
slPanel.putConstraint(SpringLayout.WEST, owlButton, 93, SpringLayout.WEST, pan);
pan.add(owlButton);
JPanel rightPanel = new JPanel();
contentPanel.add(rightPanel);
setVisible(true);
}