javax.swing.JPanel.setLayout()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中javax.swing.JPanel.setLayout()方法的一些代码示例,展示了JPanel.setLayout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPanel.setLayout()方法的具体详情如下:
包路径:javax.swing.JPanel
类名称:JPanel
方法名:setLayout

JPanel.setLayout介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

protected JPanel createStatusArea() {
 JPanel statusArea = new JPanel();
 JLabel status =
   new JLabel("No log records to display.");
 _statusLabel = status;
 status.setHorizontalAlignment(JLabel.LEFT);
 statusArea.setBorder(BorderFactory.createEtchedBorder());
 statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 statusArea.add(status);
 return (statusArea);
}

代码示例来源:origin: apache/ignite

/**
 * @param components Components.
 * @return Panel.
 */
private JPanel createPanel(JComponent... components) {
  JPanel panel = new JPanel();
  panel.setLayout(new FlowLayout());
  for (JComponent component : components)
    panel.add(component);
  return panel;
}

代码示例来源:origin: stackoverflow.com

JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

代码示例来源:origin: stackoverflow.com

JPanel jPanel1 = new JPanel();
jPanel1.setLayout(new java.awt.BorderLayout());
 ..
ChartPanel CP = new ChartPanel(chart);
.. 
jPanel1.add(CP,BorderLayout.CENTER);
jPanel1.validate();

代码示例来源:origin: MovingBlocks/Terasology

MyRenderer() {
  setBackground(BACKGROUND);
  setLayout(new BorderLayout());
  pHead.setLayout(new BorderLayout());
  pHead.setBackground(BACKGROUND);
  pHead.add(pList, BorderLayout.LINE_START);
  pHead.add(lActive, BorderLayout.LINE_END);
  pHead.add(pError, BorderLayout.PAGE_END);
  lId.setHorizontalAlignment(SwingConstants.RIGHT);
  lName.setForeground(Color.BLUE);
  lCounters.setForeground(Color.GRAY);
  pList.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 2));
  pList.setBackground(BACKGROUND);
  pList.add(lId);
  pList.add(lName);
  pList.add(lCounters);
  pError.setVisible(false);
  pError.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 2));
  pError.setBackground(BACKGROUND);
  pError.add(lErrorSpacer);
  pError.add(lError);
  lError.setForeground(Color.RED);
  add(pHead, BorderLayout.PAGE_START);
}

代码示例来源:origin: libgdx/libgdx

private void uiLayout () {
  title.setLayout(new GridLayout(1, 2));
  
  minimize.setPreferredSize(new Dimension(50, 26));
  exit.setPreferredSize(new Dimension(50, 26));
  title.add(minimize);
  title.add(exit);
  topBar.setLayout(new GridLayout(1, 1));
  topBar.add(windowLabel, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTHWEST, VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
  setLayout(new GridBagLayout());
  add(topBar, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 100), 0, 10));
  add(title, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTHEAST, NONE, new Insets(0, 0, 0, 0), 0, 0));
  add(logo, new GridBagConstraints(0, 0, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(40, 6, 6, 6), 0, 0));
  add(form, new GridBagConstraints(0, 1, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(6, 6, 0, 6), 0, 0));
  add(buttonPanel, new GridBagConstraints(0, 2, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 0, 0, 0), 0, 0));
  add(scrollPane, new GridBagConstraints(0, 3, 1, 1, 1, 1, CENTER, BOTH, new Insets(6, 6, 6, 6), 0, 0));
}

代码示例来源:origin: iluwatar/java-design-patterns

private void setup() {
 setLayout(new BorderLayout());
 JPanel bot = new JPanel();
 add(jt.getTableHeader(), BorderLayout.NORTH);
 bot.setLayout(new BorderLayout());
 bot.add(del, BorderLayout.EAST);
 add(bot, BorderLayout.SOUTH);
 JScrollPane jsp = new JScrollPane(jt);
 jsp.setPreferredSize(new Dimension(500, 250));
 add(jsp, BorderLayout.CENTER);
 del.addActionListener(new DListener());
 JRootPane rootPane = SwingUtilities.getRootPane(del);
 rootPane.setDefaultButton(del);
 setVisible(true);
}

代码示例来源:origin: wiztools/rest-client

