Package arayuzler

Source Code of arayuzler.RenkSecimEkrani

package arayuzler;

import hibernateSwingApi.component.TablePanel;
import hibernateSwingApi.utils.UiUtils;

import java.awt.Container;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import servis.IkonGetirme;
import urun.pojos.Renk;

public class RenkSecimEkrani extends JDialog {

  private static final long serialVersionUID = 1L;

  private JButton buttonIptal;
  private Renk secilenRenk;
  private TablePanel tableRenk;
  private Container contentPane;

  public RenkSecimEkrani(Frame owner) {
    super(owner, true);
    setResizable(false);
    setTitle("PSA RENK SECİM EKRANI");
    setIconImage(IkonGetirme.dosyaYoluylaIkonuGetir("ikonlar/psaIcon.png")
        .getImage());
    contentPane = getContentPane();
    contentPane.setBounds(100, 100, 470, 300);

    tableRenk = new TablePanel((String) null, Renk.class, true, true);
    tableRenk.getTable().setAutoResizeMode(
        JTable.AUTO_RESIZE_ALL_COLUMNS);
    UiUtils.setPanelTitle(tableRenk, "RENK LİSTESİ");
    tableRenk.getRaporButton().setVisible(false);
    tableRenk.setBounds(0, 0, 434, 262);
    tableRenk.getTable().setRowHeight(20);

    buttonIptal = new JButton("İPTAL");
    buttonIptal.setIcon(IkonGetirme.dosyaYoluylaIkonuGetir("ikonlar/geriButonu.png"));

    buttonIptal.setFont(new Font("Tahoma", Font.BOLD, 12));
    buttonIptal.setBounds(70, 273, 144, 23);
    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout
        .setHorizontalGroup(groupLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(
                                Alignment.TRAILING)
                            .addComponent(
                                tableRenk,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                442,
                                Short.MAX_VALUE)
                            .addComponent(
                                buttonIptal,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                442,
                                Short.MAX_VALUE))
                    .addContainerGap()));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
        Alignment.LEADING).addGroup(
        groupLayout
            .createSequentialGroup()
            .addContainerGap()
            .addComponent(tableRenk,
                GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)
            .addGap(7)
            .addComponent(buttonIptal, GroupLayout.DEFAULT_SIZE,
                41, Short.MAX_VALUE).addContainerGap()));
    getContentPane().setLayout(groupLayout);

    tabloDoldur();
    dinleyicileriDoldur();
    pack();
  }

  private void tabloDoldur() {
    tableRenk.refresh();
  }

  private void dinleyicileriDoldur() {
    addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        sayfayiKapat();
      }
    });

    buttonIptal.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        sayfayiKapat();
      }
    });

    tableRenk.getTable().getSelectionModel()
        .addListSelectionListener(new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
              return;
            secilenRenk = (Renk) tableRenk
                .getSelectedObject();
            dispose();
          }
        });
  }

  protected void sayfayiKapat() {
    secilenRenk = null;
    dispose();
  }

  public Renk showDialog() {
    setVisible(true);
    return secilenRenk;
  }

}
TOP

Related Classes of arayuzler.RenkSecimEkrani

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.