本文整理汇总了Java中javax.swing.JPanel.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.setLayout方法的具体用法?Java JPanel.setLayout怎么用?Java JPanel.setLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.setLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TypeWizard
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Create the frame.
*/
public TypeWizard(final Graph graph, final Object onWhat, final List<Object> list) {
this.graph = graph;
this.onWhat = onWhat;
this.setTitle("Change Atom Type Wizard");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setBounds(100, 100, 450, 300);
this.getContentPane().setLayout(new BorderLayout(0, 0));
final JScrollPane scrollPane = new JScrollPane();
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
this.list = new JList<Object>();
this.list.setFont(new Font("Times New Roman", Font.PLAIN, 12));
this.list.setBorder(new LineBorder(new Color(0, 0, 0)));
this.list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.list.setModel(new TypeListModel(list));
scrollPane.setViewportView(this.list);
final JPanel buttonPanel = new JPanel();
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
buttonPanel.setLayout(new BorderLayout(0, 0));
this.finishButton = new JButton("Finish");
this.finishButton.setFont(new Font("Times New Roman", Font.PLAIN, 12));
this.finishButton.setMnemonic('F');
buttonPanel.add(this.finishButton, BorderLayout.EAST);
this.finishButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg) {
TypeWizard.this.performFinish();
GraphUtil.getInstance().layout();
TypeWizard.this.dispose();
}
});
}
示例2: Ed
import javax.swing.JPanel; //导入方法依赖的package包/类
public Ed(RestrictCommands piece) {
box = new JPanel();
box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
name = new StringConfigurer(null, "Description: ", piece.name);
box.add(name.getControls());
actionOption = new JComboBox();
actionOption.addItem(HIDE);
actionOption.addItem(DISABLE);
actionOption.setSelectedIndex((piece.action.equals(HIDE)) ? 0 : 1);
Box b = Box.createHorizontalBox();
b.add(new JLabel("Restriction: "));
b.add(actionOption);
box.add(b);
propertyMatch = new PropertyExpressionConfigurer(null, "Restrict when properties match: ", piece.propertyMatch, Decorator.getOutermost(piece));
box.add(propertyMatch.getControls());
watchKeys = new NamedKeyStrokeArrayConfigurer(null, "Restrict these Key Commands ", piece.watchKeys);
box.add(watchKeys.getControls());
}
示例3: paintEncrypt
import javax.swing.JPanel; //导入方法依赖的package包/类
public void paintEncrypt(JPanel _panel){
JButton en = new JButton("Encrypt");
JButton de = new JButton("Decrypt");
JPanel panel = new JPanel();
JPanel panel2 = new JPanel();
JTextField input = new JTextField(20);
JTextField output = new JTextField(20);
JTextField code = new JTextField(20);
_panel.add(panel, BorderLayout.CENTER);
_panel.add(panel2, BorderLayout.SOUTH);
panel.setLayout(new GridLayout(4,2));
panel.add(new JLabel("Input File Location :"));
panel.add(input);
panel.add(new JLabel("Output File Location :"));
panel.add(output);
panel.add(new JLabel("Encryptiong Code :"));
panel.add(code);
panel2.add(en);
panel2.add(de);
en.addActionListener(event -> encrypt(input.getText(),output.getText(),stringToCode(code.getText())));
de.addActionListener(event -> decrypt(input.getText(),output.getText(),stringToCode(code.getText())));
}
示例4: createProcParasPane
import javax.swing.JPanel; //导入方法依赖的package包/类
private JPanel createProcParasPane(JPanel parent)
{
JPanel paneProcParas = new JPanel();
paneProcParas.setLayout(null);
paneProcParas.setBorder(BorderFactory.createEtchedBorder());
int nYStartPaneProcParas = m_paneProbability.getHeight() + GuiConstants.GAP_COMPONENT;
paneProcParas.setBounds(0, nYStartPaneProcParas, parent.getWidth(), parent.getHeight() - nYStartPaneProcParas);
LHSListPane scrollParaNames = new LHSListPane(paneProcParas, m_lstProcParaNames);
paneProcParas.add(scrollParaNames);
paneProcParas.add(m_paneParaDistribution);
int nXStartParaDistribution = scrollParaNames.getWidth() + GuiConstants.GAP_COMPONENT;
int nWidthParaDistribution = paneProcParas.getWidth() - nXStartParaDistribution - GuiConstants.GAP_COMPONENT;
int nHeightParaDistribution = scrollParaNames.getHeight() - 2 * GuiConstants.GAP_COMPONENT;
m_paneParaDistribution.setBounds(nXStartParaDistribution, GuiConstants.GAP_COMPONENT, nWidthParaDistribution,
nHeightParaDistribution);
m_paneParaDistribution.add(s_paneDummy);
return paneProcParas;
}
示例5: initComponents
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
innerPanel = new JPanel();
innerPanel.setLayout(new BorderLayout());
GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(innerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(innerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
}
示例6: setUpControls
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
*
*/
private JPanel setUpControls() {
JPanel jp = new JPanel();
jp.setBackground(Color.WHITE);
jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
jp.setBorder(BorderFactory.createLineBorder(Color.black, 3));
jp.add(
new JLabel("Select a pair of vertices for which a shortest path will be displayed"));
JPanel jp2 = new JPanel();
jp2.add(new JLabel("vertex from", SwingConstants.LEFT));
jp2.add(getSelectionBox(true));
jp2.setBackground(Color.white);
JPanel jp3 = new JPanel();
jp3.add(new JLabel("vertex to", SwingConstants.LEFT));
jp3.add(getSelectionBox(false));
jp3.setBackground(Color.white);
jp.add( jp2 );
jp.add( jp3 );
return jp;
}
示例7: onStartOpenJar
import javax.swing.JPanel; //导入方法依赖的package包/类
public void onStartOpenJar() {
m_classesPanel.removeAll();
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(new JLabel("Loading..."));
m_classesPanel.add(panel);
redraw();
}
示例8: constructPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
private void constructPanel(String[] values) {
// constructing editors
editors = new PropertyValueCellEditor[types.length];
for (int i = 0; i < types.length; i++) {
editors[i] = PropertyPanel.instantiateValueCellEditor(types[i], operator);
}
// building panel
panel = new JPanel();
panel.setFocusable(true);
panel.setLayout(new GridLayout(1, editors.length));
for (int i = 0; i < types.length; i++) {
Component editorComponent = editors[i].getTableCellEditorComponent(null, values[i], false, 0, 0);
if (editorComponent instanceof JComboBox && ((JComboBox) editorComponent).isEditable()) {
if (((JComboBox) editorComponent).isEditable()) {
ComboBoxEditor editor = ((JComboBox) editorComponent).getEditor();
if (editor instanceof BasicComboBoxEditor) {
editor.getEditorComponent().addFocusListener(focusListener);
}
} else {
editorComponent.addFocusListener(focusListener);
}
} else if (editorComponent instanceof JPanel) {
JPanel editorPanel = (JPanel) editorComponent;
Component[] components = editorPanel.getComponents();
for (Component comp : components) {
comp.addFocusListener(focusListener);
}
} else {
editorComponent.addFocusListener(focusListener);
}
panel.add(editorComponent);
panel.addFocusListener(focusListener);
}
}
示例9: makeButtons
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* @return the button panel
*/
@Override
protected JComponent makeButtons() {
help = new HoverHelp();
helpLabel = help.getHelpLabel();
helpLabel.setBorder(BorderFactory.createEtchedBorder());
//helpLabel.setHorizontalAlignment(SwingConstants.CENTER);
ACTION_FINISH.putValue(Action.NAME, "Solve");
ACTION_CANCEL.putValue(Action.NAME, "Exit");
JPanel buttons = new JPanel();
JButton button_finish = new JButton(ACTION_FINISH);
help.addHelp(button_finish, "Validates the system and starts the solver");
JButton button_cancel = new JButton(ACTION_CANCEL);
help.addHelp(button_cancel, "Exits the wizard discarding all changes");
JButton button_next = new JButton(ACTION_NEXT);
help.addHelp(button_next, "Moves on to the next step");
JButton button_previous = new JButton(ACTION_PREV);
help.addHelp(button_previous, "Goes back to the previous step");
JButton button_help = new JButton(ACTION_HELP);
help.addHelp(button_help, "Displays help for the current panel");
buttons.add(button_previous);
buttons.add(button_next);
buttons.add(button_finish);
buttons.add(button_cancel);
buttons.add(button_help);
JPanel labelbox = new JPanel();
labelbox.setLayout(new BorderLayout());
labelbox.add(Box.createVerticalStrut(20), BorderLayout.WEST);
labelbox.add(helpLabel, BorderLayout.CENTER);
Box buttonBox = Box.createVerticalBox();
buttonBox.add(buttons);
buttonBox.add(labelbox);
return buttonBox;
}
示例10: getSingleInfoPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Lazily creates and returns a monolithic panel used as info panel in case there is
* only an upper panel.
*/
private JPanel getSingleInfoPanel() {
JPanel result = this.singleInfoPanel;
if (result == null) {
this.singleInfoPanel = result = new JPanel();
result.setLayout(new BorderLayout());
result.setBorder(null);
}
return result;
}
示例11: createControllerPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
private JPanel createControllerPanel() {
JPanel controllerPanel = new JPanel();
JLabel pane = new JLabel();
pane.setText(NbBundle.getMessage(FakeJiraConnector.class, "MSG_NOT_YET_INSTALLED")); // NOI18N
JButton downloadButton = new JButton();
downloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JiraUpdater.getInstance().downloadAndInstall(null);
}
});
org.openide.awt.Mnemonics.setLocalizedText(downloadButton, org.openide.util.NbBundle.getMessage(FakeJiraConnector.class, "MissingJiraSupportPanel.downloadButton.text")); // NOI18N
GroupLayout layout = new GroupLayout(controllerPanel);
controllerPanel.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(pane, GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(downloadButton))
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(pane)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(downloadButton))
.addContainerGap())
);
return controllerPanel;
}
示例12: DefinitionBox
import javax.swing.JPanel; //导入方法依赖的package包/类
public DefinitionBox(MethodNode mn, JList<?> list) {
super("Definition: " + mn.name);
setMaximumSize(new Dimension(700, 700));
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1.0;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
add(c, new JLabel("Name:"), new ActionTextField(mn.name, n -> {
mn.name = n;
list.repaint();
}));
add(c, new JLabel("Descriptor:"), new ActionTextField(mn.desc, d -> {
mn.desc = d;
list.repaint();
}));
add(c, new JLabel("Signature:"), new ActionTextField(mn.signature == null ? "" : mn.signature, s -> {
if (s.isEmpty()) {
mn.signature = null;
} else {
mn.signature = s;
}
}));
add(c, new AccessPanel(mn, null));
// Exceptions
JPanel exceptions = new JPanel();
exceptions.setBorder(BorderFactory.createTitledBorder("Exceptions"));
exceptions.setLayout(new BoxLayout(exceptions, BoxLayout.Y_AXIS));
update(exceptions, mn);
add(c, exceptions);
setVisible(true);
}
示例13: buildDetail
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void buildDetail(String id, JPanel panel) {
if (getId().equals(id)) return;
final Specification spec = getSpecification();
ResourceType type = spec.getResourceType(id);
panel.setLayout(new MigLayout("wrap 2", "[]20[]"));
JLabel name = Utility.localizedHeaderLabel(type, FontLibrary.FontSize.SMALL);
panel.add(name, "span, align center, wrap 40");
panel.add(Utility.localizedLabel("colopedia.resource.bonusProduction"));
JPanel goodsPanel = new JPanel();
goodsPanel.setOpaque(false);
List<Modifier> mods = sort(type.getModifiers(),
Modifier.ascendingModifierIndexComparator);
for (Modifier modifier : mods) {
String text = ModifierFormat.getModifierAsString(modifier);
if (modifier.hasScope()) {
String scopes = transform(modifier.getScopes(),
isNotNull(Scope::getType),
s -> Messages.getName(spec.findType(s.getType())),
Collectors.joining(", "));
if (!scopes.isEmpty()) text += " (" + scopes + ")";
}
GoodsType goodsType = spec.getGoodsType(modifier.getId());
JButton goodsButton = getGoodsButton(goodsType, text);
goodsPanel.add(goodsButton);
}
panel.add(goodsPanel);
panel.add(Utility.localizedLabel("colopedia.resource.description"),
"newline 20");
panel.add(Utility.localizedTextArea(Messages.descriptionKey(type), 30),
"growx");
}
示例14: createHorizontalPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
public JPanel createHorizontalPanel(boolean threeD)
{
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
p.setAlignmentY(TOP_ALIGNMENT);
p.setAlignmentX(LEFT_ALIGNMENT);
if(threeD)
{
p.setBorder(loweredBorder);
}
return p;
}
示例15: SpecialGraphWindow
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Creates an instance of this class.
*/
public SpecialGraphWindow () {
setTitle("Create special graph");
setBounds(50,50,700,500);
wkPreview = new GraphWorkspace(new GTCGraph(),false);
typeOptions = PluginController.getInstance().getFactories();
layoutOptions = PluginController.getInstance().getLayouts(null,wkPreview);
// Create Center, South, and West and South
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel,BoxLayout.X_AXIS));
JPanel southPanel = new JPanel(new BorderLayout());
JPanel westPanel = new JPanel(new BorderLayout());
// Create and set properties panel
propertiesPanel = new JPanel();
propertiesPanel.setLayout(new BoxLayout(propertiesPanel,BoxLayout.Y_AXIS));
propertiesPanel.setBorder(BorderFactory.createTitledBorder("Properties"));
// Create ComboBox wirh Graph Factory options
bType = new JComboBox(typeOptions);
bType.setAction(COMBO_GRAPH_TYPE_ACTION);
buildPropertiesMembersInterface(bType);
// Create and set a Graph Type panel and add a ComboBox type
JPanel graphTypePanel = new JPanel();
graphTypePanel.setLayout(new BoxLayout(graphTypePanel,BoxLayout.Y_AXIS));
graphTypePanel.setBorder(BorderFactory.createTitledBorder("Graph Type"));
graphTypePanel.add(bType);
// Create ComboBox wirh Graph Factory options
bLayout = new JComboBox(layoutOptions);
bLayout.setAction(COMBO_GRAPH_LAYOUT_ACTION);
// Create and set a Graph Layout panel and add a ComboBox layout
JPanel graphLayoutPanel = new JPanel();
graphLayoutPanel.setLayout(new BoxLayout(graphLayoutPanel,BoxLayout.Y_AXIS));
graphLayoutPanel.setBorder(BorderFactory.createTitledBorder("Graph Layout"));
graphLayoutPanel.add(bLayout);
// Create a combos` panel
JPanel comboPanel = new JPanel(new BorderLayout());
comboPanel.add(graphTypePanel,"North");
comboPanel.add(graphLayoutPanel,"South");
// Add graph type panel and properties panel in West Panel
westPanel.add(comboPanel,"North");
westPanel.add(propertiesPanel,"Center");
// Add preview workspace in Center Panel
centerPanel.add(wkPreview);
centerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
// Create buttons and buttons panel
JPanel buttonsPanel = new JPanel(new FlowLayout());
buttonsPanel.add(new JButton(PREVIEW_ACTION));
buttonsPanel.add(new JButton(RESTORE_DEFAULT_ACTION));
buttonsPanel.add(new JButton(OK_ACTION));
buttonsPanel.add(new JButton(CANCEL_ACTION));
// Add buttons panel in South Panel
southPanel.add(buttonsPanel,BorderLayout.EAST);
// Add panels in Main Panel (SpecialGraphWindow Content Panel)
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(southPanel,BorderLayout.SOUTH);
this.getContentPane().add(westPanel,BorderLayout.WEST);
this.getContentPane().add(centerPanel,BorderLayout.CENTER);
}