public static JPanel getFlowLayoutLeftAlignedMulti(Component ... components) {
  JPanel jp = new JPanel();
  jp.setLayout(new FlowLayout(FlowLayout.LEFT));
  
  for(Component c: components) {
    jp.add(c);
  }
  
  return jp;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

private Container makeMainTab() {
  Container pane = new JPanel();
  pane.setLayout(new BorderLayout());
  
  // init center graphical panel
  showGraph = new ShowGraph(this, getGraph());
  pane.add(showGraph, BorderLayout.CENTER);
  traverseVisitor = new VisualTraverseVisitor(showGraph);
  // init left panel
  leftPanel = new JPanel();
  leftPanel.setLayout(new BorderLayout());
  pane.add(leftPanel, BorderLayout.LINE_START);
  initRoutingSubpanel();
  initVertexInfoSubpanel();
  initControlButtons();
  // init right panel
  initRightPanel(pane);
  return pane;
}

代码示例来源:origin: zzz40500/GsonFormat

rendererComponent.setLayout(new BorderLayout());
rendererComponent.add(_checkBox);
rendererComponent.add(_label, BorderLayout.LINE_END);

代码示例来源:origin: log4j/log4j

public LogFactor5LoadingDialog(JFrame jframe, String message) {
 super(jframe, "LogFactor5", false);
 JPanel bottom = new JPanel();
 bottom.setLayout(new FlowLayout());
 JPanel main = new JPanel();
 main.setLayout(new GridBagLayout());
 wrapStringOnPanel(message, main);
 getContentPane().add(main, BorderLayout.CENTER);
 getContentPane().add(bottom, BorderLayout.SOUTH);
 show();
}
//--------------------------------------------------------------------------

代码示例来源:origin: log4j/log4j

public CategoryNodeRenderer() {
 _panel.setBackground(UIManager.getColor("Tree.textBackground"));
 if (_sat == null) {
  // Load the satellite image.
  String resource =
    "/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif";
  URL satURL = getClass().getResource(resource);
  _sat = new ImageIcon(satURL);
 }
 setOpaque(false);
 _checkBox.setOpaque(false);
 _panel.setOpaque(false);
 // The flowlayout set to LEFT is very important so that the editor
 // doesn't jump around.
 _panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 _panel.add(_checkBox);
 _panel.add(this);
 setOpenIcon(_sat);
 setClosedIcon(_sat);
 setLeafIcon(_sat);
}

代码示例来源:origin: iluwatar/java-design-patterns

private void setup() {
 setLayout(new BorderLayout());
 JPanel panel = new JPanel();
 add(jl, BorderLayout.SOUTH);
 add(panel, BorderLayout.CENTER);
 panel.setLayout(new GridLayout(6, 2));
 panel.add(new JLabel("Name"));
 panel.add(jtFields[0]);
 panel.add(new JLabel("Contact Number"));
 panel.add(jtFields[1]);
 panel.add(new JLabel("Address"));
 panel.add(jtAreas[0]);
 panel.add(new JLabel("Deposit Number"));
 panel.add(processButton);
 clearButton.addActionListener(e -> {
  for (JTextArea i : jtAreas) {
   i.setText("");
 processButton.addActionListener(e -> {
  Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(),
    jtAreas[1].getText());

代码示例来源:origin: wiztools/rest-client

public static JPanel getFlowLayoutPanelLeftAligned(String title, Component component){
  JPanel jp = new JPanel();
  jp.setLayout(new FlowLayout(FlowLayout.LEFT));
  if(title != null){
    if(component instanceof JPanel){
      JPanel p = (JPanel)component;
      p.setBorder(BorderFactory.createTitledBorder(title));
    }
  }
  jp.add(component);
  return jp;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

protected JComponent makeTextPanel(String text) {
  JPanel panel = new JPanel(false);
  JLabel filler = new JLabel(text);
  filler.setHorizontalAlignment(JLabel.CENTER);
  panel.setLayout(new GridLayout(1, 1));
  panel.add(filler);
  return panel;
}

代码示例来源:origin: stackoverflow.com

JPanel container = new JPanel();
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));

JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();

//panel1.set[Preferred/Maximum/Minimum]Size()

container.add(panel1);
container.add(panel2);

代码示例来源:origin: stanfordnlp/CoreNLP

private JPanel makeFoundStatsBox() {
 JPanel foundStatsBox = new JPanel();
 foundStatsBox.setLayout(new GridBagLayout());
 Box labelBox = Box.createHorizontalBox();
 foundStats = new JLabel(" ");
 labelBox.add(foundStats);
 historyButton = new JButton("Statistics");
 historyButton.setEnabled(false);
 historyButton.addActionListener(this);
 GridBagConstraints c = new GridBagConstraints();
 c.fill = GridBagConstraints.BOTH;
 c.weightx = 1.7;
 foundStatsBox.add(labelBox,c);
 c.weightx = .3;
 c.gridwidth = 1;
 foundStatsBox.add(historyButton);
 return foundStatsBox;
}

代码示例来源:origin: ballerina-platform/ballerina-lang

public ServersGUI() {
  rootPanel = new JPanel();
  rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS));
  rootPanel.add(createArtifactRow("", "", "", ""));
}

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(200, 200);

// create the status bar panel and shove it down the bottom of the frame
JPanel statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.add(statusPanel, BorderLayout.SOUTH);
statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16));
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
JLabel statusLabel = new JLabel("status");
statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
statusPanel.add(statusLabel);

frame.setVisible(true);

代码示例来源:origin: alibaba/druid

/**
 * 将各个界面添加到JFrame中
 * 
 * @param pane JFrame内部的Container对象
 */
private void addComponentsToPane(Container pane) {
  JScrollPane scrollPane = new JScrollPane();
  JPanel contentPanel = new JPanel();
  contentPanel.setLayout(new GridLayout(0, 1));
  final JTextArea sqlField = new JTextArea(formatSql, 8, 20);
  final JScrollPane content1 = new JScrollPane(sqlField);
  content1.setBorder((TitledBorder) BorderFactory.createTitledBorder("SQL语句"));
  contentPanel.add(content1);
  addTable(contentPanel, "解析信息", parseData);
  addTable(contentPanel, "上次慢查询信息", lastSlowData);
  addTable(contentPanel, "上次错误查询信息", lastErrorData);
  addTable(contentPanel, "其他信息", otherData);
  scrollPane.setViewportView(contentPanel);
  pane.add(scrollPane, BorderLayout.CENTER);
}

相关文章

微信公众号

最新文章

更多

JPanel类方法