List of usage examples for javax.swing JButton equals
public boolean equals(Object obj)
From source file:Main.java
private JButton createGridButton(final int row, final int col) { final JButton b = new JButton("r" + row + ",c" + col); b.addActionListener(e -> {//from w w w . ja va2s . c om JButton gb = Main.this.getGridButton(row, col); System.out.println("r" + row + ",c" + col + " " + (b == gb) + " " + (b.equals(gb))); }); return b; }
From source file:st.jigasoft.dbutil.view.DUReport.java
private void closeAreaCommand(JButton butao) { if (butao.equals(this.btWindowsBtRigth)) { int newState = (this.state == StateReport.NORMAL) ? 1 : (this.state == StateReport.CLOSED) ? 2 : 2; this.stateReport(newState); } else if (butao.equals(this.btWindowsLeft)) { this.stateReport(3); }//from w w w .j ava 2 s.c o m }
From source file:SuitaDetails.java
public DefPanel(String descriptions, String button, String id, int width, final int index, SuitaDetails container) {/*from ww w . ja v a 2 s . co m*/ this.descriptions = descriptions; this.id = id; reference = this; this.container = container; this.index = index; setBackground(new Color(255, 255, 255)); setBorder(BorderFactory.createEmptyBorder(2, 20, 2, 20)); setMaximumSize(new Dimension(32767, 30)); setMinimumSize(new Dimension(100, 30)); setPreferredSize(new Dimension(300, 30)); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); description = new JLabel(descriptions); description.setPreferredSize(new Dimension(width, 20)); description.setMinimumSize(new Dimension(width, 20)); description.setMaximumSize(new Dimension(width, 20)); add(description); filedsGap = new JPanel(); filedsGap.setBackground(new Color(255, 255, 255)); filedsGap.setMaximumSize(new Dimension(20, 20)); filedsGap.setMinimumSize(new Dimension(20, 20)); filedsGap.setPreferredSize(new Dimension(20, 20)); GroupLayout filedsGapLayout = new GroupLayout(filedsGap); filedsGap.setLayout(filedsGapLayout); filedsGapLayout.setHorizontalGroup( filedsGapLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 20, Short.MAX_VALUE)); filedsGapLayout.setVerticalGroup( filedsGapLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 20, Short.MAX_VALUE)); add(filedsGap); userDefinition = new JTextField(); doclistener = new DocumentListener() { public void changedUpdate(DocumentEvent e) { setParentField(userDefinition.getText(), false); } public void removeUpdate(DocumentEvent e) { setParentField(userDefinition.getText(), false); } public void insertUpdate(DocumentEvent e) { setParentField(userDefinition.getText(), false); } }; userDefinition.getDocument().addDocumentListener(doclistener); userDefinition.setText(""); userDefinition.setMaximumSize(new Dimension(300, 100)); userDefinition.setMinimumSize(new Dimension(50, 20)); userDefinition.setPreferredSize(new Dimension(100, 20)); add(userDefinition); filedsGap = new JPanel(); filedsGap.setBackground(new Color(255, 255, 255)); filedsGap.setMaximumSize(new Dimension(20, 20)); filedsGap.setMinimumSize(new Dimension(20, 20)); filedsGap.setPreferredSize(new Dimension(20, 20)); filedsGapLayout = new GroupLayout(filedsGap); filedsGap.setLayout(filedsGapLayout); filedsGapLayout.setHorizontalGroup( filedsGapLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 20, Short.MAX_VALUE)); filedsGapLayout.setVerticalGroup( filedsGapLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 20, Short.MAX_VALUE)); add(filedsGap); if (button.equals("UserSelect")) { final JButton database = new JButton("Database"); database.setMaximumSize(new Dimension(100, 20)); database.setMinimumSize(new Dimension(50, 20)); database.setPreferredSize(new Dimension(80, 20)); add(database); database.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { DatabaseFrame frame = new DatabaseFrame(reference); frame.executeQuery(); frame.setLocation((int) database.getLocationOnScreen().getX() - 100, (int) database.getLocationOnScreen().getY()); frame.setVisible(true); } }); } else if (button.equals("UserScript")) { JButton script = new JButton("Script"); script.setMaximumSize(new Dimension(100, 20)); script.setMinimumSize(new Dimension(50, 20)); script.setPreferredSize(new Dimension(80, 20)); add(script); script.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { Container c; if (RunnerRepository.container != null) c = RunnerRepository.container.getParent(); else c = RunnerRepository.window; try { // String passwd = RunnerRepository.getRPCClient().execute("sendFile", new Object[]{"/etc/passwd"}).toString(); // new MySftpBrowser(RunnerRepository.host,RunnerRepository.user,RunnerRepository.password,userDefinition,c,passwd); new MySftpBrowser(RunnerRepository.host, RunnerRepository.user, RunnerRepository.password, userDefinition, c, false); } catch (Exception e) { System.out.println("There was a problem in opening sftp browser!"); e.printStackTrace(); } } }); filedsGap = new JPanel(); filedsGap.setBackground(new Color(255, 255, 255)); filedsGap.setMaximumSize(new Dimension(10, 10)); filedsGap.setMinimumSize(new Dimension(10, 10)); filedsGap.setPreferredSize(new Dimension(10, 10)); filedsGapLayout = new GroupLayout(filedsGap); filedsGap.setLayout(filedsGapLayout); filedsGapLayout.setHorizontalGroup(filedsGapLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGap(0, 20, Short.MAX_VALUE)); filedsGapLayout.setVerticalGroup(filedsGapLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGap(0, 20, Short.MAX_VALUE)); filedsGap.setLayout(filedsGapLayout); add(filedsGap); final JButton value = new JButton("Value"); value.setMaximumSize(new Dimension(100, 20)); value.setMinimumSize(new Dimension(50, 20)); value.setPreferredSize(new Dimension(80, 20)); add(value); value.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String script = userDefinition.getText(); if (script != null && !script.equals("")) { try { String result = RunnerRepository.getRPCClient().execute("runUserScript", new Object[] { script }) + ""; JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocation(value.getLocationOnScreen()); JLabel l = new JLabel("Script result: " + result); f.getContentPane().add(l, BorderLayout.CENTER); f.pack(); f.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } } }); } else if (button.equals("UserText")) { JPanel database = new JPanel(); database.setBackground(Color.WHITE); database.setMaximumSize(new Dimension(100, 20)); database.setMinimumSize(new Dimension(50, 20)); database.setPreferredSize(new Dimension(80, 20)); add(database); } }