Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ===================
- JentWindowJava.java
- ===================
- import javax.swing.JFrame;
- /**
- *
- * @author Jent Digital Solutions
- * @param
- *
- */
- public class JentWindow extends JFrame {
- private static final long serialVersionUID = 6305168658694781802L;
- /**
- *
- * @param JentTitle Defines a window title
- * @param jexit If true, when the X of window is pressed, the window closes
- * @param jwidth Defines the window width
- * @param jheight Defines the window height
- * @param jresize Defines is the window can be resizable or not
- * @param jmenu Defines is the window have a menu bar or not
- * @param buttonB If the tool bar is closed, if buttonB is true, window also is closed
- */
- public void instWindow(String JentTitle, boolean jexit, int jwidth, int jheight, boolean jresize, boolean jmenu, boolean buttonB){
- if (jexit) {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- //Instantiates a menu bar into the window
- if (jmenu) {
- JentMenuBar menuBar = new JentMenuBar(); //Instantiates an object to make menu works
- menuBar.JentConfigureMenuBar(true, true, true); //Calls method that pass two arguments: file menu and edit menu.
- setJMenuBar(menuBar); //Configures menu bar
- }
- //Instantiates a button bar (tool bar) into the window
- if (buttonB){
- JentButtonBar buttonBar = new JentButtonBar();
- buttonBar.instButtonBar(false);
- }
- setTitle(JentTitle);
- setSize(jwidth, jheight);
- setVisible(true);
- setLocationRelativeTo(null); //center the window at the screen
- setResizable(jresize); //Don't resize
- setLayout(null); ///Don't uses layout
- }
- }
- ==================
- JentButtonBar.java
- ==================
- import java.awt.BorderLayout;
- import java.awt.Container;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JToolBar;
- public class JentButtonBar extends JFrame {
- private static final long serialVersionUID = 1L;
- JToolBar jent_toolbar = new JToolBar();
- public JentButtonBar(){
- super("TOOLBAR");
- }
- /**
- * This class instantiates a Tool Bar on the window
- * If jexitonclose, the bar closes when X is pressed
- */
- public void instButtonBar(boolean jexitonclose){
- jent_toolbar.add(new JButton("Abrir"));
- jent_toolbar.add(new JButton("Novo"));
- jent_toolbar.add(new JButton("Salvar"));
- jent_toolbar.add(new JButton("Fechar"));
- Container pane = this.getContentPane();
- //define como layout o layout de borda
- pane.setLayout(new BorderLayout());
- //adiciona o toolbar no topo
- pane.add(BorderLayout.NORTH, jent_toolbar);
- jent_toolbar.setFloatable(false); //Não permite que a barra se mova na janela
- if (jexitonclose){
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- this.setSize(1024, 54);
- this.setResizable(false);
- this.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment