Example usage for java.awt.event ComponentEvent COMPONENT_RESIZED

List of usage examples for java.awt.event ComponentEvent COMPONENT_RESIZED

Introduction

In this page you can find the example usage for java.awt.event ComponentEvent COMPONENT_RESIZED.

Prototype

int COMPONENT_RESIZED

To view the source code for java.awt.event ComponentEvent COMPONENT_RESIZED.

Click Source Link

Document

This event indicates that the component's size changed.

Usage

From source file:Main.java

@Override
public void componentResized(ComponentEvent e) {
    System.out.println(e.getID() == ComponentEvent.COMPONENT_RESIZED);

}

From source file:Main.java

public Main() {
    setSize(500, 340);//from   ww  w. j  a v a 2s.  c  o  m

    Date currentDate = new Date();
    calendar.setTime(currentDate);

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(4, 1));

    JPanel p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Selected Date"));
    dateLabel = new JLabel(dateFormat.format(currentDate) + "     ");
    dateLabel.setFont(new Font("Arial", Font.BOLD, 24));
    p.add(dateLabel);
    p1.add(p);

    yearSlider.setPaintLabels(true);
    yearSlider.setMajorTickSpacing(5);
    yearSlider.setMinorTickSpacing(1);
    yearSlider.setPaintTicks(true);
    DateListener lst = new DateListener();
    yearSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Year"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(yearSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    String[] months = (new DateFormatSymbols()).getShortMonths();
    hashTable = new Hashtable(12);
    for (int i = 0; i < 12; i++)
        hashTable.put(new Integer(i + 1), new JLabel(months[i], JLabel.CENTER));
    monthSlider.setLabelTable(hashTable);
    monthSlider.setPaintLabels(true);
    monthSlider.setMajorTickSpacing(1);
    monthSlider.setPaintTicks(true);
    monthSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Month"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(monthSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    daySlider = new JSlider(JSlider.HORIZONTAL, 1, maxDays, calendar.get(Calendar.DAY_OF_MONTH));
    daySlider.setPaintLabels(true);
    daySlider.setMajorTickSpacing(5);
    daySlider.setMinorTickSpacing(1);
    daySlider.setPaintTicks(true);
    daySlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Day"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(daySlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    getContentPane().add(p1, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    enableEvents(ComponentEvent.COMPONENT_RESIZED);
    setVisible(true);
}

From source file:Main.java

protected void processComponentEvent(ComponentEvent e) {
    if (e.getID() == ComponentEvent.COMPONENT_RESIZED) {
        int w = getSize().width;

        yearSlider.setLabelTable(null);//from  ww  w. j av a  2s  .c  o  m
        if (w > 200)
            yearSlider.setMajorTickSpacing(5);
        else
            yearSlider.setMajorTickSpacing(10);
        yearSlider.setPaintLabels(w > 100);

        monthSlider.setLabelTable(w > 300 ? hashTable : null);
        if (w <= 300 && w >= 200)
            monthSlider.setMajorTickSpacing(1);
        else
            monthSlider.setMajorTickSpacing(2);
        monthSlider.setPaintLabels(w > 100);

        daySlider.setLabelTable(null);
        if (w > 200)
            daySlider.setMajorTickSpacing(5);
        else
            daySlider.setMajorTickSpacing(10);
        daySlider.setPaintLabels(w > 100);
    }
}

From source file:EventTestPane.java

/** Display Component events. */
public void processComponentEvent(ComponentEvent e) {
    switch (e.getID()) {
    case ComponentEvent.COMPONENT_MOVED:
        showLine("COMPONENT_MOVED");
        break;/*from   ww  w . j  a v  a2s.  c  o  m*/
    case ComponentEvent.COMPONENT_RESIZED:
        showLine("COMPONENT_RESIZED");
        break;
    case ComponentEvent.COMPONENT_HIDDEN:
        showLine("COMPONENT_HIDDEN");
        break;
    case ComponentEvent.COMPONENT_SHOWN:
        showLine("COMPONENT_SHOWN");
        break;
    }
}

From source file:it.ventuland.ytd.ui.GUIClient.java

@Override
public void processComponentEvent(ComponentEvent e) {
    switch (e.getID()) {
    case ComponentEvent.COMPONENT_MOVED:
        break;//w w  w . j a  v  a  2s . com
    case ComponentEvent.COMPONENT_RESIZED:
        middlepane.setDividerLocation(middlepane.getWidth() / 3);
        break;
    case ComponentEvent.COMPONENT_HIDDEN:
        break;
    case ComponentEvent.COMPONENT_SHOWN:
        break;
    }
}

From source file:op.care.prescription.DlgRegular.java

private void reloadTable() {
    String zubereitung = "x";
    if (prescription.getTradeForm() != null) {
        zubereitung = prescription.getTradeForm().getDosageForm().getPreparation();
    }/*from   www. ja  va  2 s .c o  m*/

    tblDosis.setModel(new TMDose(zubereitung, prescription));
    tblDosis.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jspDosis.dispatchEvent(new ComponentEvent(jspDosis, ComponentEvent.COMPONENT_RESIZED));
    tblDosis.getColumnModel().getColumn(TMDose.COL_Dosis).setCellRenderer(new RNDHTML());
    tblDosis.getColumnModel().getColumn(TMDose.COL_Dosis).setHeaderValue(SYSTools.xx("misc.msg.usage"));
}

