我在paintComponent中渲染了白噪声,但我得到了10 fps,因为 这一切都在CPU上处理。有没有什么简单的方法可以使用 GPU 的全部功能?我试过 Aparapi,但有人告诉我有些东西不支持新指令。
Александр
Asked:
2022-08-13 02:54:46 +0800 CST
告诉我有一个 JTable (swing) 表,是否可以使用 Stream 形成一个 List,其中将放置 JTable 表的行号,例如,在第 4 列中包含值“no”?
Александр
Asked:
2020-04-15 02:41:35 +0800 CST
告诉我有一个表格
public class MainFrame extends JFrame {
private int colThread=0;
MainThread mt=new MainThread("Поток - 1");
public MainFrame()
{
setSize(300,300);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable jTable=new JTable(20,4);
jTable.setRowHeight(20);
jTable.addMouseListener(new RightMouse());
add(jTable);
}
}
还有一个右键监听类
public class RightMouse extends MouseAdapter{
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
if (e.getButton()==MouseEvent.BUTTON3)
{
JPopupMenu popupMenu = new TableMenu(e);
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
private class TableMenu extends JPopupMenu
{
JMenuItem anMenu;
public TableMenu(MouseEvent event) {
this.anMenu = new JMenuItem("Увеличить ширину строки");
add(anMenu);
this.anMenu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (event.getComponent() instanceof JTable)
{
JTable table = (JTable) event.getComponent();
try {
table.setRowHeight(table.getRowHeight() + 10);
}catch (IllegalArgumentException err)
{
table.setRowHeight(10);
}
}
}
});
this.anMenu = new JMenuItem("Уменьшить ширину строки");
add(anMenu);
this.anMenu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (event.getComponent() instanceof JTable)
{
JTable table = (JTable) event.getComponent();
try {
table.setRowHeight(table.getRowHeight() - 10);
}catch (IllegalArgumentException err)
{
table.setRowHeight(10);
}
}
}
});
}
}
}
问题是我怎样才能改变某一行的高度,鼠标指针当前可以在该行上,而不是表中的所有行
public class Main {
public static void main(String[]args) {
Window window = new Window();
window.initializeFrame();
PanelPhone panelPhone = new PanelPhone();
panelPhone.initializePanelPhone();
window.add(panelPhone);
}
}
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import java.awt.*;
public class PanelPhone extends JPanel {
JPanel panel;
public PanelPhone() {
panel = new JPanel();
panel.setVisible(true);
}
void initializePanelPhone() {
panel.setLayout(null);
panel.setBorder(new EtchedBorder());
panel.setBackground(Color.GRAY);
panel.setLocation(20, 20);
panel.setSize(300,200);
add(panel);
}
}
import javax.swing.*;
import java.awt.*;
public class Window extends Frame {
private JFrame frame;
public Window(){
frame = new JFrame("Phone");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void initializeFrame() {
frame.setSize(new Dimension(1000 ,900));
frame.setLocationRelativeTo(null);
frame.setLayout(null);
}
}