RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

全部问题

Martin Hope
FENIX ф
Asked: 2024-11-27 01:35:14 +0000 UTC

无法使用MySql django正确迁移

  • 5

在此输入图像描述

在此输入图像描述

在此输入图像描述

在此输入图像描述

当我尝试迁移时,我得到的是:

django.core.exceptions.ImproperlyConfigured:         
'django.db.backends.mysql' isn't an available database backend 
or couldn't be imported. Check the above exception. To use one 
of the built-in backends, use 'django.db.backends.XXX', where 
XXX is one of:
'oracle', 'postgresql', 'sqlite3'

看起来我做了一切:我提前创建了数据库,PyMySql在__init__.我正确配置了设置 - 还有什么原因?

python
  • 1 个回答
  • 28 Views
Martin Hope
user27630724
Asked: 2024-11-27 00:38:39 +0000 UTC

DP 任务。我不明白出了什么问题

  • 6

通过问题E-蚱蜢和青蛙的解决方案 满分:100 时间限制:2秒 实时限制:5秒 内存限制:256M 问题E:蚱蜢和青蛙 问题条件(pdf)

蚱蜢沿着位于同一条线上且彼此距离相等的柱子跳跃。这些列的序列号为 1 到 N。一开始,蚱蜢坐在编号为 1 的柱子上。他可以向前跳跃 1 到 K 柱的距离,从当前的柱子开始计算。

有些帖子上有青蛙吃蚱蜢(蚱蜢不应该落在这些帖子上!)。确定 Grasshopper 可以通过多少种方式安全到达编号为 N 的列。请记住,Grasshopper 无法向后跳。输入格式 输入字符串包含自然数 N 和 K,以空格分隔。保证1≤N,K≤32。第二行包含青蛙的数量 L (0≤L≤N−2)。第三行包含L个自然数:青蛙所坐的列数(其中没有数字为1和N的列)。

Примеры
Входные данные
6 4
2
2 4
Выходные данные
3

我不明白出了什么问题,并非所有测试都通过

n, k = map(int, input().split())
l = int(input())
s_l = list(map(int, input().split()))
dp = [1] * n
dp_1 = []
for i in range(l):
    dp[s_l[i] - 1] = 0
dp_1 = []
dp_1.append(dp[0])
print(dp)
for i in range(1,n):
    if dp[i] == 0:
        pass
    else:
        if i < k:
            dp_1.append(sum(dp_1[:i]))
        else:
            dp_1.append(sum(dp_1[i - k:i]))
print(dp_1[-1])
python-3.x
  • 1 个回答
  • 34 Views
Martin Hope
Таня Мамоля
Asked: 2024-11-26 23:26:13 +0000 UTC

如何将变量从一个类传递到另一个类?

  • 6

需要Stol()将字段中的输入值从类中传递到类中Zakaz()并输出到label_6(也在类中Zakaz())

from PyQt6.QtWidgets import *
from стол import Ui_Form as Ui_Form2
from заказ import Ui_Form as Ui_Form3
class Stol(QMainWindow):
    def __init__(self):
        super().__init__()

        self.ui = Ui_Form2()
        self.ui.setupUi(self)
        self.stol = self.ui.lineEdit
        self.ui.pushButton.clicked.connect(self.btn)


    def btn(self):
        self.st = self.stol.text() #переформотировала введеное число в текст
        print(self.st)
        self.main_window = Zakaz()
        self.main_window.show()
        self.hide()
       

class Zakaz(QMainWindow):
    def __init__(self):
        super().__init__()

        self.ui = Ui_Form3()
        self.ui.setupUi(self)
        #self.sto = self.st #здесь в теории хочу записать данные из другого класса
        #print(self.st)

        self.ui.label_6.setText(???) #что сюда писать
    

if __name__ == "__main__":
    app = QApplication([])
    window = Stol()
    window.show()
    app.exec()

