主頁 > 作業系統 > 有沒有其他方法可以在新的JFrame中顯示不同的影像,具體取決于單擊的JRadioButton物件,而不創建100多個類?

有沒有其他方法可以在新的JFrame中顯示不同的影像,具體取決于單擊的JRadioButton物件,而不創建100多個類?

2022-07-04 06:24:32 作業系統

我創建了一個 Java 程式,旨在用于以下目的:單擊每個代表元素周期表中的化學元素的 JRadioButton 物件后,由新 JFrame 中的 JLabel 物件表示的相應螢屏截圖將展示周期表中每個化學元素的各種屬性桌子。

該程式具有名為 PeriodicTable、AtomicNumber 和 Properties 的公共類。PeriodicTable 包含 main 方法并實體化 AtomicNumber。AtomicNumber 是一個顯示元素周期表的 JFrame,而 Properties 打開一個新的 JFrame 用于顯示屬性的 png 影像。所有化學元素都由 JRadioButton 物件表示。元素周期表中每種化學元素的各種屬性是一個已保存為 png 影像的螢屏截圖,使用 JLabel ImageIcon 方法實體化。

在按照元素周期表中的確切順序排列所有化學元素后,我注意到 JFrame 中沒有足夠的空間來添加屬性的 png 檔案。為了解決這個問題,我使用名為 Properties 的公共類創建了一個新的 JFrame,其中只能顯示第一個化學元素 Hydrogen 的 png 影像。雖然為屬性調整 png 影像的大小似乎是一種可行的方法,但結果是字體太小而無法辨認。為了為屬性顯示不同的png影像,具體取決于單擊哪個代表化學元素的JRadioButton物件,我嘗試在公共類AtomicNumber的ActionEvent中添加和洗掉png影像,但無濟于事。

我已經考慮過創建 100 多個類來顯示每個包含相應 png 屬性檔案的視窗的可能性,但這似乎太麻煩了。在不創建 100 多個類的情況下,是否有任何其他方法可以在單擊代表化學元素的 JRadioButton 物件時顯示每個相應的屬性 png 檔案?感謝您的幫助。

有沒有其他方法可以在新的 JFrame 中顯示不同的影像,具體取決于單擊的 JRadioButton 物件,而不創建 100 多個類? 有沒有其他方法可以在新的 JFrame 中顯示不同的影像,具體取決于單擊的 JRadioButton 物件,而不創建 100 多個類?

我的代碼如下:

