This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.text.DecimalFormat; | |
| public class NomeDaClasse { | |
| public static void main(String[] args) { | |
| double numero | |
| DecimalFormat df = new DecimalFormat("##.##"); //o número formatado terá duas casas decimais | |
| JOptionPane.showMessageDialog(null, df.format(numero)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Criar JFrameA | |
| //O Evento windowOpened deve ser o primeiro a ser criado. (na aba Projeto) | |
| //Criar a JLabelData e JLabelHorario no rodapé do JFrameA (na aba Projeto) | |
| private void formWindowOpened(java.awt.event.WindowEvent evt) { | |
| //Editando a Data | |
| Date dataSistema = new Date(); | |
| SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); | |
| jLabelData.setText(formato.format(dataSistema)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Criar JFrameA e JFrameB | |
| //Criar jProgressBar dentro do JFrameA | |
| private Timer tempo= null; | |
| private int count = 0; | |
| public JFrameA() { | |
| initComponents(); | |
| tempo = new Timer(100, new ActionListener() { | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Este método será declarado dentro de um JButton. | |
| System.exit(0); //Este comando fecha o JFrame, onde o JButton foi criado |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Este método será declarado dentro de um JButton. | |
| new JFameB().setVisible(true); //Este comando abre o JFrameB. | |
| this.dispose(); //Este comando fecha o JFrame onde o JButton foi criado |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Este método será declarado dentro de um JButton. | |
| Toolkit toolkt = Toolkit.getDefaultToolkit(); | |
| Dimension dimensao = toolkt.getScreenSize(); | |
| JOptionPane.showMessageDialog(this,"A resolução do monitor em pixels é: "+ | |
| " * Largura: \n"+ dimensao.height+ "* Altura: "+dimensao.width); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Este método será declarado dentro de um JButton. | |
| Locale idioma = Locale.getDefault(); | |
| JOptionPane.showMessageDialog(this,"O idioma do Sistema Operacional é: " + idioma.getDisplayLanguage()); |