Example usage for java.awt GridBagConstraints NONE

List of usage examples for java.awt GridBagConstraints NONE

Introduction

In this page you can find the example usage for java.awt GridBagConstraints NONE.

Prototype

int NONE

To view the source code for java.awt GridBagConstraints NONE.

Click Source Link

Document

Do not resize the component.

Usage

From source file:EditorPaneExample18.java

public EditorPaneExample18() {
    super("JEditorPane Example 18");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);//from  w ww.  j ava 2s.  com

    // Populate it
    createMenuBar();

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java

public EtatJournauxPanel() {
    super();//from  ww w. jav  a 2  s.  com

    this.tabbedJournaux = new JTabbedPane();

    this.setLayout(new GridBagLayout());

    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;

    this.add(this.tabbedJournaux, c);

    JButton buttonImpression = new JButton("Impression");
    JButton buttonClose = new JButton("Fermer");
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    this.add(buttonImpression, c);
    c.gridx++;
    c.weightx = 0;
    this.add(buttonClose, c);

    buttonClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(EtatJournauxPanel.this)).dispose();
        };
    });
    buttonImpression.addActionListener(new ImpressionJournauxAction());
}

From source file:StoppUhr.java

private void initGUI() {
    try {// w ww. j  ava2 s . c  o  m
        AnchorLayout thisLayout = new AnchorLayout();
        getContentPane().setLayout(thisLayout);
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        this.setPreferredSize(new java.awt.Dimension(609, 394));
        {
            jPanel3 = new JPanel();
            GridBagLayout jPanel3Layout = new GridBagLayout();
            jPanel3.setLayout(jPanel3Layout);
            getContentPane().add(jPanel3, new AnchorConstraint(668, 811, 978, 19, AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
            jPanel3.setPreferredSize(new java.awt.Dimension(384, 94));
            {
                jScrollPane1 = new JScrollPane();
                jPanel3.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 90));
                {
                    jTextArea = new JTextArea();
                    jScrollPane1.setViewportView(jTextArea);
                    jTextArea.setText("");
                }
            }
            {
                jTextFieldStNr = new JTextField();
                jPanel3.add(jTextFieldStNr, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                jTextFieldStNr.setText("");
                jTextFieldStNr.setPreferredSize(new java.awt.Dimension(150, 90));
                jTextFieldStNr.setHorizontalAlignment(JTextField.CENTER);
                jTextFieldStNr.setFont(new Font(Font.DIALOG, Font.BOLD, 40));

            }
            jPanel3Layout.rowWeights = new double[] { 0.1 };
            jPanel3Layout.rowHeights = new int[] { 7 };
            jPanel3Layout.columnWeights = new double[] { 0.1, 0.1 };
            jPanel3Layout.columnWidths = new int[] { 7, 7 };
        }
        {
            jPanel2 = new JPanel();
            GridBagLayout jPanel2Layout = new GridBagLayout();
            jPanel2Layout.rowWeights = new double[] { 0.1, 0.1 };
            jPanel2Layout.rowHeights = new int[] { 7, 7 };
            jPanel2Layout.columnWeights = new double[] { 0.1 };
            jPanel2Layout.columnWidths = new int[] { 7 };
            jPanel2.setLayout(jPanel2Layout);
            getContentPane().add(jPanel2, new AnchorConstraint(47, 821, 721, 27, AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
            jPanel2.setPreferredSize(new java.awt.Dimension(363, 178));
            {
                uhrzeitAusgabe = new JLabel();
                jPanel2.add(uhrzeitAusgabe, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                uhrzeitAusgabe.setText("00:00:00");
                uhrzeitAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize));

            }
            {
                stoppuhrAusgabe = new JLabel();
                jPanel2.add(stoppuhrAusgabe, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                stoppuhrAusgabe.setText("00:00:00");
                stoppuhrAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize));
            }
        }
        {
            jPanel1 = new JPanel();
            GridBagLayout jPanel1Layout = new GridBagLayout();
            getContentPane().add(jPanel1, new AnchorConstraint(48, 987, 954, 820, AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
            jPanel1Layout.rowWeights = new double[] { 0.1, 0.1, 0.1, 1.0, 0.1 };
            jPanel1Layout.rowHeights = new int[] { 1, 1, 1, 1, 1 };
            jPanel1Layout.columnWeights = new double[] { 0.1 };
            jPanel1Layout.columnWidths = new int[] { 7 };
            jPanel1.setLayout(jPanel1Layout);
            jPanel1.setPreferredSize(new java.awt.Dimension(100, 330));
            {
                startButton = new JButton();
                jPanel1.add(startButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                        GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                startButton.setPreferredSize(new java.awt.Dimension(90, 30));
                startButton.setText("Start");
            }
            {
                resetButton = new JButton();
                jPanel1.add(resetButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                        GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                resetButton.setText("Reset");
                resetButton.setPreferredSize(new java.awt.Dimension(90, 30));
            }
            {
                jPanel4 = new JPanel();
                GridBagLayout jPanel4Layout = new GridBagLayout();
                jPanel1.add(jPanel4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                        GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                jPanel4.setPreferredSize(new java.awt.Dimension(51, 81));
                jPanel4Layout.rowWeights = new double[] { 0.1, 0.1, 0.1 };
                jPanel4Layout.rowHeights = new int[] { 7, 7, 7 };
                jPanel4Layout.columnWeights = new double[] { 0.1 };
                jPanel4Layout.columnWidths = new int[] { 7 };
                jPanel4.setLayout(jPanel4Layout);
                {
                    plusButton = new JButton();
                    jPanel4.add(plusButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
                            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    plusButton.setText("+");
                    plusButton.setPreferredSize(new java.awt.Dimension(50, 30));
                }
                {
                    minusButton = new JButton();
                    jPanel4.add(minusButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
                            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    minusButton.setText("-");
                    minusButton.setPreferredSize(new java.awt.Dimension(50, 30));
                }
                {
                    jLabelFontSize = new JLabel();
                    jPanel4.add(jLabelFontSize, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                    jLabelFontSize.setFont(new Font(Font.DIALOG, Font.PLAIN, 10));
                    jLabelFontSize.setText("Font Size");
                }
            }

        }

        this.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent evt) {
                thisWindowClosing(evt);
            }
        });

        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonListener(evt);
            }
        });

        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonListener(evt);
            }
        });

        jTextFieldStNr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    stNrFieldListener(evt);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        plusButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                plusButtonListener(evt);
            }
        });

        minusButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minusButtonListener(evt);
            }
        });

        pack();
        this.setSize(609, 394);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.AjouterComptePCGtoPCEFrame.java