From source file:op.care.sysfiles.PnlFiles.java

void reloadTable() {
    HashSet<SYSFiles> filesSet = new HashSet<>();

    EntityManager em = OPDE.createEM();//w  ww .j  a v a2 s  . c o m

    Query query0 = em.createQuery(
            "SELECT s FROM SYSFiles s JOIN s.residentAssignCollection res WHERE res.resident = :resident");
    query0.setParameter("resident", resident);
    filesSet.addAll(query0.getResultList());

    Query query1 = em.createQuery(
            "SELECT s FROM SYSFiles s JOIN s.nrAssignCollection nr WHERE nr.nReport.resident = :resident");
    query1.setParameter("resident", resident);
    filesSet.addAll(query1.getResultList());

    Query query2 = em.createQuery(
            "SELECT s FROM SYSFiles s JOIN s.bwiAssignCollection bwi WHERE bwi.bwinfo.resident = :resident");
    query2.setParameter("resident", resident);
    filesSet.addAll(query2.getResultList());

    Query query3 = em.createQuery(
            "SELECT s FROM SYSFiles s JOIN s.preAssignCollection pre WHERE pre.prescription.resident = :resident");
    query3.setParameter("resident", resident);
    filesSet.addAll(query3.getResultList());

    Query query4 = em.createQuery(
            "SELECT s FROM SYSFiles s JOIN s.valAssignCollection val WHERE val.value.resident = :resident");
    query4.setParameter("resident", resident);
    filesSet.addAll(query4.getResultList());

    Query query5 = em.createQuery(
            "SELECT s FROM SYSFiles s JOIN s.npAssignCollection np WHERE np.nursingProcess.resident = :resident");
    query5.setParameter("resident", resident);
    filesSet.addAll(query5.getResultList());

    em.close();

    ArrayList<SYSFiles> listFiles = new ArrayList<>(filesSet);

    Collections.sort(listFiles);

    //        createFilters();
    tmSYSFiles = new TMSYSFiles(listFiles);
    tblFiles.setModel(tmSYSFiles);

    sorter = new TableRowSorter(tmSYSFiles);
    sorter.setSortsOnUpdates(true);
    tblFiles.setRowSorter(sorter);

    //        sorter.setComparator(TMSYSFiles.COL_PIT, new Comparator<Date>() {
    //            @Override
    //            public int compare(Date o1, Date o2) {
    //                return o1.compareTo(o2);
    //            }
    //        });

    //        sorter.setRowFilter(textFilter);

    tblFiles.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd.MM.yyyy HH:mm");
            return super.getTableCellRendererComponent(table, sdf.format((Date) value), isSelected, hasFocus,
                    row, column);
        }
    });
    tblFiles.getColumnModel().getColumn(1).setCellRenderer(new RNDHTML());
    tblFiles.getColumnModel().getColumn(2).setCellRenderer(new RNDHTML());
    tblFiles.getColumnModel().getColumn(3).setCellRenderer(new RNDHTML());

    tblFiles.getColumnModel().getColumn(0).setHeaderValue(SYSTools.xx("nursingrecords.files.tabheader1"));
    tblFiles.getColumnModel().getColumn(1).setHeaderValue(SYSTools.xx("nursingrecords.files.tabheader2"));
    tblFiles.getColumnModel().getColumn(2).setHeaderValue(SYSTools.xx("nursingrecords.files.tabheader3"));
    tblFiles.getColumnModel().getColumn(3).setHeaderValue(SYSTools.xx("nursingrecords.files.tabheader4"));

    jspFiles.dispatchEvent(new ComponentEvent(jspFiles, ComponentEvent.COMPONENT_RESIZED));
}

From source file:org.jimcat.gui.wheellist.WheelList.java

/**
 * signal parent components that the size of this component has changed
 *//*from   ww  w . j  a va 2  s.c  om*/
private void fireResizeEvent() {
    // inform listeners about resize event
    ComponentListener listener[] = getComponentListeners();
    // test if there are listeners
    if (listener.length == 0) {
        return;
    }

    // create event and send
    ComponentEvent event = new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
    for (ComponentListener l : listener) {
        l.componentResized(event);
    }
}

From source file:zsk.JFCMainClient.java

public void processComponentEvent(ComponentEvent e) {
    switch (e.getID()) {
    case ComponentEvent.COMPONENT_MOVED:
        break;/*from w  ww . j  a v  a  2  s. c  o  m*/
    case ComponentEvent.COMPONENT_RESIZED:
        JFCMainClient.frame.middlepane.setDividerLocation(JFCMainClient.frame.middlepane.getWidth() / 3);
        break;
    case ComponentEvent.COMPONENT_HIDDEN:
        break;
    case ComponentEvent.COMPONENT_SHOWN:
        break;
    }
}