//PeriodicTable.java
public class PeriodicTable {
  public static void main(String[] args) {
    new AtomicNumber();
  }
}
********************
//AtomicNumber.java
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.EventQueue;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.Font;
    import javax.swing.ButtonGroup;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JTextField;
    import javax.swing.SwingConstants;
    
    public class AtomicNumber extends JFrame implements ActionListener {
      private static final long serialVersionUID = 1L;
      static ButtonGroup periodicTable;
      ImageIcon[] elementImage;
      ImageIcon periodicTableIcon;
      static JButton[] button;
      static JLabel[] properties;
      static JPanel panel;
      static JRadioButton[] element;
      JTextField title;
    
  AtomicNumber() {
    elementClip = new Clip[119];
    propertiesClip = new Clip[119];
    elementAudioFile = new File[119];
    propertiesAudioFile = new File[119];
    elementAudioFile[1] = new File("H.wav");

    elementImage = new ImageIcon[119];
    properties = new JLabel[119];
    button = new JButton[2];
    button[0] = new JButton("reset");
    button[0].setBounds(1000, 500, 200, 50);
    button[1] = new JButton("restart");
    button[1].setBounds(1000, 550, 200, 50);
    for (int i = 0; i < 2; i  ) {
      button[i].addActionListener(this);
      button[i].setFocusable(false);
      button[i].setFont(new Font("Times New Roman", Font.BOLD, 30));
      button[i].setPreferredSize(new Dimension(240, 50));
    }
    title = new JTextField("The Periodic Table of the Chemical Elements");
    title.setBounds(0, 0, 1080, 65);
    title.setEditable(false);
    title.setFont(new Font("Arial", Font.BOLD, 50));
    element = new JRadioButton[119];
    element[1] = new JRadioButton("1");
    element[1].setBounds(50, 75, 50, 50);
    elementImage[1] = new ImageIcon(getClass().getClassLoader().getResource("H.png"));
    properties[1] = new JLabel();
    element[2] = new JRadioButton("2");
    element[2].setBounds(925, 75, 50, 50);
    elementImage[2] = new ImageIcon(getClass().getClassLoader().getResource("He.png"));
    properties[2] = new JLabel();
    element[3] = new JRadioButton("3");
    element[3].setBounds(50, 125, 50, 50);
    elementImage[3] = new ImageIcon(getClass().getClassLoader().getResource("Li.png"));
    properties[3] = new JLabel();
    element[4] = new JRadioButton("4");
    element[4].setBounds(100, 125, 50, 50);
    elementImage[4] = new ImageIcon(getClass().getClassLoader().getResource("Be.png"));
    properties[4] = new JLabel();
    element[5] = new JRadioButton("5");
    element[5].setBounds(675, 125, 50, 50);
    elementImage[5] = new ImageIcon(getClass().getClassLoader().getResource("B.png"));
    properties[5] = new JLabel();
    element[6] = new JRadioButton("6");
    element[6].setBounds(725, 125, 50, 50);
    elementImage[6] = new ImageIcon(getClass().getClassLoader().getResource("C.png"));
    properties[6] = new JLabel();
    element[7] = new JRadioButton("7");
    element[7].setBounds(775, 125, 50, 50);
    elementImage[7] = new ImageIcon(getClass().getClassLoader().getResource("N.png"));
    properties[7] = new JLabel();
    element[8] = new JRadioButton("8");
    element[8].setBounds(825, 125, 50, 50);
    elementImage[8] = new ImageIcon(getClass().getClassLoader().getResource("O.png"));
    properties[8] = new JLabel();
    element[9] = new JRadioButton("9");
    element[9].setBounds(875, 125, 50, 50);
    elementImage[9] = new ImageIcon(getClass().getClassLoader().getResource("F.png"));
    properties[9] = new JLabel();
    element[10] = new JRadioButton("10");
    element[10].setBounds(925, 125, 50, 50);
    elementImage[10] = new ImageIcon(getClass().getClassLoader().getResource("Ne.png"));
    properties[10] = new JLabel();
    element[11] = new JRadioButton("11");
    element[11].setBounds(50, 175, 50, 50);
    elementImage[11] = new ImageIcon(getClass().getClassLoader().getResource("Na.png"));
    properties[11] = new JLabel();
    element[12] = new JRadioButton("12");
    element[12].setBounds(100, 175, 50, 50);
    elementImage[12] = new ImageIcon(getClass().getClassLoader().getResource("Mg.png"));
    properties[12] = new JLabel();
    element[13] = new JRadioButton("13");
    element[13].setBounds(675, 175, 50, 50);
    elementImage[13] = new ImageIcon(getClass().getClassLoader().getResource("Al.png"));
    properties[13] = new JLabel();
    element[14] = new JRadioButton("14");
    element[14].setBounds(725, 175, 50, 50);
    elementImage[14] = new ImageIcon(getClass().getClassLoader().getResource("Si.png"));
    properties[14] = new JLabel();
    element[15] = new JRadioButton("15");
    element[15].setBounds(775, 175, 50, 50);
    elementImage[15] = new ImageIcon(getClass().getClassLoader().getResource("P.png"));
    properties[15] = new JLabel();
    element[16] = new JRadioButton("16");
    element[16].setBounds(825, 175, 50, 50);
    elementImage[16] = new ImageIcon(getClass().getClassLoader().getResource("S.png"));
    properties[16] = new JLabel();
    element[17] = new JRadioButton("17");
    element[17].setBounds(875, 175, 50, 50);
    elementImage[17] = new ImageIcon(getClass().getClassLoader().getResource("Cl.png"));
    properties[17] = new JLabel();
    element[18] = new JRadioButton("18");
    element[18].setBounds(925, 175, 50, 50);
    elementImage[18] = new ImageIcon(getClass().getClassLoader().getResource("Ar.png"));
    properties[18] = new JLabel();
    element[19] = new JRadioButton("19");
    element[19].setBounds(50, 225, 50, 50);
    elementImage[19] = new ImageIcon(getClass().getClassLoader().getResource("K.png"));
    properties[19] = new JLabel();
    element[20] = new JRadioButton("20");
    element[20].setBounds(100, 225, 50, 50);
    elementImage[20] = new ImageIcon(getClass().getClassLoader().getResource("Ca.png"));
    properties[20] = new JLabel();
    element[21] = new JRadioButton("21");
    element[21].setBounds(150, 225, 50, 50);
    elementImage[21] = new ImageIcon(getClass().getClassLoader().getResource("Sc.png"));
    properties[21] = new JLabel();
    element[22] = new JRadioButton("22");
    element[22].setBounds(225, 225, 50, 50);
    elementImage[22] = new ImageIcon(getClass().getClassLoader().getResource("Ti.png"));
    properties[22] = new JLabel();
    element[23] = new JRadioButton("23");
    element[23].setBounds(275, 225, 50, 50);
    elementImage[23] = new ImageIcon(getClass().getClassLoader().getResource("V.png"));
    properties[23] = new JLabel();
    element[24] = new JRadioButton("24");
    element[24].setBounds(325, 225, 50, 50);
    elementImage[24] = new ImageIcon(getClass().getClassLoader().getResource("Cr.png"));
    properties[24] = new JLabel();
    element[25] = new JRadioButton("25");
    element[25].setBounds(375, 225, 50, 50);
    elementImage[25] = new ImageIcon(getClass().getClassLoader().getResource("Mn.png"));
    properties[25] = new JLabel();
    element[26] = new JRadioButton("26");
    element[26].setBounds(425, 225, 50, 50);
    elementImage[26] = new ImageIcon(getClass().getClassLoader().getResource("Fe.png"));
    properties[26] = new JLabel();
    element[27] = new JRadioButton("27");
    element[27].setBounds(475, 225, 50, 50);
    elementImage[27] = new ImageIcon(getClass().getClassLoader().getResource("Co.png"));
    properties[27] = new JLabel();
    element[28] = new JRadioButton("28");
    element[28].setBounds(525, 225, 50, 50);
    elementImage[28] = new ImageIcon(getClass().getClassLoader().getResource("Ni.png"));
    properties[28] = new JLabel();
    element[29] = new JRadioButton("29");
    element[29].setBounds(575, 225, 50, 50);
    elementImage[29] = new ImageIcon(getClass().getClassLoader().getResource("Cu.png"));
    properties[29] = new JLabel();
    element[30] = new JRadioButton("30");
    element[30].setBounds(625, 225, 50, 50);
    elementImage[30] = new ImageIcon(getClass().getClassLoader().getResource("Zn.png"));
    properties[30] = new JLabel();
    element[31] = new JRadioButton("31");
    element[31].setBounds(675, 225, 50, 50);
    elementImage[31] = new ImageIcon(getClass().getClassLoader().getResource("Ga.png"));
    properties[31] = new JLabel();
    element[32] = new JRadioButton("32");
    element[32].setBounds(725, 225, 50, 50);
    elementImage[32] = new ImageIcon(getClass().getClassLoader().getResource("Ge.png"));
    properties[32] = new JLabel();
    element[33] = new JRadioButton("33");
    element[33].setBounds(775, 225, 50, 50);
    elementImage[33] = new ImageIcon(getClass().getClassLoader().getResource("As.png"));
    properties[33] = new JLabel();
    element[34] = new JRadioButton("34");
    element[34].setBounds(825, 225, 50, 50);
    elementImage[34] = new ImageIcon(getClass().getClassLoader().getResource("Se.png"));
    properties[34] = new JLabel();
    element[35] = new JRadioButton("35");
    element[35].setBounds(875, 225, 50, 50);
    elementImage[35] = new ImageIcon(getClass().getClassLoader().getResource("Br.png"));
    properties[35] = new JLabel();
    element[36] = new JRadioButton("36");
    element[36].setBounds(925, 225, 50, 50);
    elementImage[36] = new ImageIcon(getClass().getClassLoader().getResource("Kr.png"));
    properties[36] = new JLabel();
    element[37] = new JRadioButton("37");
    element[37].setBounds(50, 275, 50, 50);
    elementImage[37] = new ImageIcon(getClass().getClassLoader().getResource("Rb.png"));
    properties[37] = new JLabel();
    element[38] = new JRadioButton("38");
    element[38].setBounds(100, 275, 50, 50);
    elementImage[38] = new ImageIcon(getClass().getClassLoader().getResource("Sr.png"));
    properties[38] = new JLabel();
    element[39] = new JRadioButton("39");
    element[39].setBounds(150, 275, 50, 50);
    elementImage[39] = new ImageIcon(getClass().getClassLoader().getResource("Y.png"));
    properties[39] = new JLabel();
    element[40] = new JRadioButton("40");
    element[40].setBounds(225, 275, 50, 50);
    elementImage[40] = new ImageIcon(getClass().getClassLoader().getResource("Zr.png"));
    properties[40] = new JLabel();
    element[41] = new JRadioButton("41");
    element[41].setBounds(275, 275, 50, 50);
    elementImage[41] = new ImageIcon(getClass().getClassLoader().getResource("Nb.png"));
    properties[41] = new JLabel();
    element[42] = new JRadioButton("42");
    element[42].setBounds(325, 275, 50, 50);
    elementImage[42] = new ImageIcon(getClass().getClassLoader().getResource("Mo.png"));
    properties[42] = new JLabel();
    element[43] = new JRadioButton("43");
    element[43].setBounds(375, 275, 50, 50);
    elementImage[43] = new ImageIcon(getClass().getClassLoader().getResource("Tc.png"));
    properties[43] = new JLabel();
    element[44] = new JRadioButton("44");
    element[44].setBounds(425, 275, 50, 50);
    elementImage[44] = new ImageIcon(getClass().getClassLoader().getResource("Ru.png"));
    properties[44] = new JLabel();
    element[45] = new JRadioButton("45");
    element[45].setBounds(475, 275, 50, 50);
    elementImage[45] = new ImageIcon(getClass().getClassLoader().getResource("Rh.png"));
    properties[45] = new JLabel();
    element[46] = new JRadioButton("46");
    element[46].setBounds(525, 275, 50, 50);
    elementImage[46] = new ImageIcon(getClass().getClassLoader().getResource("Pd.png"));
    properties[46] = new JLabel();
    element[47] = new JRadioButton("47");
    element[47].setBounds(575, 275, 50, 50);
    elementImage[47] = new ImageIcon(getClass().getClassLoader().getResource("Ag.png"));
    properties[47] = new JLabel();
    element[48] = new JRadioButton("48");
    element[48].setBounds(625, 275, 50, 50);
    elementImage[48] = new ImageIcon(getClass().getClassLoader().getResource("Cd.png"));
    properties[48] = new JLabel();
    element[49] = new JRadioButton("49");
    element[49].setBounds(675, 275, 50, 50);
    elementImage[49] = new ImageIcon(getClass().getClassLoader().getResource("In.png"));
    properties[49] = new JLabel();
    element[50] = new JRadioButton("50");
    element[50].setBounds(725, 275, 50, 50);
    elementImage[50] = new ImageIcon(getClass().getClassLoader().getResource("Sn.png"));
    properties[50] = new JLabel();
    element[51] = new JRadioButton("51");
    element[51].setBounds(775, 275, 50, 50);
    elementImage[51] = new ImageIcon(getClass().getClassLoader().getResource("Sb.png"));
    properties[51] = new JLabel();
    element[52] = new JRadioButton("52");
    element[52].setBounds(825, 275, 50, 50);
    elementImage[52] = new ImageIcon(getClass().getClassLoader().getResource("Te.png"));
    properties[52] = new JLabel();
    element[53] = new JRadioButton("53");
    element[53].setBounds(875, 275, 50, 50);
    elementImage[53] = new ImageIcon(getClass().getClassLoader().getResource("I.png"));
    properties[53] = new JLabel();
    element[54] = new JRadioButton("54");
    element[54].setBounds(925, 275, 50, 50);
    elementImage[54] = new ImageIcon(getClass().getClassLoader().getResource("Xe.png"));
    properties[54] = new JLabel();
    element[55] = new JRadioButton("55");
    element[55].setBounds(50, 325, 50, 50);
    elementImage[55] = new ImageIcon(getClass().getClassLoader().getResource("Cs.png"));
    properties[55] = new JLabel();
    element[56] = new JRadioButton("56");
    element[56].setBounds(100, 325, 50, 50);
    elementImage[56] = new ImageIcon(getClass().getClassLoader().getResource("Ba.png"));
    properties[56] = new JLabel();
    /*element[57]=new JRadioButton("57);
    elementImage[57]=new ImageIcon(getClass().getClassLoader().getResource("La.png"));
    properties[57]=new JLabel();*/

    periodicTableIcon = new ImageIcon(getClass().getClassLoader().getResource("periodicTableIcon.png"));
    periodicTable = new ButtonGroup();
    panel = new JPanel();
    panel.add(title);
    for (int i = 1; i < 57; i  ) {
      element[i].addActionListener(this);
      element[i].setFocusable(false);
      element[i].setIcon(elementImage[i]);
      element[i].setHorizontalTextPosition(SwingConstants.CENTER);
      element[i].setVerticalTextPosition(SwingConstants.TOP);
      periodicTable.add(element[i]);
      panel.add(element[i]);
      panel.add(properties[i]);
    }
    for (int i = 0; i < 2; i  ) {
      panel.add(button[i]);
    }
    panel.setLayout(null);
    panel.setOpaque(false);
    this.add(panel);
    this.getContentPane().setBackground(Color.WHITE);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setIconImage(periodicTableIcon.getImage());
    this.setSize(1500, 1500);
    this.setTitle("The Periodic Table of the Chemical Elements");
    this.setVisible(true);
  }
  public void actionPerformed(ActionEvent e) {
      Properties Properties = new Properties();
      for (int i = 1; i < 119; i  ) {
        if (e.getSource() == button[0] && element[i].isSelected()) {
          periodicTable.clearSelection();
        }
      }
      if (e.getSource() == button[1]) {
        EventQueue.invokeLater(new Runnable() {
          public void run() {
            new AtomicNumber();
            JOptionPane.showMessageDialog(null, "Program has restarted.", "Restart", JOptionPane.INFORMATION_MESSAGE);
          }
        });
      }
      if (element[1].isSelected()) {
        new Properties().setVisible(true);}
********************
//Properties.java
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Properties extends JFrame {

  private static final long serialVersionUID = 1L;

  JLabel[] properties;
  JPanel propertiesPanel;
  Properties() {
    properties = new JLabel[119];
    properties[0] = new JLabel(new ImageIcon(getClass().getClassLoader().getResource("H_properties.png")));

    propertiesPanel = new JPanel();
    propertiesPanel.add(properties[0]);
    this.add(propertiesPanel);
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.setResizable(false);
    this.setSize(1250, 340);

  }
}

uj5u.com熱心網友回復:

對于所有元素,您應該只需要在 Class 上。

現在,這不是一個答案,而只是對手頭任務的不同方法(概念)的建議,描述它的最佳方式是在行動中看到它:

有沒有其他方法可以在新的 JFrame 中顯示不同的影像,具體取決于單擊的 JRadioButton 物件,而不創建 100 多個類?

這實際上來自www.britannica.com,您可以在這里玩當頁面顯示時,單擊小元素周期表影像以縮放影像。打開一個面板,顯示更大版本的元素周期表,底部是一個影像微調器。將影像微調器滾動到最后一張影像,然后用滑鼠指標單擊它。互動式元素周期表將顯示在視窗中。現在只需將滑鼠指標移到元素周期表元素上,然后選擇要查看其屬性的元素。這基本上就是我會這樣做的方式,但是,對于每個人來說都是如此。我只是想我會傳遞它。

元素周期表本身可以是一個 JPanel,由 103 個 JLabel 組成,采用網格型別布局,每個 JLabel 都有自己的元素影像和其他 JLabel,例如標題和圖例資料。按照你喜歡的方式裝扮它。重要的部分是創建一個全域滑鼠偵聽器來處理所有元素 JLabel 的mouseEnteredmouseExited(用于邊框突出顯示)和mouseClicked(用于顯示屬性)事件。這甚至可能是一個內部類,例如:

private class ElementsMouseHandler extends java.awt.event.MouseAdapter {
    @Override
    public void mouseClicked(java.awt.event.MouseEvent evt) {
         // Do whatever you like here
    }

    @Override
    public void mouseReleased(java.awt.event.MouseEvent evt) {
         // Example:

         // Ignore the right mouse button.
         if (SwingUtilities.isRightMouseButton(evt)) {
            return;
        }
        
        /* Which JLabel fired the event. You can do this also in 
           the other events below.       */
        javax.swing.JLabel source = (javax.swing.JLabel) evt.getSource();

        // Get the name placed into the element JLabel's Name property
        String elementName = source.getName();

        /* Do whatever you want here like perhaps display another JPanel
           in the window containing the properties information or the 
           image thereof related to the elementName retrieved.    */
    }

    @Override
    public void mouseEntered(java.awt.event.MouseEvent evt) {
        // Do whatever you like here
    }

    @Override
    public void mouseExited(java.awt.event.MouseEvent evt) {
        // Do whatever you like here
    }
}

然后,當您在 Main 類的成員區域中時,您可能會遇到以下情況:

ElementsMouseHandler elementsMouseHandler;

然后在你初始化所有元素 JLabels 之前,你可以有這樣的東西:

elementsMouseHandler = new ElementsMouseHandler();

當您實際初始化元素 JLabel 時,您可以執行以下操作:

elementJLabel[idx].addMouseListener(elementMouseHandler);

現在,同一個滑鼠偵聽器可以處理所有 Elements JLabel 的滑鼠事件。無論如何……值得深思。

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/498056.html

標籤:爪哇 图片 班级

上一篇:PILImage如何保存具有非整數和非正值的NumPy陣列?

下一篇:如何從HTMLImageElement獲取mimeType?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • CA和證書

    1、在 CentOS7 中使用 gpg 創建 RSA 非對稱密鑰對 gpg --gen-key #Centos上生成公鑰/密鑰對(存放在家目錄.gnupg/) 2、將 CentOS7 匯出的公鑰,拷貝到 CentOS8 中,在 CentOS8 中使用 CentOS7 的公鑰加密一個檔案 gpg -a ......

    uj5u.com 2020-09-10 00:09:53 more
  • Kubernetes K8S之資源控制器Job和CronJob詳解

    Kubernetes的資源控制器Job和CronJob詳解與示例 ......

    uj5u.com 2020-09-10 00:10:45 more
  • VMware下安裝CentOS

    VMware下安裝CentOS 一、軟硬體準備 1 Centos鏡像準備 1.1 CentOS鏡像下載地址 下載地址 1.2 CentOS鏡像下載程序 點擊下載地址進入如下圖的網站,選擇需要下載的版本,這里選擇的是Centos8,點擊如圖所示。 決定選擇Centos8后,選擇想要的鏡像源進行下載,此 ......

    uj5u.com 2020-09-10 00:12:10 more
  • 如何使用Grep命令查找多個字串

    如何使用Grep 命令查找多個字串 大家好,我是良許! 今天向大家介紹一個非常有用的技巧,那就是使用 grep 命令查找多個字串。 簡單介紹一下,grep 命令可以理解為是一個功能強大的命令列工具,可以用它在一個或多個輸入檔案中搜索與正則運算式相匹配的文本,然后再將每個匹配的文本用標準輸出的格式 ......

    uj5u.com 2020-09-10 00:12:28 more
  • git配置http代理

    git配置http代理 經常遇到克隆 github 慢的問題,這里記錄一下幾種配置 git 代理的方法,解決 clone github 過慢。 目錄 git配置代理 git單獨配置github代理 git配置全域代理 配置終端環境變數 git配置代理 主要使用 git config 命令 git單獨 ......

    uj5u.com 2020-09-10 00:12:33 more
  • Linux npm install 裝包時提示Error EACCES permission denied解

    npm install 裝包時提示Error EACCES permission denied解決辦法 ......

    uj5u.com 2020-09-10 00:12:53 more
  • Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包

    Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包。 18 (flaskApi) [root@67 flaskDemo]# yum -y install nginx 19 已加載插件:fastestmirror, langpacks 20 Loading ......

    uj5u.com 2020-09-10 00:13:13 more
  • Linux查看服務器暴力破解ssh IP

    在公網的服務器上經常遇到別人爆破你服務器的22埠,用來挖礦或者干其他嘿嘿嘿的事情~ 這種情況下正確的做法是: 修改默認ssh的22埠 使用設定密鑰登錄或者白名單ip登錄 建議服務器密碼為復雜密碼 創建普通用戶登錄服務器(root權限過大) 建立堡壘機,實作統一管理服務器 統計爆破IP [root ......

    uj5u.com 2020-09-10 00:13:17 more
  • CentOS 7系統常見快捷鍵操作方式

    Linux系統中一些常見的快捷方式,可有效提高操作效率,在某些時刻也能避免操作失誤帶來的問題。 ......

    uj5u.com 2020-09-10 00:13:31 more
  • CentOS 7作業系統目錄結構介紹

    作業系統存在著大量的資料檔案資訊,相應檔案資訊會存在于系統相應目錄中,為了更好的管理資料資訊,會將系統進行一些目錄規劃,不同目錄存放不同的資源。 ......

    uj5u.com 2020-09-10 00:13:35 more
最新发布
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:43:21 more
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:42:36 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:26:53 more
  • 設定Windows主機的瀏覽器為wls2的默認瀏覽器

    這里以Chrome為例。 1. 準備作業 wsl是可以使用Windows主機上安裝的exe程式,出于安全考慮,默認情況下改功能是無法使用。要使用的話,終端需要以管理員權限啟動。 我這里以Windows Terminal為例,介紹如何默認使用管理員權限打開終端,具體操作如下圖所示: 2. 操作 wsl ......

    uj5u.com 2023-04-19 09:25:49 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:19:04 more
  • Linux學習筆記

    IP地址和主機名 IP地址 ifconfig可以用來查詢本機的IP地址,如果不能使用,可以通過install net-tools安裝。 Centos系統下ens33表示主網卡;inet后表示IP地址;lo表示本地回環網卡; 127.0.0.1表示代指本機;0.0.0.0可以用于代指本機,同時在放行設 ......

    uj5u.com 2023-04-18 06:52:01 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:50 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:01 more
  • 你是不是暴露了?

    作者:袁首京 原創文章,轉載時請保留此宣告,并給出原文連接。 如果您是計算機相關從業人員,那么應該經歷不止一次網路安全專項檢查了,你肯定是收到過資訊系統技術檢測報告,要求你加強風險監測,確保你提供的系統服務堅實可靠了。 沒檢測到問題還好,檢測到問題的話,有些處理起來還是挺麻煩的,尤其是線上正在運行的 ......

    uj5u.com 2023-04-05 16:52:56 more
  • 細節拉滿,80 張圖帶你一步一步推演 slab 記憶體池的設計與實作

    1. 前文回顧 在之前的幾篇記憶體管理系列文章中,筆者帶大家從宏觀角度完整地梳理了一遍 Linux 記憶體分配的整個鏈路,本文的主題依然是記憶體分配,這一次我們會從微觀的角度來探秘一下 Linux 內核中用于零散小記憶體塊分配的記憶體池 —— slab 分配器。 在本小節中,筆者還是按照以往的風格先帶大家簡單 ......

    uj5u.com 2023-04-05 16:44:11 more