public AjouterComptePCGtoPCEFrame() {

    super("Ajouter un compte du plan comptable gnral");
    Container f = this.getContentPane();

    // instanciation du panel et du menu click droit associ
    Vector<AbstractAction> actionClickDroitTable = new Vector<AbstractAction>();

    actionClickDroitTable.add(new AbstractAction("Ajouter au PCE") {

        public void actionPerformed(ActionEvent e) {
            ajoutCompteSelected();/* ww  w .  j av  a 2  s  .c o m*/
        }
    });

    this.planPanel = new PlanComptableGPanel(actionClickDroitTable);

    this.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(12, 2, 12, 2);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridwidth = 2;
    c.gridheight = 1;
    JLabel label = new JLabel("Choississez le ou les comptes  ajouter au Plan Comptable Entreprise");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    f.add(label, c);

    /*******************************************************************************************
     * * Affichage du plan comptable entreprise
     ******************************************************************************************/
    c.insets = new Insets(0, 0, 0, 0);
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.gridy++;
    f.add(this.planPanel, c);

    /*******************************************************************************************
     * * Bouton ajout / fermer
     ******************************************************************************************/
    c.insets = new Insets(2, 2, 1, 2);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    c.gridx = 0;
    c.anchor = GridBagConstraints.SOUTHEAST;

    f.add(this.boutonAjout, c);

    this.boutonAjout.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            ajoutCompteSelected();

        }
    });

    c.gridx++;
    f.add(this.boutonClose, c);
    this.boutonClose.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            AjouterComptePCGtoPCEFrame.this.setVisible(false);
            AjouterComptePCGtoPCEFrame.this.dispose();
        }
    });
    /*
     * this.pack(); this.setVisible(true);
     */
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

public GrandLivrePanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.weightx = 1;// ww  w .  ja v a2 s  . c o  m
    this.tabbedClasse = new JTabbedPane();

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.gridx = 0;

    c.gridy = 0;
    c.gridwidth = 2;
    this.add(this.tabbedClasse, c);

    JButton buttonImpression = new JButton("Impression");
    JButton buttonClose = new JButton("Fermer");
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    this.add(buttonImpression, c);
    c.gridx++;
    c.weightx = 0;
    this.add(buttonClose, c);

    buttonClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(GrandLivrePanel.this)).dispose();
        };
    });
    buttonImpression.addActionListener(new ImpressionGrandLivreAction());
}

From source file:TrabajoFinalJava.DescargaFichero.java

@Override
public void run() {

    //************************INICIO****INTERFAZ**************************************************************************

    JFrame principal = new JFrame("GESTOR DESCARGAS");
    //Colores//from   ww  w .  j av  a 2s.  c o m

    Color nuevoColor = new Color(167, 220, 231);

    principal.getContentPane().setBackground(nuevoColor);

    JLabel tituloPrincipal = new JLabel("GESTOR DESCARGAS");
    JLabel tituloVentana = new JLabel("DESCARGA FICHERO FTP");
    //Recojo la fuente que se esta utilizando actualmente.
    Font auxFont = tituloPrincipal.getFont();

    //Aplico la fuente actual, y al final le doy el tamao del texto...
    tituloPrincipal.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30));
    tituloVentana.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30));
    //tituloVentana.setAlignmentY(0);

    JLabel nombreArchivo = new JLabel("INTRODUCE EL NOMBRE DEL FICHERO A DESCARGAR.");
    JTextField nombreArchivoIn = new JTextField();
    JButton descarga = new JButton("DESCARGA FICHERO.");
    JButton atras = new JButton("ATRAS");

    JButton salir = new JButton("Salir");

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();

    //Asignamos la constante EXIT_ON_CLOSE, cierra la ventana al pulsar la X.
    principal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Asignamos al JFrame el Layout que usaremos, GridBagLayout
    principal.setLayout(gridbag);
    //aadir botones al layout

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0
    gbc.fill = GridBagConstraints.HORIZONTAL;
    principal.add(tituloPrincipal, gbc);

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0
    gbc.fill = GridBagConstraints.NONE;
    principal.add(tituloVentana, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    principal.add(nombreArchivo, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    principal.add(nombreArchivoIn, gbc);

    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    principal.add(descarga, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.1;
    gbc.fill = GridBagConstraints.NONE;
    principal.add(atras, gbc);

    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0
    gbc.fill = GridBagConstraints.HORIZONTAL;
    principal.add(salir, gbc);

    //Hace visible el panel
    principal.setVisible(true);
    principal.setSize(650, 350);
    principal.setLocationRelativeTo(null);
    principal.setResizable(false);
    //principal.pack();

    descarga.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (descargasUsuarioLog <= 9) {
                try {
                    cFtp.connect(ftpSsrver);
                    boolean login = cFtp.login(ftpUser, ftpPass);
                    System.out.print("conexion establecida");

                    cFtp.enterLocalPassiveMode();

                    nombreFichero = nombreArchivoIn.getText();
                    nombrePc = nombreArchivoIn.getText();

                    CrearListaFicheros listarFicheros = new CrearListaFicheros();
                    listarFicheros.start();

                    for (int i = 0; i < CrearListaFicheros.arrayArchivos.size(); i++) {

                        System.out.println(CrearListaFicheros.arrayArchivos.get(i));

                    }

                    if (CrearListaFicheros.arrayArchivos.contains(nombreFichero)) {
                        FTPFile file = cFtp.mlistFile(nombreFichero);
                        long size = file.getSize();
                        System.out.println("Tamao del fichero= " + size);

                        if (size > 1000000) {
                            System.out.println("El fichero es muy grande......");
                        } else {

                            FileOutputStream fos = new FileOutputStream(nombreFichero);
                            cFtp.retrieveFile(nombreFichero, fos);

                            System.out.println("");
                            System.out.println("Archivo recibido");

                            nombreArchivoIn.setBackground(Color.green);
                            descargasUsuarioLog = descargasUsuarioLog + 1;
                            System.out.println(descargasUsuarioLog);

                            //modificamos las descargas totales del usuario en la BBDD
                            Connection conn;

                            try {
                                try {
                                    Class.forName("com.mysql.jdbc.Driver");
                                } catch (Exception y) {
                                    y.printStackTrace();
                                }

                                conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/midb", "root",
                                        "");
                                System.out.println("Conn OK!");

                                stmt = conn.createStatement();

                                stmt.executeUpdate("UPDATE usuarios SET bajadas = '" + descargasUsuarioLog
                                        + "' WHERE usuario = '" + usuarioLog + "';");

                                System.out.print("Descargas modificadas correctamente.");

                                conn.close();
                            } catch (Exception i) {
                                System.out.println(e);
                            }
                        }

                    } else {
                        System.out.println("El fichero no existe...");
                        nombreArchivoIn.setText("El fichero no existe");
                    }

                } catch (IOException r) {
                    r.printStackTrace();
                }

            } else {
                System.out.println(
                        "No te quedan descargas... por favor comuniquese con el administrador del servidor. Gracias.");
                nombreArchivoIn.setText(
                        "No te quedan descargas... por favor comuniquese con el administrador del servidor. Gracias.");

            }

        }

    });

    atras.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            FormularioAccesoFtp accesoFtp = new FormularioAccesoFtp();
            accesoFtp.inicioFtp();
            principal.setVisible(false);

        }

    });

    salir.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            System.exit(1000);

        }

    });

}

