@Override public void initView() { initConfView(); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); javax.swing.GroupLayout.SequentialGroup hsg = layout.createSequentialGroup(); hsg.addComponent(tf_PropData, javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE); hsg.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); hsg.addComponent( pl_PropConf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, hsg)); javax.swing.GroupLayout.ParallelGroup vpg = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER); vpg.addComponent( pl_PropConf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); vpg.addComponent( tf_PropData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); layout.setVerticalGroup(vpg); }
final void makeLayout() { javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); GroupLayout.ParallelGroup g = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); for (JPanel p : panels) g.addComponent( p, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); g.addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jButton1)); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout.createSequentialGroup().addContainerGap().addGroup(g).addContainerGap())); GroupLayout.SequentialGroup g2 = layout.createSequentialGroup().addContainerGap(); for (JPanel p : panels) g2 = g2.addComponent( p, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); g2 = g2.addComponent(jButton1).addContainerGap(); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(g2)); pack(); }
private JPanel createBattlefieldSlidersPanel() { JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); GroupLayout.ParallelGroup left = layout.createParallelGroup(); left.addComponent(battlefieldSizeLabel); left.addComponent(battlefieldWidthSlider); leftToRight.addGroup(left); GroupLayout.ParallelGroup right = layout.createParallelGroup(); right.addComponent(battlefieldHeightSlider); leftToRight.addGroup(right); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup top = layout.createParallelGroup(); top.addComponent(battlefieldSizeLabel); top.addComponent(battlefieldHeightSlider); topToBottom.addGroup(top); GroupLayout.ParallelGroup bottom = layout.createParallelGroup(); bottom.addComponent(battlefieldWidthSlider); topToBottom.addGroup(bottom); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); return panel; }
public void initView() { ls_DataList = new javax.swing.JList(); bt_Cancel = new javax.swing.JButton(); bt_Update = new javax.swing.JButton(); ls_DataList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); javax.swing.JScrollPane sp_DataList = new javax.swing.JScrollPane(); sp_DataList.setViewportView(ls_DataList); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); javax.swing.GroupLayout.SequentialGroup hsg1 = layout.createSequentialGroup(); hsg1.addComponent(bt_Update); hsg1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); hsg1.addComponent(bt_Cancel); javax.swing.GroupLayout.ParallelGroup hpg = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING); hpg.addComponent( sp_DataList, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE); hpg.addGroup(hsg1); javax.swing.GroupLayout.SequentialGroup hsg = layout.createSequentialGroup(); hsg.addContainerGap(); hsg.addGroup(hpg); hsg.addContainerGap(); layout.setHorizontalGroup(hsg); javax.swing.GroupLayout.ParallelGroup vpg1 = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE); vpg1.addComponent(bt_Cancel); vpg1.addComponent(bt_Update); javax.swing.GroupLayout.SequentialGroup vsg = layout.createSequentialGroup(); vsg.addContainerGap(); vsg.addComponent(sp_DataList, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE); vsg.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); vsg.addGroup(vpg1); vsg.addContainerGap(); layout.setVerticalGroup(vsg); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setIconImage(Bean.getLogo(16)); }
private void init() { btnOpen = new JButton("Open"); btnOpen.setSize(100, 50); textArea = new JTextArea("sd"); textArea.setSize(200, 100); textArea.setDragEnabled(true); btnOpen.addActionListener(new OpenAction()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (InstantiationException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (IllegalAccessException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } Container container = getContentPane(); GroupLayout groupLayout = new GroupLayout(container); container.setLayout(groupLayout); groupLayout.setAutoCreateContainerGaps(true); groupLayout.setAutoCreateGaps(true); // 左对齐 GroupLayout.ParallelGroup p1 = groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING); p1.addComponent(btnOpen); p1.addComponent(textArea); // 水平 groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup().addGroup(p1)); GroupLayout.ParallelGroup v1 = groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING); v1.addComponent(btnOpen); GroupLayout.ParallelGroup v2 = groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING); v2.addComponent(textArea); GroupLayout.SequentialGroup vGroup = groupLayout.createSequentialGroup(); vGroup.addGroup(v1).addGroup(v2); // 垂直 groupLayout.setVerticalGroup(groupLayout.createSequentialGroup().addGroup(vGroup)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("通讯录"); setSize(300, 500); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((dimension.width - getSize().width) / 2, (dimension.height - getSize().height) / 3); // pack(); setVisible(true); }
private void initializeLayout() { GroupLayout layout = new GroupLayout(this); setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(false); GroupLayout.SequentialGroup hg = layout.createSequentialGroup(); hg.addComponent(backButton, 60, 60, 150); hg.addComponent(nextButton, 60, 60, 150); hg.addComponent(cancelButton, 60, 60, 150); layout.setHorizontalGroup(hg); GroupLayout.ParallelGroup vg = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); vg.addComponent(backButton); vg.addComponent(nextButton); vg.addComponent(cancelButton); layout.setVerticalGroup(vg); }
private void createFilterViolationPanelLayout() { GroupLayout filterViolationPanelLayout = new GroupLayout(filterViolationPanel); GroupLayout.SequentialGroup horizontalFilterViolationGroup = filterViolationPanelLayout.createSequentialGroup(); horizontalFilterViolationGroup.addComponent(ruletypePanel); horizontalFilterViolationGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); horizontalFilterViolationGroup.addComponent(violationtypePanel); filterViolationPanelLayout.setHorizontalGroup(horizontalFilterViolationGroup); GroupLayout.ParallelGroup verticalFilterViolationGroup = filterViolationPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); verticalFilterViolationGroup.addComponent(ruletypePanel); verticalFilterViolationGroup.addComponent(violationtypePanel); filterViolationPanelLayout.setVerticalGroup(verticalFilterViolationGroup); filterViolationPanel.setLayout(filterViolationPanelLayout); }
/** * Sets the inner middle panel layout with the orders. * * @param innerMiddlePanelLayout * @param orders */ private void setInnerMiddlePanelLayout( javax.swing.GroupLayout innerMiddlePanelLayout, ArrayList<javax.swing.JLabel> orders) { // Set horizontal axis javax.swing.GroupLayout.ParallelGroup tempHorizontalGroup = innerMiddlePanelLayout.createParallelGroup(); for (int i = 0; i < orders.size(); i++) { tempHorizontalGroup.addComponent( orders.get(i), javax.swing.GroupLayout.PREFERRED_SIZE, 773, javax.swing.GroupLayout.PREFERRED_SIZE); } innerMiddlePanelLayout.setHorizontalGroup( innerMiddlePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, innerMiddlePanelLayout .createSequentialGroup() .addContainerGap() .addGroup(tempHorizontalGroup) .addContainerGap())); // Set vertical axis javax.swing.GroupLayout.SequentialGroup tempVerticalGroup = innerMiddlePanelLayout.createSequentialGroup(); tempVerticalGroup.addContainerGap(); for (int i = 0; i < orders.size(); i++) { tempVerticalGroup.addComponent( orders.get(i), javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE); tempVerticalGroup.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); } tempVerticalGroup.addContainerGap(6, Short.MAX_VALUE); innerMiddlePanelLayout.setVerticalGroup( innerMiddlePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(tempVerticalGroup)); }
private void createPathFilterPanelLayout() { GroupLayout pathFilterPanelLayout = new GroupLayout(pathFilterPanel); GroupLayout.ParallelGroup horizontalButtonPathGroup = pathFilterPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false); horizontalButtonPathGroup.addComponent( removePath, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); horizontalButtonPathGroup.addComponent( addPath, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); GroupLayout.SequentialGroup horizontalPanePathGroup = pathFilterPanelLayout.createSequentialGroup(); horizontalPanePathGroup.addComponent(pathFilterScrollPane); horizontalPanePathGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED); horizontalPanePathGroup.addGroup(horizontalButtonPathGroup); horizontalPanePathGroup.addContainerGap(); pathFilterPanelLayout.setHorizontalGroup(horizontalPanePathGroup); GroupLayout.SequentialGroup verticalButtonPathGroup = pathFilterPanelLayout.createSequentialGroup(); verticalButtonPathGroup.addComponent(addPath); verticalButtonPathGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED); verticalButtonPathGroup.addComponent(removePath); verticalButtonPathGroup.addContainerGap(); GroupLayout.ParallelGroup verticalPanePathGroup = pathFilterPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); verticalPanePathGroup.addComponent(pathFilterScrollPane); verticalPanePathGroup.addGroup(verticalButtonPathGroup); pathFilterPanelLayout.setVerticalGroup(verticalPanePathGroup); pathFilterPanel.setLayout(pathFilterPanelLayout); }
/** * Universally creates layout for dialog. * * @param jcs */ protected final void createLayout(JComponent... jcs) { Container pane = getContentPane(); GroupLayout gl = new GroupLayout(pane); pane.setLayout(gl); gl.setAutoCreateContainerGaps(true); gl.setAutoCreateGaps(true); GroupLayout.ParallelGroup pg = gl.createParallelGroup(CENTER); for (JComponent jc : jcs) { pg.addComponent(jc).addGap(200); } gl.setHorizontalGroup(pg); GroupLayout.SequentialGroup sg = gl.createSequentialGroup(); for (JComponent jc : jcs) { sg.addGap(30).addComponent(jc).addGap(20); } gl.setVerticalGroup(sg); pack(); }
private void createBaseLayout() { GroupLayout layout = new GroupLayout(getContentPane()); GroupLayout.SequentialGroup horizontalButtonGroup = layout.createSequentialGroup(); horizontalButtonGroup.addComponent(hideFilteredValues); horizontalButtonGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED); horizontalButtonGroup.addComponent(showFilteredValues); horizontalButtonGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED); horizontalButtonGroup.addComponent(save); horizontalButtonGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED); horizontalButtonGroup.addComponent(cancel); horizontalButtonGroup.addContainerGap(); GroupLayout.ParallelGroup horizontalPaneGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); horizontalPaneGroup.addComponent(tabbedPane); horizontalPaneGroup.addGroup(horizontalButtonGroup); getContentPane().setLayout(layout); layout.setHorizontalGroup(horizontalPaneGroup); GroupLayout.ParallelGroup verticalRadioButtonGroup = layout.createParallelGroup(GroupLayout.Alignment.TRAILING); verticalRadioButtonGroup.addComponent(hideFilteredValues); verticalRadioButtonGroup.addComponent(showFilteredValues); GroupLayout.ParallelGroup verticalButtonGroup = layout.createParallelGroup(GroupLayout.Alignment.TRAILING); verticalButtonGroup.addComponent(save); verticalButtonGroup.addComponent(cancel); verticalButtonGroup.addGroup(verticalRadioButtonGroup); GroupLayout.SequentialGroup verticalPaneGroup = layout.createSequentialGroup(); verticalPaneGroup.addComponent(tabbedPane); verticalPaneGroup.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); verticalPaneGroup.addGroup(verticalButtonGroup); layout.setVerticalGroup(verticalPaneGroup); }
public GameLobby(JFrame f, GameControl gc) { super(f, "New Game", false); frame = f; GC = gc; setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); addWindowListener(this); JPanel main_panel = new JPanel(new BorderLayout()); // main_panel.setLayout(new BoxLayout(main_panel, BoxLayout.Y_AXIS)); JPanel map_panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // use flowLayout to right-align the row map_label = new JLabel( LOAD_MAP_MSG); // BOOKMARK! should check with GC to see if map_file is already choosen. map_panel.add(map_label); is_hosting = GC.players[GC.player_id].hosting; choose_map = new JButton("Select Map"); choose_map.addActionListener(this); choose_map.setEnabled(is_hosting); map_panel.add(choose_map); main_panel.add(map_panel, BorderLayout.NORTH); // Create and populate the panel. JPanel panel = new JPanel(); GroupLayout gl = new GroupLayout(panel); panel.setLayout(gl); gl.setAutoCreateGaps(true); gl.setAutoCreateContainerGaps(true); JLabel[] player_nums = new JLabel[GC.players.length]; player_names = new JLabel[GC.players.length]; color_samples = new JPanel[GC.players.length]; color_nums = new Integer[GC.players.length]; GroupLayout.ParallelGroup hgroup1 = gl.createParallelGroup(); GroupLayout.ParallelGroup hgroup2 = gl.createParallelGroup(); GroupLayout.ParallelGroup hgroup3 = gl.createParallelGroup(); GroupLayout.SequentialGroup vgroup = gl.createSequentialGroup(); // create the header JLabel num = new JLabel("#"); JLabel name = new JLabel("Name"); JLabel color = new JLabel("Color"); vgroup.addGroup( gl.createParallelGroup().addComponent(num).addComponent(name).addComponent(color)); hgroup1.addComponent(num); hgroup2.addComponent(name); hgroup3.addComponent(color); for (int i = 0; i < GC.players.length; i++) { player_nums[i] = new JLabel(Integer.toString(i + 1)); player_nums[i].setFont(player_nums[i].getFont().deriveFont(Font.PLAIN)); hgroup1.addComponent(player_nums[i]); player_names[i] = new JLabel(); color_samples[i] = new JPanel(); if (GC.players[i] != null) { player_names[i].setText(GC.players[i].getName()); if (GC.players[i].ready) player_names[i].setForeground(Color.GREEN); else player_names[i].setForeground(Color.RED); color_samples[i].setBackground( GC.players[i] .getColor()); // player.getColor() returns the default color here, since color is // not yet set color_nums[i] = i; } player_names[i].setFont(player_names[i].getFont().deriveFont(Font.PLAIN)); color_samples[i].setMinimumSize(new Dimension(50, 15)); color_samples[i].setPreferredSize(new Dimension(50, 15)); color_samples[i].setMaximumSize(new Dimension(50, 15)); color_samples[i].addMouseListener(this); hgroup2.addComponent(player_names[i]); hgroup3.addComponent(color_samples[i]); vgroup.addGroup( gl.createParallelGroup() .addComponent(player_nums[i]) .addComponent(player_names[i]) .addComponent(color_samples[i])); } gl.setHorizontalGroup( gl.createSequentialGroup().addGroup(hgroup1).addGroup(hgroup2).addGroup(hgroup3)); gl.setVerticalGroup(vgroup); JScrollPane scroller = new JScrollPane(panel); main_panel.add(scroller, BorderLayout.CENTER); JPanel p2 = new JPanel(); if (is_hosting) start_game = new JButton("Start Game"); else start_game = new JButton("Ready!"); start_game.addActionListener(this); start_game.setMnemonic(KeyEvent.VK_S); start_game.setEnabled(false); p2.add(start_game); leave_game = new JButton("Leave Game"); leave_game.addActionListener(this); leave_game.setMnemonic(KeyEvent.VK_L); p2.add(leave_game); main_panel.add(p2, BorderLayout.SOUTH); add(main_panel); pack(); setVisible(true); filechooser = new JFileChooser(); filechooser.setFileFilter(new FileNameExtensionFilter("XML files only", "xml")); }
private void initForm(Map<Strategy, Integer> votingResults) { ForagingStrategy[] strategies = ForagingStrategy.values(); JPanel panel = new JPanel(); GroupLayout groupLayout = new GroupLayout(panel); panel.setLayout(groupLayout); groupLayout.setAutoCreateGaps(true); groupLayout.setAutoCreateContainerGaps(true); GroupLayout.SequentialGroup horizontalGroup = groupLayout.createSequentialGroup(); // horizontal parallel group GroupLayout.ParallelGroup horizontalLabelParallelGroup = groupLayout.createParallelGroup(); horizontalGroup.addGroup(horizontalLabelParallelGroup); GroupLayout.ParallelGroup horizontalButtonParallelGroup = groupLayout.createParallelGroup(); horizontalGroup.addGroup(horizontalButtonParallelGroup); GroupLayout.SequentialGroup verticalGroup = groupLayout.createSequentialGroup(); boolean imposedStrategyEnabled = (client != null) && client.getCurrentRoundConfiguration().isImposedStrategyEnabled(); // XXX: this is certainly what Rawlins was warning against String rightColumnHeader = votingResults.isEmpty() ? (imposedStrategyEnabled) ? "" : "Select" : "Nominations"; JLabel rightHeaderLabel = new JLabel(rightColumnHeader); rightHeaderLabel.setFont(UserInterfaceUtils.DEFAULT_BOLD_FONT); horizontalButtonParallelGroup.addComponent(rightHeaderLabel); JLabel strategyHeaderLabel = new JLabel("Strategy"); strategyHeaderLabel.setFont(UserInterfaceUtils.DEFAULT_BOLD_FONT); horizontalLabelParallelGroup.addComponent(strategyHeaderLabel); verticalGroup.addGroup( groupLayout .createParallelGroup(Alignment.BASELINE) .addComponent(strategyHeaderLabel) .addGap(20) .addComponent(rightHeaderLabel)); Dimension labelDimension = new Dimension(1000, 100); for (ForagingStrategy strategy : strategies) { JLabel ruleLabel = new JLabel("<html>" + strategy.getDescription() + "</html>"); ruleLabel.setFont(UserInterfaceUtils.DEFAULT_PLAIN_FONT); ruleLabel.setMaximumSize(labelDimension); horizontalLabelParallelGroup.addComponent(ruleLabel); JComponent component = null; if (imposedStrategyEnabled) { component = new JLabel(""); } else if (votingResults.isEmpty()) { JRadioButton radioButton = new JRadioButton(); radioButton.setActionCommand(strategy.name()); buttonGroup.add(radioButton); component = radioButton; // horizontalButtonParallelGroup.addComponent(radioButton); // // verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleLabel).addComponent(radioButton)); } else { Integer numberOfVotes = votingResults.get(strategy); component = new JLabel(String.valueOf(numberOfVotes == null ? 0 : numberOfVotes)); } horizontalButtonParallelGroup.addComponent(component); verticalGroup.addGroup( groupLayout .createParallelGroup(Alignment.BASELINE) .addComponent(ruleLabel) .addGap(DEFAULT_STRATEGY_GAP_SIZE) .addComponent(component)); } if (votingResults.isEmpty()) { JButton submitButton = getSubmitButton(); horizontalLabelParallelGroup.addComponent(submitButton); verticalGroup.addGroup( groupLayout .createParallelGroup(Alignment.BASELINE) .addComponent(submitButton) .addGap(80)); } groupLayout.setHorizontalGroup(horizontalGroup); groupLayout.setVerticalGroup(verticalGroup); JScrollPane scrollPane = new JScrollPane( panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); setLayout(new BorderLayout()); add(scrollPane, BorderLayout.CENTER); }
public DialogActivity(JFrame parentFrame) { super(parentFrame); setTitle("Activity"); lbFirst = new JLabel("Date"); lbSecond = new JLabel("Hours"); lbThird = new JLabel("Activity"); txtFirst = new JTextField(); txtFirst.setColumns(20); txtSecond = new JTextField(); txtSecond.setColumns(20); txtThird = new JTextField(); txtThird.setColumns(20); GroupLayout layout = new GroupLayout(inputPanel); inputPanel.setLayout(layout); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); GroupLayout.ParallelGroup parallelGroup1 = layout.createParallelGroup(); GroupLayout.ParallelGroup parallelGroup2 = layout.createParallelGroup(); parallelGroup1.addComponent(lbFirst).addComponent(lbSecond).addComponent(lbThird); parallelGroup2.addComponent(txtFirst).addComponent(txtSecond).addComponent(txtThird); GroupLayout.SequentialGroup sequentialGroup1 = layout.createSequentialGroup(); sequentialGroup1.addGroup(parallelGroup1); sequentialGroup1.addGroup(parallelGroup2); layout.setHorizontalGroup(sequentialGroup1); GroupLayout.ParallelGroup parallelGroup3 = layout.createParallelGroup(); GroupLayout.ParallelGroup parallelGroup4 = layout.createParallelGroup(); GroupLayout.ParallelGroup parallelGroup5 = layout.createParallelGroup(); parallelGroup3.addComponent(lbFirst).addComponent(txtFirst); parallelGroup4.addComponent(lbSecond).addComponent(txtSecond); parallelGroup5.addComponent(lbThird).addComponent(txtThird); GroupLayout.SequentialGroup sequentialGroup2 = layout.createSequentialGroup(); sequentialGroup2.addGroup(parallelGroup3); sequentialGroup2.addGroup(parallelGroup4); sequentialGroup2.addGroup(parallelGroup5); layout.setVerticalGroup(sequentialGroup2); inputPanel.add(txtFirst); inputPanel.add(txtSecond); inputPanel.add(txtThird); GridLayout btnLayout = new GridLayout(1, 2); btnOk = new JButton("Ok"); btnOk.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (txtFirst.getText().equals("") && txtSecond.getText().equals("")) result = null; else result = new Activity(txtFirst.getText(), txtSecond.getText(), txtThird.getText()); setVisible(false); } }); btnCancel = new JButton("Cancel"); btnCancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result = null; setVisible(false); } }); buttonPanel.setLayout(btnLayout); buttonPanel.add(btnOk); buttonPanel.add(btnCancel); getContentPane().setLayout(new BorderLayout()); getContentPane().add(inputPanel, BorderLayout.CENTER); getContentPane().add(buttonPanel, BorderLayout.SOUTH); pack(); }
/** Create the vertical group */ private GroupLayout.Group createVerticalGroup(GroupLayout gl) { GroupLayout.ParallelGroup vg = gl.createParallelGroup(); vg.addComponent(role_pnl); vg.addComponent(cap_pnl); return vg; }
private void makeArgumentPane(Action a, LibAction la) { setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); JLabel lab; JPanel pane; pane = new JPanel(); pane.setBorder(new EmptyBorder(6, 6, 0, 6)); pane.setLayout(new BorderLayout()); add(pane); if (la.actImage != null) { lab = new JLabel(new ImageIcon(la.actImage)); lab.setBorder(new EmptyBorder(16, 16, 16, 20)); pane.add(lab, BorderLayout.LINE_START); } String s = Messages.getString("ActionFrame.APPLIES"); // $NON-NLS-1$ appliesPanel.setBorder(BorderFactory.createTitledBorder(s)); pane.add(appliesPanel); if (!la.canApplyTo) appliesPanel.setVisible(false); List<Argument> args = a.getArguments(); argComp = new ArgumentComponent[args.size()]; if (args.size() > 0) { pane = new JPanel(); pane.setBorder( BorderFactory.createCompoundBorder( new EmptyBorder(6, 8, 0, 8), BorderFactory.createTitledBorder(""))); GroupLayout kvLayout = new GroupLayout(pane); GroupLayout.SequentialGroup hGroup, vGroup; GroupLayout.ParallelGroup keyGroup, valueGroup; hGroup = kvLayout.createSequentialGroup(); vGroup = kvLayout.createSequentialGroup(); keyGroup = kvLayout.createParallelGroup(Alignment.TRAILING); valueGroup = kvLayout.createParallelGroup(); hGroup.addGap(4); hGroup.addGroup(keyGroup); hGroup.addGap(6); hGroup.addGroup(valueGroup); hGroup.addGap(4); kvLayout.setHorizontalGroup(hGroup); kvLayout.setVerticalGroup(vGroup); pane.setLayout(kvLayout); add(pane); vGroup.addGap(4); for (int n = 0; n < args.size(); n++) { argComp[n] = new ArgumentComponent(args.get(n), a.getLibAction().libArguments[n]); if (la.parent == null) lab = new JLabel(Messages.format("ActionFrame.UNKNOWN", n)); // $NON-NLS-1$ else { LibArgument larg = la.libArguments[n]; lab = new JLabel(larg.caption); } Alignment al; if (n == 0 && act.getLibAction().interfaceKind == LibAction.INTERFACE_ARROWS) { argComp[n].setEditor(new ArrowsEditor(argComp[n].getArgument().getVal())); al = Alignment.CENTER; } else { Component c = argComp[n].getEditor(); c.setMaximumSize(new Dimension(240, 20)); c.setPreferredSize(new Dimension(200, 20)); c.setMinimumSize(new Dimension(160, 20)); al = Alignment.BASELINE; } keyGroup.addComponent(lab); valueGroup.addComponent(argComp[n].getEditor()); if (n > 0) vGroup.addGap(6); GroupLayout.ParallelGroup argGroup = kvLayout.createParallelGroup(al); argGroup.addComponent(lab).addComponent(argComp[n].getEditor()); vGroup.addGroup(argGroup); } vGroup.addGap(4); } pane = new JPanel(); pane.setLayout(new FlowLayout(FlowLayout.TRAILING)); add(pane); if (la.allowRelative) { relativeBox = new JCheckBox(Messages.getString("ActionFrame.RELATIVE")); // $NON-NLS-1$ relativeBox.setSelected(act.isRelative()); pane.add(relativeBox); } if (la.question) { notBox = new JCheckBox(Messages.getString("ActionFrame.NOT")); // $NON-NLS-1$ notBox.setSelected(act.isNot()); pane.add(notBox); } pane = new JPanel(); pane.setLayout(new GridLayout(1, 2, 8, 0)); pane.setBorder(new EmptyBorder(0, 8, 8, 8)); add(pane); s = Messages.getString("ActionFrame.SAVE"); // $NON-NLS-1$ save = new JButton(s, LGM.getIconForKey("ActionFrame.SAVE")); // $NON-NLS-1$ save.addActionListener(this); pane.add(save); s = Messages.getString("ActionFrame.DISCARD"); // $NON-NLS-1$ discard = new JButton(s, LGM.getIconForKey("ActionFrame.DISCARD")); // $NON-NLS-1$ discard.addActionListener(this); pane.add(discard); }
private JPanel createRulesPanel() { JPanel panel = new JPanel(); panel.addAncestorListener(new EventHandler()); panel.setBorder(BorderFactory.createEtchedBorder()); GroupLayout layout = new GroupLayout(panel); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); panel.setLayout(layout); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); GroupLayout.ParallelGroup left = layout.createParallelGroup(); left.addComponent(numberOfRoundsLabel); left.addComponent(gunCoolingRateLabel); left.addComponent(inactivityTimeLabel); left.addComponent(sentryBorderSizeLabel); left.addComponent(hideEnemyNamesLabel); leftToRight.addGroup(left); GroupLayout.ParallelGroup right = layout.createParallelGroup(); right.addComponent(getNumberOfRoundsTextField()); right.addComponent(getGunCoolingRateTextField()); right.addComponent(getInactivityTimeTextField()); right.addComponent(getSentryBorderSizeTextField()); right.addComponent(hideEnemyNamesCheckBox); leftToRight.addGroup(right); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup row0 = layout.createParallelGroup(Alignment.BASELINE); row0.addComponent(numberOfRoundsLabel); row0.addComponent(numberOfRoundsTextField); topToBottom.addGroup(row0); GroupLayout.ParallelGroup row1 = layout.createParallelGroup(Alignment.BASELINE); row1.addComponent(gunCoolingRateLabel); row1.addComponent(getGunCoolingRateTextField()); topToBottom.addGroup(row1); GroupLayout.ParallelGroup row2 = layout.createParallelGroup(Alignment.BASELINE); row2.addComponent(inactivityTimeLabel); row2.addComponent(inactivityTimeTextField); topToBottom.addGroup(row2); GroupLayout.ParallelGroup row3 = layout.createParallelGroup(Alignment.BASELINE); row3.addComponent(sentryBorderSizeLabel); row3.addComponent(sentryBorderSizeTextField); topToBottom.addGroup(row3); GroupLayout.ParallelGroup row4 = layout.createParallelGroup(Alignment.CENTER); row4.addComponent(hideEnemyNamesLabel); row4.addComponent(hideEnemyNamesCheckBox); topToBottom.addGroup(row4); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); return panel; }
private void initGUI() { /** 北部panel */ Font font_12 = new Font("微软雅黑", Font.PLAIN, 14); /** 设置字体 */ crackButton.setFont(font_12); northPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); northPane.setBorder(BorderFactory.createTitledBorder("破解地址")); GroupLayout layout_north = new GroupLayout(northPane); northPane.setLayout(layout_north); /** 自动设定组件、组之间的间隙 */ layout_north.setAutoCreateGaps(true); layout_north.setAutoCreateContainerGaps(true); /** 垂直一 */ GroupLayout.ParallelGroup hpg_north_1 = layout_north.createParallelGroup(GroupLayout.Alignment.LEADING); hpg_north_1.addComponent(label_for_pageUrl); /** 垂直二 */ GroupLayout.ParallelGroup hpg_north_2 = layout_north.createParallelGroup(GroupLayout.Alignment.LEADING); hpg_north_2.addComponent(pageUrl); /** 垂直三 */ GroupLayout.ParallelGroup hpg_north_3 = layout_north.createParallelGroup(GroupLayout.Alignment.LEADING); hpg_north_3.addComponent(crackButton); /** 垂直 */ layout_north.setHorizontalGroup( layout_north .createSequentialGroup() .addGroup(hpg_north_1) .addGroup(hpg_north_2) .addGroup(hpg_north_3)); /** 水平一 */ GroupLayout.ParallelGroup vpg_north_1 = layout_north.createParallelGroup(GroupLayout.Alignment.CENTER); vpg_north_1.addComponent(label_for_pageUrl).addComponent(pageUrl).addComponent(crackButton); /** 水平 */ layout_north.setVerticalGroup(layout_north.createSequentialGroup().addGroup(vpg_north_1)); this.add(northPane, BorderLayout.NORTH); /** 南部panel */ mCode.setColumns(50); regCode.setColumns(50); mCode.setEditable(false); southPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); southPane.setBorder(BorderFactory.createTitledBorder("软件注册")); southPane.add(label_for_mCode); southPane.add(mCode); southPane.add(label_for_regCode); southPane.add(regCode); /** 新增为布局的南部 */ this.add(southPane, BorderLayout.SOUTH); /** 中部panel */ videoInfo = new JPanel(); videoInfo.setBorder(BorderFactory.createTitledBorder("视频信息")); GroupLayout layout = new GroupLayout(videoInfo); videoInfo.setLayout(layout); /** 自动设定组件、组之间的间隙 */ layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); JButton cancelButton = new JButton("Cancel"); /** LEADING -- 左对齐 BASELINE -- 底部对齐 CENTER -- 中心对齐 */ /** 垂直一 */ GroupLayout.ParallelGroup hpg1 = layout.createParallelGroup(GroupLayout.Alignment.LEADING); hpg1.addComponent(label_for_title) .addComponent(label_for_time) .addComponent(label_for_addTime) .addComponent(label_for_imgPre) .addComponent(label_for_crack_video) .addComponent(label_for_fileSize); /** 垂直二 */ GroupLayout.ParallelGroup hpg2 = layout.createParallelGroup(GroupLayout.Alignment.LEADING); hpg2.addComponent(title) .addComponent(time) .addComponent(addTime) .addComponent(image) .addComponent(crackVideo) .addComponent(fileSize); /** 垂直三 */ GroupLayout.ParallelGroup hpg3 = layout.createParallelGroup(GroupLayout.Alignment.LEADING); hpg3.addComponent(cancelButton); /** 垂直 */ layout.setHorizontalGroup( layout.createSequentialGroup().addGroup(hpg1).addGroup(hpg2).addGroup(hpg3)); /** 设定两个Button在水平方向一样宽 */ // layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{crackButton, // cancelButton}); /** 水平一 */ GroupLayout.ParallelGroup vpg1 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); // vpg1.addComponent(crackButton); /** 水平二 */ GroupLayout.ParallelGroup vpg2 = layout.createParallelGroup(GroupLayout.Alignment.CENTER); vpg2.addComponent(label_for_title).addComponent(title).addComponent(cancelButton); /** 水平三 */ GroupLayout.ParallelGroup vpg3 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); vpg3.addComponent(label_for_time).addComponent(time); /** 水平四 */ GroupLayout.ParallelGroup vpg4 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); vpg4.addComponent(label_for_addTime).addComponent(addTime); /** 水平五 */ GroupLayout.ParallelGroup vpg5 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); vpg5.addComponent(label_for_imgPre).addComponent(image); /** 水平六 */ GroupLayout.ParallelGroup vpg6 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); vpg6.addComponent(label_for_crack_video).addComponent(crackVideo); /** 水平七 */ GroupLayout.ParallelGroup vpg7 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); vpg7.addComponent(label_for_fileSize).addComponent(fileSize); /** 水平 */ layout.setVerticalGroup( layout .createSequentialGroup() .addGroup(vpg1) .addGroup(vpg2) .addGroup(vpg3) .addGroup(vpg4) .addGroup(vpg5) .addGroup(vpg6) .addGroup(vpg7)); this.add(videoInfo, BorderLayout.CENTER); }
@Override public JComponent createOptionsPanel() { final JPanel panel = new JPanel(); final JLabel textFieldLabel = new JLabel(getConfigurationLabel()); final JFormattedTextField valueField = prepareNumberEditor("m_limit"); final JLabel comboBoxLabel = new JLabel(InspectionGadgetsBundle.message("constructor.visibility.option")); final JComboBox comboBox = new JComboBox(); comboBox.addItem(Scope.NONE); comboBox.addItem(Scope.PRIVATE); comboBox.addItem(Scope.PACKAGE_LOCAL); comboBox.addItem(Scope.PROTECTED); comboBox.setRenderer( new ListCellRendererWrapper() { @Override public void customize( JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof Scope) setText(((Scope) value).getText()); } }); comboBox.setSelectedItem(ignoreScope); comboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ignoreScope = (Scope) comboBox.getSelectedItem(); } }); comboBox.setPrototypeDisplayValue(Scope.PROTECTED); final GroupLayout layout = new GroupLayout(panel); layout.setAutoCreateGaps(true); panel.setLayout(layout); final GroupLayout.ParallelGroup horizontal = layout.createParallelGroup(); horizontal.addGroup( layout .createSequentialGroup() .addComponent(textFieldLabel) .addComponent( valueField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); horizontal.addGroup( layout .createSequentialGroup() .addComponent(comboBoxLabel) .addComponent(comboBox, 100, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); layout.setHorizontalGroup(horizontal); final GroupLayout.SequentialGroup vertical = layout.createSequentialGroup(); vertical.addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(textFieldLabel) .addComponent(valueField)); vertical.addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(comboBoxLabel) .addComponent(comboBox)); layout.setVerticalGroup(vertical); return panel; }
@Override public void initView() { btPath = new BtnLabel(); btPath.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { btPathActionPerformed(e); } }); tfPath = new javax.swing.JTextField(); lbPath = new javax.swing.JLabel(); tfArgs = new javax.swing.JTextField(); lbArgs = new javax.swing.JLabel(); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); javax.swing.GroupLayout.SequentialGroup hsg1 = layout.createSequentialGroup(); hsg1.addComponent(tfPath, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE); hsg1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); hsg1.addComponent(btPath, 21, 21, 21); javax.swing.GroupLayout.ParallelGroup hpg1 = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); hpg1.addComponent(lbArgs, javax.swing.GroupLayout.Alignment.TRAILING); hpg1.addComponent(lbPath, javax.swing.GroupLayout.Alignment.TRAILING); javax.swing.GroupLayout.ParallelGroup hpg2 = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); hpg2.addGroup(hsg1); hpg2.addComponent(tfArgs, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE); javax.swing.GroupLayout.SequentialGroup hsg2 = layout.createSequentialGroup(); // hsg2.addContainerGap(); hsg2.addGroup(hpg1); hsg2.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); hsg2.addGroup(hpg2); // hsg2.addContainerGap(); layout.setHorizontalGroup(hsg2); javax.swing.GroupLayout.ParallelGroup vpg1 = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE); vpg1.addComponent(lbPath); vpg1.addComponent( tfPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); vpg1.addComponent(btPath, 21, 21, 21); javax.swing.GroupLayout.ParallelGroup vpg2 = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE); vpg2.addComponent(lbArgs); vpg2.addComponent( tfArgs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); javax.swing.GroupLayout.SequentialGroup vsg = layout.createSequentialGroup(); // vsg.addContainerGap(); vsg.addGroup(vpg1); vsg.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); vsg.addGroup(vpg2); // vsg.addContainerGap(); layout.setVerticalGroup(vsg); }