For IntelliJ IDEA,
Android Studio or Eclipse



private void myMethod () {}
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); 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); }
public void actionPerformed (ActionEvent event) { boolean visible = !highMaxSlider.isVisible(); highMaxSlider.setVisible(visible); highRangeButton.setText(visible ? "<" : ">"); GridBagLayout layout = (GridBagLayout)formPanel.getLayout(); GridBagConstraints constraints = layout.getConstraints(highRangeButton); constraints.gridx = visible ? 5 : 4; layout.setConstraints(highRangeButton, constraints); Slider slider = visible ? highMaxSlider : highMinSlider; value.setHighMax((Float)slider.getValue()); } });
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); } }
private void makeGUI() { final JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().setLayout(new FlowLayout()); // include: "class AnswerWorker" code here. // include: "JButton" b code here. f.getContentPane().add(b); f.getContentPane().add(new JButton("Nothing")); f.pack(); f.setVisible(true); }
public LogFactor5ErrorDialog(JFrame jframe, String message) { super(jframe, "Error", true); JButton ok = new JButton("Ok"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); } }); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); bottom.add(ok); JPanel main = new JPanel(); main.setLayout(new GridBagLayout()); wrapStringOnPanel(message, main); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(bottom, BorderLayout.SOUTH); show(); } //--------------------------------------------------------------------------
public void refresh(JButton src) { if(!canRefresh) { src.setEnabled(true); return; } panel2.removeAll(); try { image = ImageIO.read(new ByteArrayInputStream(contents)); } catch (IOException e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER); panel2.add( label, BorderLayout.CENTER ); panel2.updateUI(); src.setEnabled(true); } }
private void initializeComponents (String chartTitle) { JPanel contentPanel = getContentPanel(); { chart = new Chart(chartTitle) { public void pointsChanged () { value.setTimeline(chart.getValuesX()); value.setScaling(chart.getValuesY()); } }; chart.setPreferredSize(new Dimension(150, 62)); contentPanel.add(chart, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } { expandButton = new JButton("+"); expandButton.setBorder(BorderFactory.createEmptyBorder(4, 10, 4, 10)); contentPanel.add(expandButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0)); } } }
/** * Makes a color choosing button that displays only an icon with a square of the given color */ public static JButton makeColorButton(final String promptText, Color iconColor, final JPanel parent) { final ColorIcon icon = new ColorIcon(iconColor); final JButton button = new JButton(icon); button.addActionListener(arg0 -> { Color newColor = JColorChooser.showDialog(parent,promptText, icon.getColor()); if (newColor != null) { icon.setColor(newColor); parent.repaint(); } }); return button; }
public void actionPerformed (ActionEvent event) { boolean visible = !lowMaxSlider.isVisible(); lowMaxSlider.setVisible(visible); lowRangeButton.setText(visible ? "<" : ">"); GridBagLayout layout = (GridBagLayout)formPanel.getLayout(); GridBagConstraints constraints = layout.getConstraints(lowRangeButton); constraints.gridx = visible ? 5 : 4; layout.setConstraints(lowRangeButton, constraints); Slider slider = visible ? lowMaxSlider : lowMinSlider; ScaledNumericPanel.this.value.setLowMax(slider.getValue()); } });
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"); } }); }}); }}); }};
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); } }
private void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. frame = new JFrame("Stanford Named Entity Recognizer"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().setPreferredSize(new Dimension(WIDTH, HEIGHT)); frame.setJMenuBar(addMenuBar()); buildTagPanel(); buildContentPanel(); buildExtractButton(); extractButton.setEnabled(false); extract.setEnabled(false); //Display the window. frame.pack(); frame.setVisible(true); }
public AllatoriStringDecrypterOptions() { this.setIconImages(Resources.iconList); setSize(new Dimension(250, 120)); setResizable(false); setTitle("Allatori decrypter"); getContentPane().setLayout(null); JButton btnNewButton = new JButton("Decrypt"); btnNewButton.setBounds(6, 56, 232, 23); getContentPane().add(btnNewButton); JLabel lblNewLabel = new JLabel("Class:"); lblNewLabel.setBounds(6, 20, 67, 14); getContentPane().add(lblNewLabel); textField = new JTextField(); textField.setToolTipText("* will search all classes"); textField.setText("*"); textField.setBounds(80, 17, 158, 20); getContentPane().add(textField); textField.setColumns(10); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { PluginManager.runPlugin(new AllatoriStringDecrypter(textField.getText())); dispose(); } }); this.setLocationRelativeTo(null); }
private void buildTagPanel() { if (tagPanel == null) { tagPanel = new JToolBar(SwingConstants.VERTICAL); tagPanel.setFloatable(false); frame.getContentPane().add(tagPanel, BorderLayout.EAST); } else { tagPanel.removeAll(); } if (classifier != null) { makeTagMaps(); Set<String> tags = classifier.labels(); String backgroundSymbol = classifier.backgroundSymbol(); for (String tag : tags) { if (backgroundSymbol.equals(tag)) { continue; } Color color = tagToColorMap.get(tag); JButton b = new JButton(tag, new ColorIcon(color)); tagPanel.add(b); } } tagPanel.revalidate(); tagPanel.repaint(); }
public void actionPerformed (ActionEvent event) { chart.setExpanded(!chart.isExpanded()); boolean expanded = chart.isExpanded(); GridBagLayout layout = (GridBagLayout)getContentPanel().getLayout(); GridBagConstraints chartConstraints = layout.getConstraints(chart); GridBagConstraints expandButtonConstraints = layout.getConstraints(expandButton); if (expanded) { chart.setPreferredSize(new Dimension(150, 200)); expandButton.setText("-"); chartConstraints.weightx = 1; expandButtonConstraints.weightx = 0; } else { chart.setPreferredSize(new Dimension(150, 62)); expandButton.setText("+"); chartConstraints.weightx = 0; expandButtonConstraints.weightx = 1; } layout.setConstraints(chart, chartConstraints); layout.setConstraints(expandButton, expandButtonConstraints); chart.revalidate(); } });
this.fcn = fcn; getContentPane().setLayout(new BorderLayout()); getContentPane().add(tabs, BorderLayout.CENTER); buttonPanel = new JPanel(new FlowLayout()); refreshClass = new JButton("Refresh"); refreshClass.addActionListener(this); buttonPanel.add(refreshClass); buttonPanel.setVisible(false); getContentPane().add(buttonPanel, BorderLayout.SOUTH);
super(jframe, title, true); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); JPanel main = new JPanel(); main.setLayout(new FlowLayout()); main.add(new JLabel(label)); JButton ok = new JButton("Ok"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); bottom.add(ok); bottom.add(cancel); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(bottom, BorderLayout.SOUTH); pack(); centerWindow(this);
setTitle("Save As Jar.."); JButton btnNewButton = new JButton("Save As Jar.."); btnNewButton.setMaximumSize(new Dimension(999, 23)); btnNewButton.setMinimumSize(new Dimension(999, 23)); btnNewButton.setSize(new Dimension(999, 0)); getContentPane().setLayout( new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); getContentPane().add(scrollPane); mani.setText("Manifest-Version: 1.0\r\nClass-Path: .\r\nMain-Class: "); scrollPane.setViewportView(mani); getContentPane().add(btnNewButton); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { BytecodeViewer.viewer.setIcon(true);
((JSpinner.DefaultEditor)((JSpinner)component).getEditor()).getTextField().setColumns(4); JPanel panel = new JPanel(); getContentPane().add( panel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, JPanel buttonPanel = new JPanel(); getContentPane().add( buttonPanel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); JButton okButton = new JButton("OK"); buttonPanel.add(okButton); okButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evt) { okPressed = true; JButton cancelButton = new JButton("Cancel"); buttonPanel.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evt) { setVisible(false);
final JFrame frame = new JFrame("Nested Layout Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JPanel gui = new JPanel(new BorderLayout(5,5)); gui.setBorder( new TitledBorder("BorderLayout(5,5)") ); plafComponents.add(plafChooser); plafComponents.add(pack); gui.add(plafComponents, BorderLayout.NORTH); new TitledBorder("GridLayout(0,2,3,3)") ); JButton addNew = new JButton("Add Another Label"); dynamicLabels.add( addNew, BorderLayout.NORTH ); addNew.addActionListener( new ActionListener(){ gui.add( splitPane, BorderLayout.CENTER ); frame.setContentPane(gui); frame.pack(); frame.setLocationRelativeTo(null);