From source file:org.jets3t.gui.ProgressPanel.java

private void initGui() {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {/* ww  w . ja v  a2s  .c  o m*/
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setLayout(new GridBagLayout());

    statusMessageLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressPanelStatusMessageLabel");
    statusMessageLabel.setText(" ");
    statusMessageLabel.setHorizontalAlignment(JLabel.CENTER);
    this.add(statusMessageLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    progressBar = skinsFactory.createSkinnedJProgressBar("ProgressPanelProgressBar", 0, 100);
    this.add(progressBar, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Display the cancel button if a cancel event listener is available.
    cancelButton = skinsFactory.createSkinnedJButton("ProgressPanelCancelButton");
    guiUtils.applyIcon(cancelButton, "/images/nuvola/16x16/actions/cancel.png");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    cancelButton.setEnabled(cancelEventTrigger != null);

    this.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
}

From source file:com.game.ui.views.MapEditor.java

public void generateGUI() throws IOException {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    //        setResizable(false);
    JMenuBar menubar = new JMenuBar();
    ImageIcon icon = null;//from   w w w .  ja  va 2 s .c  om
    try {
        icon = GameUtils.shrinkImage("save.png", 20, 20);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JMenu file = new JMenu("File");
    JMenuItem save = new JMenuItem("Save", icon);
    save.setToolTipText("Save Map Information");
    save.setActionCommand("Save Map");
    save.addActionListener(this);
    file.add(save);
    menubar.add(file);
    setJMenuBar(menubar);
    JPanel topPanel = new JPanel();
    topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    topPanel.setLayout(new GridBagLayout());
    JLabel headerLbl = new JLabel("Legend : ");
    headerLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    JLabel lbl1 = new JLabel();
    lbl1.setPreferredSize(new Dimension(50, 20));
    lbl1.setBackground(Configuration.pathColor);
    lbl1.setOpaque(true);
    JLabel lbl2 = new JLabel("- Represents the path.");
    JLabel lbl3 = new JLabel();
    lbl3.setPreferredSize(new Dimension(50, 20));
    lbl3.setBackground(Configuration.enemyColor);
    lbl3.setOpaque(true);
    JLabel lbl4 = new JLabel("- Represents the path with monsters");
    JLabel lbl5 = new JLabel();
    lbl5.setPreferredSize(new Dimension(50, 20));
    lbl5.setBackground(Configuration.startPointColor);
    lbl5.setOpaque(true);
    JLabel lbl6 = new JLabel("- Represents the starting point in the path");
    JLabel lbl7 = new JLabel();
    lbl7.setBackground(Configuration.endPointColor);
    lbl7.setOpaque(true);
    lbl7.setPreferredSize(new Dimension(50, 20));
    JLabel lbl8 = new JLabel("- Ending point in the path");
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 2;
    topPanel.add(headerLbl, c);
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.ipadx = 5;
    c.ipady = 5;
    topPanel.add(lbl1, c);
    c.gridx = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    topPanel.add(lbl2, c);
    c.gridx = 0;
    c.gridy = 2;
    topPanel.add(lbl3, c);
    c.gridx = 1;
    topPanel.add(lbl4, c);
    c.gridx = 0;
    c.gridy = 3;
    topPanel.add(lbl5, c);
    c.gridx = 1;
    topPanel.add(lbl6, c);
    c.gridx = 0;
    c.gridy = 4;
    topPanel.add(lbl7, c);
    c.gridx = 1;
    topPanel.add(lbl8, c);
    add(topPanel, BorderLayout.NORTH);
    bottomPanel = new JPanel();
    add(bottomPanel, BorderLayout.CENTER);
    bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    //        bottomPanel.add(new JButton("kaushik"));
    pack();
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(env.getMaximumWindowBounds());
    setVisible(true);
    callDialogForUsersInput();
}

From source file:org.openconcerto.sql.view.listview.ListSQLView.java

protected void uiInit() {
    this.setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(1, 2, 1, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;//  ww w  .ja  v  a  2 s . c o m
    c.gridy = 0;

    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.itemsPanel, c);
    c.weighty = 0;
    c.gridy++;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTHEAST;
    this.add(this.addBtn, c);
    this.addBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addNewItem();
        }
    });

    this.itemsConstraints.gridx = 0;
    this.itemsConstraints.gridy = 0;
    this.itemsConstraints.weightx = 1;
    this.itemsConstraints.fill = GridBagConstraints.BOTH;
}

From source file:EditorPaneExample20.java

public EditorPaneExample20() {
    super("JEditorPane Example 20");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);//  ww  w.  jav  a  2s.  co  m

    // Populate it
    createMenuBar();

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    insertButton = new JButton("Insert HTML");
    panel.add(insertButton, c);
    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (insertFrame == null) {
                insertFrame = new HTMLInsertFrame("HTML Insertion", pane);
                Point pt = EditorPaneExample20.this.getLocationOnScreen();
                Dimension d = EditorPaneExample20.this.getSize();
                insertFrame.setLocation(pt.x + d.width, pt.y);
                insertFrame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent evt) {
                        insertFrame.dispose();
                        insertFrame = null;
                        setInsertButtonState();
                    }
                });
                insertButton.setEnabled(false);
                insertFrame.setVisible(true);
            }
        }
    });
    insertButton.setEnabled(false);

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit",
                loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}