Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package grafo;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.Toolkit;
- import javax.swing.JFrame;
- import grafo.Desenho;
- public class Grafica1 extends JFrame {
- private Toolkit toolkit;
- public Grafica1() {
- toolkit = getToolkit();
- Dimension size = toolkit.getScreenSize();
- //Criando botoes na tela principal
- JPanel panel = new JPanel();
- getContentPane().add(panel);
- panel.setLayout(null);
- JButton caminho = new JButton("Encontre seu caminho");
- caminho.setBounds(150, 60, 300, 30);
- caminho.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- toolkit.beep();
- }
- });
- //Exibir botoes
- panel.add(caminho);
- //Criando menu
- JMenuBar menubar = new JMenuBar();
- ImageIcon saida = new ImageIcon("exit.png");
- JMenu arquivo = new JMenu("Arquivo");
- arquivo.setMnemonic(KeyEvent.VK_F);
- JMenu help = new JMenu("Ajuda");
- arquivo.setMnemonic(KeyEvent.VK_F);
- //Escrevendo texto do help
- JPanel textPanel = new JPanel(new BorderLayout());
- textPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25));
- JTextPane pane = new JTextPane();
- pane.setContentType("text/html");
- String text = "<p><b>Closing windows using the mouse wheel</b></p>" +
- "<p>Clicking with the mouse wheel on an editor tab closes the window. " +
- "This method works also with dockable windows or Log window tabs.</p>";
- pane.setText(text);
- pane.setEditable(false);
- textPanel.add(pane);
- JMenuItem novoArquivo = new JMenuItem("Novo");
- novoArquivo.setMnemonic(KeyEvent.VK_N);
- JMenuItem fileClose = new JMenuItem("Close", saida);
- fileClose.setMnemonic(KeyEvent.VK_C);
- fileClose.setToolTipText("Saida da aplicação");
- fileClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,
- ActionEvent.CTRL_MASK));
- fileClose.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- System.exit(0);
- }
- });
- arquivo.add(novoArquivo);
- arquivo.addSeparator();
- arquivo.addSeparator();
- arquivo.add(fileClose);
- menubar.add(arquivo);
- menubar.add(help);
- setJMenuBar(menubar);
- //Criando tela principal
- // atribui uma decoração mais bonita a janela
- JFrame.setDefaultLookAndFeelDecorated(true);
- setTitle("KaMail - Entrega Rápida");
- setSize(600, 400);
- setLocation((size.width - getWidth())/2, (size.height - getHeight())/2);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setLocationRelativeTo(null);
- }
- public static void main(String[] args) {
- Grafica1 buttons = new Grafica1();
- Grafica1 simple = new Grafica1();
- simple.setVisible(true);
- Grafica1 menubar = new Grafica1();
- Desenho novoDesenho = new Desenho();
- }
- }
Add Comment
Please, Sign In to add comment