/** * Create a button to go inside of the toolbar. By default this will load an image resource. The * image filename is relative to the classpath (including the '.' directory if its a part of the * classpath), and may either be in a JAR file or a separate file. * * @param key The key in the resource file to serve as the basis of lookups. */ protected JButton createToolbarButton(String key) { URL url = getResource(key + imageSuffix); JButton b = new JButton(new ImageIcon(url)) { @Override public float getAlignmentY() { return 0.5f; } }; b.setRequestFocusEnabled(false); b.setMargin(new Insets(1, 1, 1, 1)); String astr = getProperty(key + actionSuffix); if (astr == null) { astr = key; } Action a = getAction(astr); if (a != null) { b.setActionCommand(astr); b.addActionListener(a); } else { b.setEnabled(false); } String tip = getResourceString(key + tipSuffix); if (tip != null) { b.setToolTipText(tip); } return b; }
public ShowComp() throws InterruptedException, IOException { super("CONNECTED COMPUTERS"); int x = 0, d = 20; mb = new JMenuBar(); File = new JMenu("File"); mb.add(File); exit = new JMenuItem("Exit"); exit.addActionListener(this); File.add(exit); ta = new JTextArea(); ta.setBounds(20, 30, 315, 470); ta.setEditable(false); add(ta); setJMenuBar(mb); sel = new JLabel("The connected computers are.."); sel.setBounds(15, 5, 300, 30); add(sel); b1 = new JButton("<< BACK"); b1.setBounds(140, 510, 100, 30); b1.setToolTipText("Back to main page"); b1.addActionListener(this); add(b1); setLayout(null); while (x < 360) { x = x + d; setBounds(675, 50, x, 600); this.show(); } // setVisible(true); String s = "192.168.0.", temp = null; Printer printer = new Printer(); printer.start(); Connector connector = new Connector(printer); connector.start(); LinkedList targets = new LinkedList(); for (int i = 1; i <= 255; i++) { temp = s + Integer.toString(i); Target t = new Target(temp); targets.add(t); connector.add(t); } Thread.sleep(2000); connector.shutdown(); connector.join(); for (Iterator i = targets.iterator(); i.hasNext(); ) { Target t = (Target) i.next(); if (!t.shown) t.show(); } setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
protected void addMyControls() { // add browser-style control buttons JButton home = new JButton(new ImageIcon("data/Home24.gif")); JButton back = new JButton(new ImageIcon("data/Back24.gif")); JButton fwd = new JButton(new ImageIcon("data/Forward24.gif")); home.setToolTipText("Home"); home.addActionListener(this); home.setActionCommand(homeCmd); back.setToolTipText("Back"); back.addActionListener(this); back.setActionCommand(backCmd); back.setEnabled(false); // initially disabled fwd.setToolTipText("Forward"); fwd.addActionListener(this); fwd.setActionCommand(forwardCmd); fwd.setEnabled(false); // initially disabled add(home); add(back); add(fwd); add(new JToolBar.Separator()); // set built-in index variables homeIndex = getComponentIndex(home); backIndex = getComponentIndex(back); forwardIndex = getComponentIndex(fwd); JComboBox comboBox = new JComboBox(); comboBox.setEditable(true); comboBox.addActionListener(this); comboBox.setActionCommand(comboCmd); comboBox.setMaximumRowCount(3); // don't let it get too long comboBox.insertItemAt(mainBrowserURL, 0); // don't start it out empty add(comboBox); comboBoxIndex = getComponentIndex(comboBox); }
/** Make the button for navigating to the default folder. */ protected Component makeDefaultFolderNavigationButton() { final JButton goButton = new JButton("Default Folder"); goButton.setToolTipText("Navigate to the default folder."); goButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { try { handleToDefaultFolderAction(); } catch (Exception exception) { reportException(exception); } } }); return goButton; }
private void buildInterface() { // Panel p to hold the label and text field JPanel panelInput = new JPanel(); panelInput.setLayout(new BorderLayout()); panelInput.add(buttonSelect, BorderLayout.EAST); panelInput.add(textFolder, BorderLayout.CENTER); textFolder.setEditable(false); textFolder.setText(System.getProperty("user.home") + "\\"); // Set default save location setLayout(new BorderLayout()); add(panelInput, BorderLayout.NORTH); add(new JScrollPane(textArea), BorderLayout.CENTER); textArea.setEditable(false); buttonSelect.setToolTipText(TOOL_TIP_SELECT_FOLDER); buttonSelect.addActionListener(new ButtonListener()); // Register listener }
public IUmenu(String host) { setTitle("GUUERRA_NAVAL"); efectos = new Efectos(); try { cliente = new Cliente(host); } catch (Exception ex) { } /* Titulo */ titulo = new JLabel(" JHONMAN "); titulo.setForeground(Color.BLACK); titulo.setFont(new Font("Algerian", Font.BOLD, 24)); titulo.setBounds(120, 40, 560, 40); titulo.setHorizontalAlignment(JLabel.CENTER); /* MeEnu de Opciones */ mEnU = new JLabel("MENU DE OPCIONES"); mEnU.setForeground(Color.BLACK); mEnU.setFont(new Font("Algerian", Font.BOLD, 24)); mEnU.setBounds(40, 135, 390, 40); mEnU.setHorizontalAlignment(JLabel.LEFT); ImageIcon i = new ImageIcon("imagenes/apariencia/fondo_def.jpg"); fondo = new JLabel(new ImageIcon(i.getImage().getScaledInstance(800, 600, Image.SCALE_SMOOTH))); fondo.setBounds(0, 0, 800, 600); ImageIcon i1 = new ImageIcon("imagenes/apariencia/botRegistrar.jpg"); ImageIcon i2 = new ImageIcon("imagenes/apariencia/botPrincipiante.jpg"); ImageIcon i3 = new ImageIcon("imagenes/apariencia/botDificil.jpg"); ImageIcon i4 = new ImageIcon("imagenes/apariencia/botSalir.jpg"); ImageIcon i5 = new ImageIcon("imagenes/apariencia/botRaking.jpg"); ImageIcon i6 = new ImageIcon("imagenes/apariencia/brJuegoRed2.jpg"); ImageIcon i11 = new ImageIcon("imagenes/apariencia/botRegistrar2.jpg"); ImageIcon i22 = new ImageIcon("imagenes/apariencia/botPrincipiante2.jpg"); ImageIcon i33 = new ImageIcon("imagenes/apariencia/botDificil2.jpg"); ImageIcon i44 = new ImageIcon("imagenes/apariencia/botSalir2.jpg"); ImageIcon i55 = new ImageIcon("imagenes/apariencia/botRaking2.jpg"); ImageIcon i66 = new ImageIcon("imagenes/apariencia/brJuegoRed.jpg"); /* Boton Puntajes */ estad = new JButton(new ImageIcon(i5.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); estad.setBounds(98, 148, 170, 40); estad.setRolloverIcon( new ImageIcon( i55.getImage() .getScaledInstance( 170, 40, Image .SCALE_SMOOTH))); // cuando el mouse esta sobre el boton cambia a esta // imagen estad.setBorderPainted(false); // elimino los bordes de el boton estad.addActionListener(this); estad.setMnemonic(KeyEvent.VK_P); estad.setToolTipText("ver Raking ALT + P"); /* Boton Registrar */ registrar = new JButton(new ImageIcon(i1.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBounds(98, 205, 170, 40); registrar.setRolloverIcon( new ImageIcon(i11.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBorderPainted(false); registrar.addActionListener(this); registrar.setMnemonic(KeyEvent.VK_Q); registrar.setToolTipText("Registrarse ALT + Q"); /* Boton TipoFacil */ facil = new JButton(new ImageIcon(i2.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBounds(97, 262, 170, 40); facil.setRolloverIcon( new ImageIcon(i22.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBorderPainted(false); facil.addActionListener(this); facil.setMnemonic(KeyEvent.VK_F); facil.setToolTipText("jugar en modo principiante ALT + F"); /* Boton TipoDificil */ dific = new JButton(new ImageIcon(i3.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBounds(97, 317, 170, 40); dific.setRolloverIcon( new ImageIcon(i33.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBorderPainted(false); dific.addActionListener(this); dific.setMnemonic(KeyEvent.VK_D); dific.setToolTipText("jugar en modo dificil ALT + D"); /* Boton Salir */ salir = new JButton(new ImageIcon(i4.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBounds(97, 430, 170, 40); salir.setRolloverIcon( new ImageIcon(i44.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBorderPainted(false); salir.addActionListener(this); salir.setMnemonic(KeyEvent.VK_S); salir.setToolTipText("Salir ALT + S"); /* Boton Red */ red = new JButton(new ImageIcon(i6.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBounds(97, 374, 170, 40); red.setRolloverIcon( new ImageIcon(i66.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBorderPainted(false); red.addActionListener(this); red.setMnemonic(KeyEvent.VK_C); red.setToolTipText("Jugar con varios jugadores ALT + C"); c = getContentPane(); c.setLayout(null); c.add(titulo); c.add(estad); c.add(facil); c.add(registrar); c.add(dific); c.add(salir); c.add(red); c.add(fondo); }