public CustomIconDemo() { Icon leftButtonIcon = new ArrowIcon(SwingConstants.RIGHT); Icon middleButtonIcon = createImageIcon("images/middle.gif", "the middle button"); Icon rightButtonIcon = new ArrowIcon(SwingConstants.LEFT); b1 = new JButton("Disable middle button", leftButtonIcon); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("Middle button", middleButtonIcon); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("Enable middle button", rightButtonIcon); // Use the default text position of CENTER, TRAILING (RIGHT). b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false); // Listen for actions on buttons 1 and 3. b1.addActionListener(this); b3.addActionListener(this); b1.setToolTipText("Click this button to disable the middle button."); b2.setToolTipText("This middle button does nothing when you click it."); b3.setToolTipText("Click this button to enable the middle button."); // Add Components to this container, using the default FlowLayout. add(b1); add(b2); add(b3); }
public PostTestFrame() { setTitle("PostTest"); northPanel = new JPanel(); add(northPanel, BorderLayout.NORTH); northPanel.setLayout(new GridLayout(0, 2)); northPanel.add(new JLabel("Host: ", SwingConstants.TRAILING)); final JTextField hostField = new JTextField(); northPanel.add(hostField); northPanel.add(new JLabel("Action: ", SwingConstants.TRAILING)); final JTextField actionField = new JTextField(); northPanel.add(actionField); for (int i = 1; i <= 8; i++) northPanel.add(new JTextField()); final JTextArea result = new JTextArea(20, 40); add(new JScrollPane(result)); JPanel southPanel = new JPanel(); add(southPanel, BorderLayout.SOUTH); JButton addButton = new JButton("More"); southPanel.add(addButton); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { northPanel.add(new JTextField()); northPanel.add(new JTextField()); pack(); } }); JButton getButton = new JButton("Get"); southPanel.add(getButton); getButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { result.setText(""); final Map<String, String> post = new HashMap<String, String>(); for (int i = 4; i < northPanel.getComponentCount(); i += 2) { String name = ((JTextField) northPanel.getComponent(i)).getText(); if (name.length() > 0) { String value = ((JTextField) northPanel.getComponent(i + 1)).getText(); post.put(name, value); } } new SwingWorker<Void, Void>() { protected Void doInBackground() throws Exception { try { String urlString = hostField.getText() + "/" + actionField.getText(); result.setText(doPost(urlString, post)); } catch (IOException e) { result.setText("" + e); } return null; } }.execute(); } }); pack(); }
public CreInvChecker(Component parent) { typeButtons = new JCheckBox[CHECKTYPES.length]; JPanel boxPanel = new JPanel(new GridLayout(0, 1)); for (int i = 0; i < typeButtons.length; i++) { typeButtons[i] = new JCheckBox(CHECKTYPES[i], true); boxPanel.add(typeButtons[i]); } bstart.setMnemonic('s'); bcancel.setMnemonic('c'); bstart.addActionListener(this); bcancel.addActionListener(this); selectframe.getRootPane().setDefaultButton(bstart); selectframe.setIconImage(Icons.getIcon("Find16.gif").getImage()); boxPanel.setBorder(BorderFactory.createTitledBorder("Select test to check:")); JPanel bpanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); bpanel.add(bstart); bpanel.add(bcancel); JPanel mainpanel = new JPanel(new BorderLayout()); mainpanel.add(boxPanel, BorderLayout.CENTER); mainpanel.add(bpanel, BorderLayout.SOUTH); mainpanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); JPanel pane = (JPanel) selectframe.getContentPane(); pane.setLayout(new BorderLayout()); pane.add(mainpanel, BorderLayout.CENTER); selectframe.pack(); Center.center(selectframe, parent.getBounds()); selectframe.setVisible(true); }
Main() { f = new JFrame("Wiki Seach"); JPanel p = new JPanel(); JPanel p1 = new JPanel(); b = new JButton("Search"); b1 = new JButton("Exit"); t = new JTextField(30); b.addActionListener(this); b1.addActionListener(this); p1.add(b); p1.add(b1); p.add(t); f.setLayout(new GridLayout(2, 1)); f.add(p); f.add(p1); f.pack(); f.setLocationRelativeTo(null); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
public void go() { picture(); ActionListener listener = new BtListener(); go.addActionListener(listener); btn_update_manual.addActionListener(listener); go.setForeground(Color.black); // rights.setFont((new Font("Arial", Font.PLAIN, 12))); title.setFont((new Font("Arial", Font.BOLD, 36))); title.setForeground(new Color(238, 253, 253)); today.setFont((new Font("Arial", Font.BOLD, 16))); today.setForeground(new Color(163, 184, 204)); frame.setLayout(new BorderLayout()); from.setBackground(Color.white); to.setBackground(Color.white); converted.setFont(new Font("Arial", Font.BOLD, 24)); converted.setForeground(new Color(238, 253, 253)); Lfrom.setForeground(new Color(238, 253, 253)); Lto.setForeground(new Color(238, 253, 253)); quantity.setForeground(new Color(238, 253, 253)); Lfrom.setFont(new Font("Arial", Font.BOLD, 24)); Lto.setFont(new Font("Arial", Font.BOLD, 24)); quantity.setFont(new Font("Arial", Font.BOLD, 24)); north.setLayout(new FlowLayout()); north.add(title); north.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.NORTH, north); inner.setLayout(new BorderLayout()); inner.add(BorderLayout.NORTH, today); inner.add(BorderLayout.WEST, picPanel); center.setLayout(new GridLayout(2, 4, 5, 5)); center.add(Lfrom); center.add(from); center.add(Lto); center.add(to); center.add(quantity); center.add(amount); center.add(go); inner.setBackground(new Color(59, 62, 71)); inner.add(BorderLayout.SOUTH, center); center.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.CENTER, inner); south.setBackground(new Color(59, 62, 71)); south.setLayout(new FlowLayout()); south.add(converted); south.add(answer); south.add(btn_update_manual); // south.add(rights); frame.add(BorderLayout.SOUTH, south); frame.setSize(850, 700); frame.setVisible(true); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.setVisible(false); frame.dispose(); System.exit(0); } }); }
/** * And now for a little assembly. Put together the buttons, progress bar and status text field. */ Example1(String name) { setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), name)); progressBar.setMaximum(NUMLOOPS); startButton = new JButton("Start"); startButton.addActionListener(startListener); startButton.setEnabled(true); interruptButton = new JButton("Cancel"); interruptButton.addActionListener(interruptListener); interruptButton.setEnabled(false); JComponent buttonBox = new JPanel(); buttonBox.add(startButton); buttonBox.add(interruptButton); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(buttonBox); add(progressBar); add(statusField); statusField.setAlignmentX(CENTER_ALIGNMENT); buttonBox.setBorder(spaceBelow); Border pbBorder = progressBar.getBorder(); progressBar.setBorder(BorderFactory.createCompoundBorder(spaceBelow, pbBorder)); }
/** Constructor: Sets up the GUI. */ public VoteCounterPanel() { votesForJoe = 0; votesForSam = 0; joe = new JButton("Vote For Joe"); sam = new JButton("Vote for Sam"); joe.addActionListener(new VoteButtonListener()); sam.addActionListener(new VoteButtonListener()); labelJoe = new JLabel("Votes for Joe: " + votesForJoe); labelSam = new JLabel("Votes for Sam: " + votesForSam); labelWinning = new JLabel(); add(joe); add(labelJoe); add(sam); add(labelSam); add(labelWinning); setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT)); setBackground(Color.cyan); }
public OKPanel() { setLayout(new FlowLayout(FlowLayout.RIGHT)); setBorder(BorderFactory.createEtchedBorder()); JButton saveButton = new JButton(StringConstants.BUTTON_SAVE); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveSettings(); thisFrame.setVisible(false); } }); JButton cancelButton = new JButton(StringConstants.BUTTON_CANCEL); cancelButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { thisFrame.setVisible(false); // System.exit(0); } }); add(saveButton); add(cancelButton); }
public SISCFrame(AppContext ctx) { setLayout(new BorderLayout()); SchemePanel.SchemeDocument d = new SchemePanel.SchemeDocument(); sp = new SchemePanel(ctx, d, new JTextPane(d)); input = new JTextArea(4, 70); input.setText("; Enter s-expressions here"); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sp, input); JPanel execPanel = new JPanel(); execPanel.setLayout(new BoxLayout(execPanel, BoxLayout.X_AXIS)); execPanel.add(Box.createHorizontalGlue()); eval = new JButton("Evaluate"); clear = new JButton("Clear"); autoClear = new JCheckBox("Auto-Clear"); submitOnEnter = new JCheckBox("Evaluate on Enter"); autoClear.setSelected(true); submitOnEnter.setSelected(true); execPanel.add(submitOnEnter); execPanel.add(autoClear); execPanel.add(clear); execPanel.add(eval); add(split, BorderLayout.CENTER); add(execPanel, BorderLayout.SOUTH); eval.addActionListener(this); clear.addActionListener(this); input.addKeyListener(this); /* addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });*/ }
public South(Draw d) { this.d = d; initTree(tree); setBackground(Color.black); send.addActionListener(this); step.addActionListener(this); node1.setForeground(Color.white); this.add(node1); attachment1.setColumns(4); this.add(attachment1); node2.setForeground(Color.white); this.add(node2); attachment2.setColumns(4); this.add(attachment2); cost.setForeground(Color.white); this.add(cost); valueOfArc.setColumns(4); this.add(valueOfArc); this.add(send); this.add(step); author.setFont(new Font("SimSun-ExtB", Font.ITALIC, 10)); author.setForeground(Color.BLACK); this.add(author); lblCebotarencoDan.setFont(new Font("SimSun-ExtB", Font.ITALIC, 10)); lblCebotarencoDan.setForeground(Color.WHITE); add(lblCebotarencoDan); }
public ChooseConventionDialog(List<Projet> projets) { this.returnValue = DialogReturnValue.CANCEL; this.selectedItem = null; setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); this.setTitle(ResourceBundle.getBundle("gui.EditConvention").getString("plain.title_choose")); // Fill projects list projets.forEach(conventionComboBox::addItem); buttonOK.addActionListener(e -> onOK()); buttonCancel.addActionListener(e -> onCancel()); // call onCancel() when cross is clicked setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE contentPane.registerKeyboardAction( e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
public ModpackUpdateDialog(LaunchFrame instance, boolean modal) { super(instance, modal); setupGui(); update.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ModManager.update = true; ModManager.backupCFG = backupCFG.isSelected(); ModManager.backupSave = backupSave.isSelected(); setVisible(false); } }); abort.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ModManager.update = false; setVisible(false); } }); }
/** Construtor da classe GameBoard */ public GameView(GameController controller, GameEngine engine) { super("Regras"); this.controller = controller; this.engine = engine; this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setBounds(550, 200, 350, 250); this.setVisible(true); this.setLayout(null); selecione = new JLabel("Selecione uma das regras para o jogo:"); selecione.setBounds(60, 30, 300, 30); add(selecione); conway = new JButton("Conway"); add(conway); conway.setBounds(30, 80, 120, 40); highlife = new JButton("Highlife"); add(highlife); highlife.setBounds(170, 80, 120, 40); livefreeordie = new JButton("LiveFreeOrDie"); add(livefreeordie); livefreeordie.setBounds(100, 140, 120, 40); ButtonHandler handler = new ButtonHandler(); conway.addActionListener(handler); highlife.addActionListener(handler); livefreeordie.addActionListener(handler); }
public PrintTestFrame() { canvas = new PrintComponent(); add(canvas, BorderLayout.CENTER); attributes = new HashPrintRequestAttributeSet(); JPanel buttonPanel = new JPanel(); JButton printButton = new JButton("Print"); buttonPanel.add(printButton); printButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(canvas); if (job.printDialog(attributes)) job.print(attributes); } catch (PrinterException e) { JOptionPane.showMessageDialog(PrintTestFrame.this, e); } } }); JButton pageSetupButton = new JButton("Page setup"); buttonPanel.add(pageSetupButton); pageSetupButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { PrinterJob job = PrinterJob.getPrinterJob(); job.pageDialog(attributes); } }); add(buttonPanel, BorderLayout.NORTH); pack(); }
private void dodajListeners() { RacunovodstvoSpaseniObracuniController racunovodstvoSpaseniObracuniController = new RacunovodstvoSpaseniObracuniController(this); obracunZaJComboBox.addItemListener(racunovodstvoSpaseniObracuniController.getSpaseniObracuniObracunZaJComboBoxItemListener()); obrisiObracunJButton.addActionListener(racunovodstvoSpaseniObracuniController.getSpaseniObracuniObrisiJButtonActionListener()); kreirajPdfJButton.addActionListener(racunovodstvoSpaseniObracuniController.getPDFJButtonActionListener()); }
// Skapar de grafiska komponenterna för menyn public void createLabels() { // Skapar textfält för nick och intellegens och lägger till dem i en lista for (int i = 0; i < 4; i++) { textfields.add(new JTextField(20)); intfields.add(new JTextField(20)); } // Skapar checkboxes för att bestämma om spelaren är ett AI och lägger till den i en lista for (int i = 0; i < 4; i++) { boxes.add(new JCheckBox()); boxes.get(i).addActionListener(this); } // Lägger till labels med förbestämd text i panelen for (int i = 0; i < 4; i++) { panel.add(new JLabel(labeltext[i])); } // Lägger till textfields och checkboxes i panelen for (int i = 4; i < 8; i++) { panel.add(new JLabel(labeltext[i])); panel.add(textfields.get(i - 4)); panel.add(boxes.get(i - 4)); panel.add(intfields.get(i - 4)); intfields.get(i - 4).setVisible(false); } // Lägger till några tomma labels i panelen för att skapa mellanrum och symetri for (int i = 0; i < 5; i++) { panel.add(new JLabel(" ")); } // Lägger till knapparna och lägger actionlisteners på dem panel.add(go); go.addActionListener(this); panel.add(help); help.addActionListener(this); }
public Welcome() { c.setLayout(null); c.add(welcome); welcome.setBounds(250, 100, 600, 50); welcome.setFont(font1); welcome.setForeground(Color.black); c.add(hotel); hotel.setBounds(350, 170, 700, 50); hotel.setFont(font2); hotel.setForeground(Color.black); c.add(check); check.setBounds(450, 350, 250, 50); check.addActionListener(this); c.add(order); order.setBounds(150, 350, 250, 50); order.addActionListener(this); c.add(bill); bill.setBounds(750, 350, 250, 50); bill.addActionListener(this); c.add(exit); exit.setBounds(40, 600, 130, 20); exit.addActionListener(this); c.add(back).setBounds(0, 0, 1800, 1000); }
public void Dragon() { String message = "You have come face to face with Darth Vader."; // "You have awoken the sleeping dragon! // What will you do?"; String title = "DARTH VADER!!!"; // "DRAGON!!!"; usesword = "Use Light Saber"; // "Use Magic Sword"; usedagger = "Use Glowing Hulk Mask"; runaway = "Retreat!"; final JButton retreat = new JButton(runaway); retreat.setCursor(new Cursor(Cursor.HAND_CURSOR)); retreat.addActionListener(this); final JButton dagger = new JButton(usedagger); dagger.setCursor(new Cursor(Cursor.HAND_CURSOR)); dagger.addActionListener(this); final JButton kill = new JButton(usesword); kill.setCursor(new Cursor(Cursor.HAND_CURSOR)); kill.addActionListener(this); Object[] options = {kill, dagger, retreat}; dragon.showOptionDialog( dragon, message, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, (new ImageIcon("MapPics/Vader.png")), options, options[2]); }
public ConnectDialogue(JFrame owner, String title, Properties p) { super(owner, title, true); setSize(300, 200); setLocation(250, 200); props = new Properties(p); // set properties in this class to the ones passed in ok.setPreferredSize(new Dimension(75, 25)); ok.addActionListener(this); cancel.setPreferredSize(new Dimension(75, 25)); cancel.addActionListener(this); JPanel cpanel = new JPanel(); // Grid layout with text fields JPanel cpanel2 = new JPanel(); // Add items to the Content Panel cpanel.setLayout(new GridLayout(5, 2)); cpanel.add(lhost); cpanel.add(host); cpanel.add(lport); cpanel.add(port); cpanel.add(ldatabase); cpanel.add(database); cpanel.add(luser); cpanel.add(user); cpanel.add(lpass); cpanel.add(pass); cpanel2.add(ok); cpanel2.add(cancel); add(cpanel, BorderLayout.NORTH); add(cpanel2, BorderLayout.SOUTH); }
/** * Creates a new NewStringPopupDialog object. * * @param parent DOCUMENT ME! * @param title DOCUMENT ME! */ public NewStringPopupDialog(Frame parent, String title) { super(parent, true); setTitle(title); textField = new JTextField(); textField.setPreferredSize(new Dimension(200, 25)); theString = null; JButton okButton = new JButton("OK"); JButton cancelButton = new JButton("Cancel"); okButton.addActionListener(new OkAction()); cancelButton.addActionListener(new CancelAction()); JPanel panel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); panel.setLayout(gridbag); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; gridbag.setConstraints(textField, c); panel.add(textField); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; gridbag.setConstraints(okButton, c); panel.add(okButton); c.gridx = 1; c.gridy = 1; gridbag.setConstraints(cancelButton, c); panel.add(cancelButton); setContentPane(panel); pack(); setLocationRelativeTo(parent); setVisible(true); }
/** * Bedingungen und Positionen der Bestandteile * * @param Title Legt den Titeltext fest */ public Faehigkeiten(String Title) { super(Title); text = new JLabel( " Manaentzug: 5XP Lebensentzug: 10XP Elementarmeister: 15 XP"); // Legt den ersten Text im Label fest text.setFont(new Font("Serif", Font.PLAIN, 14)); // Legt Schriftgroesse und Font fest getContentPane().add(text); nummer1 = new JButton("Manaentzug"); // definiert Position und Größe für die Buttons nummer1.setBounds(50, 170, 200, 80); nummer1.addActionListener(this); nummer2 = new JButton("Elementarmeister"); // definiert Position und Größe für die Buttons nummer2.setBounds(190, 400, 200, 80); nummer2.addActionListener(this); nummer3 = new JButton("Lebensentzug"); // definiert Position und Größe für die Buttons nummer3.setBounds(330, 170, 200, 80); nummer3.addActionListener(this); if (Board.manaleech == false) { add(nummer1); } if (Board.elementarmeister == false) { add(nummer2); // fuegt die Buttons und den Text im ersten Label zu } if (Board.lifeleech == false) { add(nummer3); } add(text); }
/** Install Add and Remove Buttons into the toolbar */ private void installAddRemovePointButtons() { URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/plus.gif"); ImageIcon plus = new ImageIcon(imgURL); imgURL = ClassLoader.getSystemResource("ch/tbe/pics/minus.gif"); ImageIcon minus = new ImageIcon(imgURL); add = new JButton(plus); rem = new JButton(minus); add.setToolTipText(workingViewLabels.getString("plus")); rem.setToolTipText(workingViewLabels.getString("minus")); add.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WorkingView.this.addRemovePoint(true); } }); rem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WorkingView.this.addRemovePoint(false); } }); add.setContentAreaFilled(false); add.setBorderPainted(false); rem.setContentAreaFilled(false); rem.setBorderPainted(false); toolbar.add(add); toolbar.add(rem); }
public RemoveFrame() { frame = new JFrame("Select Files you wish to Remove from Drive"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getRootPane().setDefaultButton(confirm); try { files = DriveList.list(); } catch (IOException e) { files = new ArrayList<File>(); } confirm = new JButton("Remove"); quit = new JButton("Cancel"); confirm.addActionListener(this); quit.addActionListener(this); frame.setLayout(new BorderLayout()); checkPanel = new JPanel(); control = new JPanel(); control.setLayout(new GridLayout(1, 2)); control.add(confirm); control.add(quit); frame.add(control, BorderLayout.SOUTH); drawCheckPanel(); frame.add(checkPanel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
private void initComponent() { // Create the logger first, because the action listeners // need to refer to it. logger = new JTextArea(8, 50); logger.setMargin(new Insets(5, 5, 5, 5)); logger.setEditable(false); JScrollPane logScrollPane = new JScrollPane(logger); // Create a file chooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Create the open button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). openButton = new JButton("Chose NetBeans ...", createImageIcon("images/open.gif")); openButton.addActionListener(GuiFriendlizerApp.this); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). patchButton = new JButton("Do Patch", createImageIcon("images/patch.gif")); patchButton.addActionListener(GuiFriendlizerApp.this); patchButton.setEnabled(false); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); // use FlowLayout buttonPanel.add(openButton); buttonPanel.add(patchButton); // Add the buttons and the logger to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }
/** * builds and displays the frame without the colored fractal; registers the buttons; sets size, * location, close operation; calls changeFractal() */ private void makeWindow() { // set size and location setSize(740, 800); setLocation(100, 0); // specify close button action setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // instantiate panel panelNorth = new JPanel(); // instantiate buttons and register action listener up = new JButton("level up"); down = new JButton("level down"); up.addActionListener(this); down.addActionListener(this); // set layout setLayout(new BorderLayout(10, 10)); // add panel to frame and buttons to panel add(panelNorth, BorderLayout.NORTH); panelNorth.add(up); panelNorth.add(down); // call changeFractal changeFractal(); }
public LayerDesignPanel(MainFrame father) { this.father = father; this.setLayout(null); jsp.setBounds(10, 10, 800, 600); this.add(jsp); jspL.setBounds(820, 10, 140, 200); this.add(jspL); jl.setCellRenderer(new MyCellRenderer()); jbSaveLayer.setBounds(820, 220, 140, 20); this.add(jbSaveLayer); jbSaveLayer.addActionListener(this); jbLoadLayer.setBounds(820, 250, 140, 20); this.add(jbLoadLayer); jbLoadLayer.addActionListener(this); jbCreate.setBounds(820, 280, 140, 20); this.add(jbCreate); jbCreate.addActionListener(this); jbLoadAll.setBounds(820, 310, 140, 20); this.add(jbLoadAll); jbLoadAll.addActionListener(this); jtfCengMing.setBounds(820, 340, 140, 20); this.add(jtfCengMing); }
public CollageList() { super(); actionComponent = new Button(); Panel toolBar; setLayout(new BorderLayout()); // ggHScroll = new Scrollbar( Scrollbar.HORIZONTAL, 0, 0x8000, 0, 0x8000 ); ggVScroll = new Scrollbar(Scrollbar.VERTICAL, 0, 0x8000, 0, 0x8000); // ggHScroll.addAdjustmentListener( ggCurve ); ggVScroll.addAdjustmentListener(this); toolBar = new Panel(); toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2)); ggAdd = new JButton(" Add "); ggDel = new JButton(" Delete "); ggDup = new JButton(" Duplicate "); ggAdd.addActionListener(this); ggDel.addActionListener(this); ggDup.addActionListener(this); toolBar.add(ggAdd); toolBar.add(ggDel); toolBar.add(ggDup); add(toolBar, BorderLayout.NORTH); // add( ggHScroll, BorderLayout.SOUTH ); add(ggVScroll, BorderLayout.EAST); add(new CollageCanvas(this), BorderLayout.CENTER); // add( ggCurve, BorderLayout.CENTER ); }
private void showControlDemo() { JButton button1 = new JButton("but1"); JButton button2 = new JButton("but2"); JButton button3 = new JButton("but3"); button1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { statusLabel.setText("button 1 clicked"); } }); button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { statusLabel.setText("button 2 clicked"); } }); button3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { statusLabel.setText("button 3 clicked"); } }); controlPanel.add(button1); controlPanel.add(button2); controlPanel.add(button3); frame.setVisible(true); }
public UpgradesPanel(ORUIManager orUIManager) { super(BoxLayout.Y_AXIS); this.orUIManager = orUIManager; preferredSize = new Dimension((int) Math.round(100 * (2 + Scale.getFontScale()) / 3), 200); setSize(preferredSize); setVisible(true); upgradePanel = new JPanel(); upgradePanel.setOpaque(true); upgradePanel.setBackground(Color.DARK_GRAY); upgradePanel.setBorder(border); upgradePanel.setLayout(new GridLayout(defaultNbPanelElements, 1)); scrollPane = new JScrollPane(upgradePanel); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setSize(getPreferredSize()); doneButton.setActionCommand("Done"); doneButton.setMnemonic(KeyEvent.VK_D); doneButton.addActionListener(this); cancelButton.setActionCommand("Cancel"); cancelButton.setMnemonic(KeyEvent.VK_C); cancelButton.addActionListener(this); add(scrollPane); }
public AnimationFrame() { ArrayComponent comp = new ArrayComponent(); add(comp, BorderLayout.CENTER); final Sorter sorter = new Sorter(comp); JButton runButton = new JButton("Run"); runButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { sorter.setRun(); } }); JButton stepButton = new JButton("Step"); stepButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { sorter.setStep(); } }); JPanel buttons = new JPanel(); buttons.add(runButton); buttons.add(stepButton); add(buttons, BorderLayout.NORTH); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); Thread t = new Thread(sorter); t.start(); }