mKorbel 274

  • again I thik that answers going wrong directions

  • never to use paintComponent for JTableHeader, is called more times than Renderer,

  • use Renderer for JTableHeader

  • never to use JTableHeader out of JScrollPane

  • hide JScrollBars

  • JTable, JScrollPane and JComboBox cant returns reasonable PreferredSize from methods implemented in theirs API

  • JTable/JScrollPane required to overide setPreferred(ScrollableViewport)Size for pack()

  • Standard LayoutManagers (most of todays customs too) accepting only PreferredSize with pack()

  • three reasons for ColumnModelListener

    1. convertColumnIndexToModel for prepareRenderer/Editor, but by default code line convertXxxIndexToXxx replace, supply usage of this Listener

    2. auto column adjuster for table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);, to hold rellative coordinates after container resized

    3. and (put all mentioned points together)

.

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;

public class TableFilterRow extends JFrame implements TableColumnModelListener {

    private static final long serialVersionUID = 1L;
    private JTable table;
    private JPanel filterRow; 

    public TableFilterRow() {
        table = new JTable(3, 5);
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
        JScrollPane scrollPane = new JScrollPane(table);
        getContentPane().add(scrollPane);
        table.getColumnModel().addColumnModelListener(this);
        filterRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
        for (int i = 0; i < table.getColumnCount(); i++) {
            filterRow.add(new JTextField(" Sum at - " + i));
        }
        columnMarginChanged(new ChangeEvent(table.getColumnModel()));
        getContentPane().add(filterRow, BorderLayout.SOUTH);
    }

    @Override
    public void columnMarginChanged(ChangeEvent e) {
        TableColumnModel tcm = table.getColumnModel();
        int columns = tcm.getColumnCount();

        for (int i = 0; i < columns; i++) {
            JTextField textField = (JTextField) filterRow.getComponent(i);
            Dimension d = textField.getPreferredSize();
            d.width = tcm.getColumn(i).getWidth();
            textField.setPreferredSize(d);
        }

        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                filterRow.revalidate();
            }
        });
    }

    @Override
    public void columnMoved(TableColumnModelEvent ...

mKorbel 274

@bguild answers here going wrong directions, please to review that, from end to the start,

@CoilFyzx please whats your goal, there are simpler ways, by using JTable and/or with another, both JTables can has the same TableModel, depends of your final idea, used notifiers and Listeners

mKorbel 274

conclusion

  • use Grouping in Regex

    1. grouping in Big Figures (000 000 / 000,000), incl. indian numbers formatter (1,00,000) use ISO standards

    2. decimal separator, grouping separator use ISO standards

    3. number and currecny formats (west formatting, arabic, hindu, chinese, japan ... ending with indian) use ISO standards

    4. number of decimal places is different CCy by CCy, (JPY, CHF etc...) use ISO standards

    5. up to 64 conditions for whole (Standard ISO Currency) world, simple binary tree with additional/conditionals nodes

  • if value passed then output should be a number in double form and in proper Java Currency format

  • Double/Float haven't decimal places, most important for all calculations for MM and Security market, difference will be significant,

riahc3 commented: Where were you when this thread was on? Just a post to get the thread answered by you. Voted down. -1

mKorbel 274

there are see two issues

  1. decimal separator is dot programming languages

  2. use Numbers instance with Currency formatter, then output to the Java GUI will be 10,00, but stored with dot internally

mKorbel 274

  • never to paint to the Top-Level Containers, use JPanel instead

  • prepare all Objects to the Array (if there are more than one element)

  • use paintComponent inastead of paint

mKorbel 274

mKorbel 274

I'm not sure (and i'm against to use Thread.sleep(int)) in Swing code, anyway in your previous thread was suggested somenthig about javax.swing.Timer

1/ look for myTimer.restart(); in your case (KeyListener)

2/ look for KeyBinding, is more confortable than KeyListener

3/ for inspiration, very simple example

[CODE]import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;

public class AnimationBackground {

public AnimationBackground() {
    Random random = new Random();
    JFrame frame = new JFrame("Animation Background");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    final MyJPanel panel = new MyJPanel();
    panel.setBackground(Color.BLACK);
    for (int i = 0; i < 50; i++) {
        Star star = new Star(new Point(random.nextInt(490), random.nextInt(490)));
        star.setColor(new Color(100 + random.nextInt(155), 100 + random.nextInt(155), 100 + random.nextInt(155)));
        star.setxIncr(-3 + random.nextInt(7));
        star.setyIncr(-3 + random.nextInt(7));
        panel.add(star);
    }
    panel.setLayout(new GridLayout(10, 1));
    JLabel label = new JLabel("This is a Starry background.", JLabel.CENTER);
    label.setForeground(Color.WHITE);
    panel.add(label);
    JPanel stopPanel = new JPanel();
    stopPanel.setOpaque(false);
    stopPanel.add(new JButton(new AbstractAction("Stop this madness!!") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            panel.stopAnimation();
        }
    }));
    panel.add(stopPanel);
    JPanel startPanel = new JPanel();
    startPanel.setOpaque(false);
    startPanel.add(new JButton(new AbstractAction("Start moving...") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            panel.startAnimation();
        }
    }));
    panel.add(startPanel);
    frame.add(panel);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            AnimationBackground animationBackground = new AnimationBackground();
        }
    });
}

class Star extends Polygon {

    private ...

mKorbel 274

if required export(s) to MsOffice (Word, Excell with formulas) then only Net is result, otherwise I don't see any differencies

java and .net have lot of custom L&F

java required JRE instalations

mKorbel 274

great topic, great sugestion, stupid reply

but you are big star on this small heaven(s) then here comings ...

[url]http://download.oracle.com/javase/tutorial/uiswing/events/index.html[/url]

don't forget look at KeyBindings too with my intention to avoids to continue this thread :-)

mKorbel 274

and you must be sure that topLayoutContainer [url]http://download.oracle.com/javase/tutorial/uiswing/components/toplevel.html[/url] is just and only JApplet not Applet,

mKorbel 274

error(s) comings just from dbConnection, GUI is correct,