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

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

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

JPanel.<init>介绍

暂无

代码示例

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

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

代码示例来源: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: stanfordnlp/CoreNLP

private void buildExtractButton() {
 if (extractButton == null) {
  JPanel buttonPanel = new JPanel();
  extractButton = new JButton("Run NER");
  buttonPanel.add(extractButton);
  frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
  extractButton.addActionListener(actor);
 }
}

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

private JFrame frame = new JFrame("Test");
private JPanel panel = new JPanel();
private JLabel label = new JLabel("CenteredJLabel");
  panel.add(label);
  panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setSize(400, 300);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);

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

private void buildExtractButton() {
 if (extractButton == null) {
  JPanel buttonPanel = new JPanel();
  extractButton = new JButton("Extract");
  buttonPanel.add(extractButton);
  frame.add(buttonPanel, BorderLayout.SOUTH);
  extractButton.addActionListener(actor);
 }
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

@Nullable
@Override
protected JComponent createCenterPanel() {
 JPanel panel = new JPanel(new BorderLayout());
 panel.add(myCommandTextField, BorderLayout.NORTH);
 return panel;
}

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

JFrame frame = new JFrame(){{
    add( new JPanel(){{
       add( new JLabel("Hey there"){{ 
         setBackground(Color.black);
         setForeground( Color.white);
       }});
       add( new JButton("Ok"){{
         addActionListener( new ActionListener(){
           public void actionPerformed( ActionEvent ae ){
             System.out.println("Button pushed");
           }
          });
        }});
   }});
 }};

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

private JButton    m_multiplyBtn = new JButton("Multiply");
private JButton    m_clearBtn    = new JButton("Clear");
  JPanel content = new JPanel();
  content.setLayout(new FlowLayout());
  content.add(new JLabel("Input"));
  content.add(m_userInputTf);
  content.add(m_multiplyBtn);
  content.add(new JLabel("Total"));
  content.add(m_totalTf);
  content.add(m_clearBtn);
  this.pack();
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

代码示例来源: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);
}

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

import javax.swing.*;

public class JOptionPaneMultiInput {
  public static void main(String[] args) {
   JTextField xField = new JTextField(5);
   JTextField yField = new JTextField(5);

   JPanel myPanel = new JPanel();
   myPanel.add(new JLabel("x:"));
   myPanel.add(xField);
   myPanel.add(Box.createHorizontalStrut(15)); // a spacer
   myPanel.add(new JLabel("y:"));
   myPanel.add(yField);

   int result = JOptionPane.showConfirmDialog(null, myPanel, 
        "Please Enter X and Y Values", JOptionPane.OK_CANCEL_OPTION);
   if (result == JOptionPane.OK_OPTION) {
     System.out.println("x value: " + xField.getText());
     System.out.println("y value: " + yField.getText());
   }
  }
}

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

JButton backwardButton, forwardButton;
add(backwardButton = new JButton("<"), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
  new Insets(0, 0, 0, 0), 0, 0));
add(regionsPanel = new JPanel(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
  new Insets(0, 0, 0, 0), 0, 0));
add(forwardButton = new JButton(">"), new GridBagConstraints(2, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
  new Insets(0, 0, 0, 0), 0, 0));

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

public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setBounds(0, 0, 300, 400);
  frame.setLayout(null);
  final JTabbedPane tabbedPane = new JTabbedPane();
  tabbedPane.addTab("One", new JPanel());
  tabbedPane.addTab("Two", new JPanel());
  tabbedPane.addTab("Three", new JPanel());
  tabbedPane.addChangeListener(new ChangeListener() {
    public void stateChanged(ChangeEvent e) {
      System.out.println("Tab: " + tabbedPane.getSelectedIndex());
    }
  });
  tabbedPane.setBounds(0, 0, 300, 400);
  frame.add(tabbedPane);
  frame.setVisible(true);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private static void createTabs(){
  tabbedPane = new JTabbedPane();
  canvasPanel1 = new JPanel();
  canvasPanel1.setLayout(new BorderLayout());
  tabbedPane.addTab("jME3 Canvas 1", canvasPanel1);
  canvasPanel2 = new JPanel();
  canvasPanel2.setLayout(new BorderLayout());
  tabbedPane.addTab("jME3 Canvas 2", canvasPanel2);
  frame.getContentPane().add(tabbedPane);
  currentPanel = canvasPanel1;
}

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

final JPanel gui = new JPanel(new BorderLayout(5,5));
gui.setBorder( new TitledBorder("BorderLayout(5,5)") );
JPanel plafComponents = new JPanel(
  new FlowLayout(FlowLayout.RIGHT, 3,3));
plafComponents.setBorder(
plafComponents.add(plafChooser);
plafComponents.add(pack);
gui.add(plafComponents, BorderLayout.NORTH);
JPanel dynamicLabels = new JPanel(new BorderLayout(4,4));
dynamicLabels.setBorder(
final JPanel labels = new JPanel(new GridLayout(0,2,3,3));
labels.setBorder(
  new TitledBorder("GridLayout(0,2,3,3)") );
JButton addNew = new JButton("Add Another Label");
  new Dimension(tablePreferred.width, tablePreferred.height/3) );
JPanel imagePanel = new JPanel(new GridBagLayout());
imagePanel.setBorder(
  new TitledBorder("GridBagLayout()") );

代码示例来源: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: libgdx/libgdx

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

代码示例来源:origin: pedrovgs/AndroidWiFiADB

private void createNoDevicesPanel() {
 panelNoDevices = new JPanel(new BorderLayout());
 JLabel labelNoDevices = new JLabel(NO_DEVICE_CONNECTED);
 labelNoDevices.setHorizontalAlignment(SwingConstants.CENTER);
 panelNoDevices.add(labelNoDevices);
}

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

private JComponent getSouthLabel() {
  final JPanel result = new JPanel();
  final JButton ok = new JButton("OK");
  ok.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
      dispose();
    }
  });
  result.add(ok);
  return result;
}

代码示例来源: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: pedrovgs/AndroidWiFiADB

public void createAndShowGUI() {
 cards = new JPanel(new CardLayout());
 createNoDevicesPanel();
 createTableDevices();
 cards.add(panelDevices, CARD_DEVICES);
 cards.add(panelNoDevices, CARD_NO_DEVICES);
 parentContainer.add(cards, BorderLayout.PAGE_START);
 setupUi();
}

相关文章

JPanel类方法