用户界面_Form2

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(685, 465)
        Form.setStyleSheet("background-color: rgb(213, 213, 213);")
        self.label = QtWidgets.QLabel(parent=Form)
        self.label.setGeometry(QtCore.QRect(130, 80, 501, 71))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(28)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.pushButton = QtWidgets.QPushButton(parent=Form)
        self.pushButton.setGeometry(QtCore.QRect(220, 340, 261, 51))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(12)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setStyleSheet("background-color: rgb(189, 189, 189);")
        self.pushButton.setObjectName("pushButton")
        self.lineEdit = QtWidgets.QLineEdit(parent=Form)
        self.lineEdit.setGeometry(QtCore.QRect(90, 200, 501, 71))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.lineEdit.setFont(font)
        self.lineEdit.setObjectName("lineEdit")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.label.setText(_translate("Form", "Введите номер стола"))
        self.pushButton.setText(_translate("Form", "Перейти к заказу"))

用户界面_Form3

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(1106, 884)
        Form.setStyleSheet("\n"
"background-color: rgb(213, 213, 213);\n"
"")
        self.label = QtWidgets.QLabel(parent=Form)
        self.label.setGeometry(QtCore.QRect(0, -10, 1111, 31))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(parent=Form)
        self.label_2.setGeometry(QtCore.QRect(-20, 30, 1111, 31))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(parent=Form)
        self.label_3.setGeometry(QtCore.QRect(10, 10, 131, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.pushButton = QtWidgets.QPushButton(parent=Form)
        self.pushButton.setGeometry(QtCore.QRect(500, 110, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_2.setGeometry(QtCore.QRect(690, 110, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_3 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_3.setGeometry(QtCore.QRect(880, 110, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_4 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_4.setGeometry(QtCore.QRect(500, 230, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_4.setFont(font)
        self.pushButton_4.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_5 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_5.setGeometry(QtCore.QRect(690, 230, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_5.setFont(font)
        self.pushButton_5.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_6 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_6.setGeometry(QtCore.QRect(880, 230, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_6.setFont(font)
        self.pushButton_6.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_6.setObjectName("pushButton_6")
        self.line = QtWidgets.QFrame(parent=Form)
        self.line.setGeometry(QtCore.QRect(471, 100, 16, 771))
        self.line.setFrameShape(QtWidgets.QFrame.Shape.VLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line.setObjectName("line")
        self.label_4 = QtWidgets.QLabel(parent=Form)
        self.label_4.setGeometry(QtCore.QRect(10, 110, 201, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.line_2 = QtWidgets.QFrame(parent=Form)
        self.line_2.setGeometry(QtCore.QRect(0, 90, 1091, 16))
        self.line_2.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line_2.setObjectName("line_2")
        self.label_5 = QtWidgets.QLabel(parent=Form)
        self.label_5.setGeometry(QtCore.QRect(10, 60, 71, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(12)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.tableWidget = QtWidgets.QTableWidget(parent=Form)
        self.tableWidget.setGeometry(QtCore.QRect(10, 150, 451, 721))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        self.label_6 = QtWidgets.QLabel(parent=Form)
        self.label_6.setGeometry(QtCore.QRect(170, 10, 131, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_6.setFont(font)
        self.label_6.setStyleSheet("background-color: rgb(226, 226, 226);")
        self.label_6.setText("")
        self.label_6.setObjectName("label_6")
        self.label_7 = QtWidgets.QLabel(parent=Form)
        self.label_7.setGeometry(QtCore.QRect(100, 60, 571, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_7.setFont(font)
        self.label_7.setStyleSheet("background-color: rgb(226, 226, 226);")
        self.label_7.setText("")
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(parent=Form)
        self.label_8.setGeometry(QtCore.QRect(230, 110, 131, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_8.setFont(font)
        self.label_8.setStyleSheet("background-color: rgb(226, 226, 226);")
        self.label_8.setText("")
        self.label_8.setObjectName("label_8")
        self.line.raise_()
        self.label_2.raise_()
        self.label.raise_()
        self.label_3.raise_()
        self.pushButton.raise_()
        self.pushButton_2.raise_()
        self.pushButton_3.raise_()
        self.pushButton_4.raise_()
        self.pushButton_5.raise_()
        self.pushButton_6.raise_()
        self.label_4.raise_()
        self.line_2.raise_()
        self.label_5.raise_()
        self.tableWidget.raise_()
        self.label_7.raise_()
        self.label_6.raise_()
        self.label_8.raise_()

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Оформление заказа"))
        self.label.setText(_translate("Form", "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"))
        self.label_2.setText(_translate("Form", "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"))
        self.label_3.setText(_translate("Form", "Стол №"))
        self.pushButton.setText(_translate("Form", "завтрак"))
        self.pushButton_2.setText(_translate("Form", "холодное"))
        self.pushButton_3.setText(_translate("Form", "горячее"))
        self.pushButton_4.setText(_translate("Form", "суп"))
        self.pushButton_5.setText(_translate("Form", "выпечка"))
        self.pushButton_6.setText(_translate("Form", "десерт"))
        self.label_4.setText(_translate("Form", "Состав заказа:"))
        self.label_5.setText(_translate("Form", "кассир:"))
python
  • 1 个回答
  • 22 Views
Martin Hope
Иван
Asked: 2024-11-26 22:11:52 +0000 UTC

是否可以在 asyncio 中进行两次超时等待?

  • 5

我正在学习 asyncio 并需要解决以下问题。如果协程完成时间超过 3 秒,则需要完成任务。其余任务必须在10秒后完成(程序总运行时间为10秒)。像这样的代码。

async def some_coro(time):
    print(f"Корутина {asyncio.current_task().get_name()} запустилась")
    try:
       await asyncio.sleep(time)
       print(f"Корутина {asyncio.current_task().get_name()} завершилась")
    except asyncio.CancelledError:
       print(f"Корутина {asyncio.current_task().get_name()} отменена")
    

async def wait_10():
    print('начало отсчета 10 сек')
    await asyncio.sleep(10)
    print ('10 сек прошло. Завершаем все задачи')
    for task in asyncio.all_tasks():
        try:
            task.cancel()
        except asyncio.CancelledError:
            pass

async def main():
   tasks = [asyncio.create_task(some_coro(12)), asyncio.create_task(some_coro(2)), asyncio.create_task(some_coro(15))]
    #await asyncio.create_task(wait_10())
   await asyncio.wait(tasks, timeout=5)

asyncio.run(main())  

如果我只运行一个 asyncio.wait(tasks, timeout=5)。然后简单地在 5 秒后取消未完成的任务(但没有 10 秒的通用计数器)如果我添加等待 asyncio.create_task(wait_10()),那么似乎 asyncio.wait 中的超时“不再起作用”,并且这对我来说就是全部任务在 10 秒后完成,而不是在 5 秒超时后完成。首先,我想亲自了解为什么会发生这种情况?其次,是否可以制作“两个独立”的计数器?我觉得我缺少一些异步基础知识,想弄清楚。提前致谢。

python
  • 1 个回答
  • 25 Views
Martin Hope
Kirill
Asked: 2024-11-26 19:36:01 +0000 UTC

输入一个 JTable 单元格的值后,该单元格的值会复制到所有单元格

  • 5

我有一个程序,目前实现了添加和删除表格列的功能,但有一个问题:当您向该表格中输入值时,它们开始在其他单元格中重复:

我在一个单元格中输入一个值:图1

然后我按 Enter 键停止编辑单元格,不知何故,该单元格左侧的所有单元格都神奇地填充了相同的值:图2

如果我单击该单元格右侧的任何单元格,则原始单元格和单击单元格之间的所有单元格(包括它)都将填充相同的值:图3

如果我与按钮交互以沿着一行单元格移动,则所有单元格都会填充相同的值。

代码:

package ru.kirill.task9;


import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

import ru.kirill.addition.Addition;


public class GraphicApp {
    private boolean isReverse = false;

    class MainFrame extends JFrame {
        private static final String TITLE = "Главное меню";
        private static final String MINUS = "-";
        private static final String PLUS = "+";
        private static final String OPEN_BUTTON_TEXT = "Открыть";
        private static final String SAVE_BUTTON_TEXT = "Сохранить";
        private static final String REVERSE_BUTTON_TEXT = "Перевернуть";
        private static final String ENTER_LABEL_TITLE = "Количество элементов";
        private static final String CALCULATE_BUTTON_TEXT = "Рассчитать";
        private static final String REFRESH_BUTTON_TEXT = "Обновить";

        JButton minusButton;
        JButton refreshButton;
        JButton plusButton;
        JButton openButton;
        JButton saveButton;
        JButton reverseButton;
        JButton calculateButton;
        JTable inputTable;
        JTable outputTable;
        JLabel titleOfEnterQuantityElements;
        JTextField fieldOfEnterQuantityElements;


        MainFrame() {
            super(TITLE);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            createMainFrameLayout();

            minusButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    int numberOfCells = Integer.parseInt(fieldOfEnterQuantityElements.getText());
                    if (numberOfCells > 1) {
                        fieldOfEnterQuantityElements.setText(
                            Integer.toString(
                                numberOfCells - 1));
                    }
                }
            });

            refreshButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    int numberOfCells = 1;
                    try {
                        numberOfCells = Integer.parseInt(fieldOfEnterQuantityElements.getText());
                    } catch (NumberFormatException err) {
                        JOptionPane.showMessageDialog(null,
                                                      "Вы ввели неверное значение");
                        fieldOfEnterQuantityElements.setText("1");
                    }
                    int columnCount = inputTable.getColumnCount();
                    if (numberOfCells < 1) {
                        numberOfCells = 1;
                        fieldOfEnterQuantityElements.setText("1");
                    }
                    if (numberOfCells < columnCount) {
                        TableColumnModel inputTableModel = inputTable.getColumnModel();
                        for (int i = 0; i < columnCount - numberOfCells; i++) {
                            inputTable.removeColumn(inputTableModel.getColumn(columnCount - i - 1));
                        }
                    } else {
                        for (int i = 0; i < numberOfCells - columnCount; i++) {
                            TableColumn newColumn = new TableColumn();
                            newColumn.setCellRenderer(new CustomCellRenderer());
                            newColumn.setCellEditor(new CustomCellEditor(new JTextField()));
                            inputTable.addColumn(newColumn);
                        }
                    }
                }
            });

            plusButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    fieldOfEnterQuantityElements.setText(
                        Integer.toString(
                            Integer.parseInt(fieldOfEnterQuantityElements.getText()) + 1));
                }
            });

            pack();
            setSize(600, 285);
            setLocationRelativeTo(null);
            setResizable(false);
            setVisible(true);

            calculateButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    for (int i = 0; i < inputTable.getColumnCount(); i++) {
                        System.out.print(inputTable.getValueAt(0, i));
                    }
                }
            });
        }


        private void createMainFrameLayout() {
            Container pane = getContentPane();
            pane.setLayout(new GridBagLayout());
            GridBagConstraints layout = new GridBagConstraints();

            JPanel topInteractionPanel = new JPanel(new GridBagLayout());
            topInteractionPanel.setBackground(Color.GREEN);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 1;
            layout.weighty = 0.15;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            pane.add(topInteractionPanel, layout);

            minusButton = new JButton(MINUS);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 0.1;
            layout.weighty = 1;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            topInteractionPanel.add(minusButton, layout);

            JPanel enterQuantityElementsPanel = new JPanel(new GridBagLayout());
            layout.weightx = 0.8;
            layout.weighty = 1;
            layout.gridx = 1;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            topInteractionPanel.add(enterQuantityElementsPanel, layout);

            titleOfEnterQuantityElements = new JLabel(ENTER_LABEL_TITLE);
            layout.weightx = 1;
            layout.weighty = 0.5;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            enterQuantityElementsPanel.add(titleOfEnterQuantityElements, layout);

            JPanel enterTextFieldPanel = new JPanel(new GridBagLayout());
            layout.weightx = 1;
            layout.weighty = 0.5;
            layout.gridx = 0;
            layout.gridy = 1;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            enterQuantityElementsPanel.add(enterTextFieldPanel, layout);

            fieldOfEnterQuantityElements = new JTextField();
            fieldOfEnterQuantityElements.setText("1");
            layout.weightx = 0.7;
            layout.weighty = 1;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            enterTextFieldPanel.add(fieldOfEnterQuantityElements, layout);

            refreshButton = new JButton(REFRESH_BUTTON_TEXT);
            layout.weightx = 0.3;
            layout.weighty = 1;
            layout.gridx = 1;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            enterTextFieldPanel.add(refreshButton, layout);

            plusButton = new JButton(PLUS);
            layout.weightx = 0.1;
            layout.weighty = 1;
            layout.gridx = 2;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            topInteractionPanel.add(plusButton, layout);


            JPanel inputTablePanel = new JPanel(new GridBagLayout());
            inputTablePanel.setBackground(Color.BLUE);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 1;
            layout.weighty = 0.30;
            layout.gridx = 0;
            layout.gridy = 1;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            pane.add(inputTablePanel, layout);

            inputTable = new JTable(1, 1);
            TableColumnModel inputTableModel = inputTable.getColumnModel();
            TableColumn firstColumn = new TableColumn();
            firstColumn.setCellRenderer(new CustomCellRenderer());
            firstColumn.setCellEditor(new CustomCellEditor(new JTextField()));
            inputTableModel.addColumn(firstColumn);
            inputTableModel.removeColumn(inputTable.getColumnModel().getColumn(0));
            inputTable.setTableHeader(null);
            inputTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            inputTable.setRowHeight(50);
            JScrollPane inputScrollPane = new JScrollPane(inputTable);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 1;
            layout.weighty = 1;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            inputTablePanel.add(inputScrollPane, layout);


            JPanel bottomInteractionPanel = new JPanel(new GridBagLayout());
            bottomInteractionPanel.setBackground(Color.ORANGE);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 1;
            layout.weighty = 0.15;
            layout.gridx = 0;
            layout.gridy = 2;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            pane.add(bottomInteractionPanel, layout);

            openButton = new JButton(OPEN_BUTTON_TEXT);
            layout.weightx = 0.25;
            layout.weighty = 1;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            bottomInteractionPanel.add(openButton, layout);

            saveButton = new JButton(SAVE_BUTTON_TEXT);
            layout.weightx = 0.25;
            layout.weighty = 1;
            layout.gridx = 1;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            bottomInteractionPanel.add(saveButton, layout);

            reverseButton = new JButton(REVERSE_BUTTON_TEXT);
            layout.weightx = 0.25;
            layout.weighty = 1;
            layout.gridx = 2;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            bottomInteractionPanel.add(reverseButton, layout);

            calculateButton = new JButton(CALCULATE_BUTTON_TEXT);
            layout.weightx = 0.25;
            layout.weighty = 1;
            layout.gridx = 3;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            bottomInteractionPanel.add(calculateButton, layout);


            JPanel outputTablePanel = new JPanel(new GridBagLayout());
            outputTablePanel.setBackground(Color.RED);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 1;
            layout.weighty = 0.30;
            layout.gridx = 0;
            layout.gridy = 3;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            pane.add(outputTablePanel, layout);

            outputTable = new JTable(1, 1);
            outputTable.setTableHeader(null);
            outputTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            outputTable.setRowHeight(50);
            outputTable.setEnabled(false);
            JScrollPane outputScrollPane = new JScrollPane(outputTable);
            layout.fill = GridBagConstraints.BOTH;
            layout.weightx = 1;
            layout.weighty = 1;
            layout.gridx = 0;
            layout.gridy = 0;
            layout.gridwidth = 1;
            layout.gridheight = 1;
            outputTablePanel.add(outputScrollPane, layout);
        }


        class CustomCellEditor extends DefaultCellEditor {
            public CustomCellEditor(JTextField textField) {
                super(textField);
                this.clickCountToStart = 1;
            }
        }


        class CustomCellRenderer extends DefaultTableCellRenderer {
            public Component getTableCellRendererComponent(JTable table, Object value,
                                                           boolean isSelected, boolean hasFocus,
                                                           int row, int column) {
                setFont(table.getFont());
                setValue(value);
                return this;
            }
        }
    }


    public GraphicApp() {
        new MainFrame();
    }
    public GraphicApp(boolean isReverse) {
        this.isReverse = isReverse;
        new MainFrame();
    }


    public static void main(String[] args) {
        new GraphicApp();
    }
}

如何删除此自动完成功能以使一切正常?

java
  • 1 个回答
  • 22 Views
上一页
下一页

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5